Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Mar 2015 21:11:54 +0200
From:      Guy Yur <guyyur@gmail.com>
To:        Tim Kientzle <tim@kientzle.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>, Hellmuth Michaelis <hm@hellmuth-michaelis.de>
Subject:   Re: beaglebone boot from eMMC
Message-ID:  <CAC67Hz_wmSLi3Om=03ids1ZvFpqPtNfOVAhTR5JMBnTS1zFEwQ@mail.gmail.com>
In-Reply-To: <40A94DE3-36A6-4E85-8B59-15329D00E89C@kientzle.com>
References:  <3DF08C65-20E3-4524-B0E1-C5C096AA0FE8@hellmuth-michaelis.de> <54BA6DB9-DC61-4A6F-B948-777BB9800F54@bocal.org> <A923E8B5-72DC-4C19-B5CA-7729C7E16A5C@hellmuth-michaelis.de> <20150312132739.GA28385@cicely7.cicely.de> <A3E0A638-450D-4B83-90F7-090D45FF4420@bsdimp.com> <3EF47A05-60B2-4BB0-8688-018E50CF7D4A@hellmuth-michaelis.de> <CAC67Hz_ssdAHoRFqC7VAR9_XvTchc5DNhKPY4=LstcMx3j9NXw@mail.gmail.com> <40A94DE3-36A6-4E85-8B59-15329D00E89C@kientzle.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Mar 19, 2015 at 5:41 AM, Tim Kientzle <tim@kientzle.com> wrote:
>
>> On Mar 18, 2015, at 11:16 AM, Guy Yur <guyyur@gmail.com> wrote:
>>
>> Hi,
>>
>>
>> Is your msdosfs slice on the eMMC aligned to 1 MB?
>>
>> I had the same "CCC" problem when I aligned the partition
>> and used newfs_msdos.
>> Removing the sector count adjustment calculation in newfs_msdos
>> as was done in NetBSD worked for me.
>>
>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D183234
>
> Fortunately, the AM335x TRM from TI documents the exact checks made by th=
e ROM before it will recognize a valid MSDOS partition.  So you don=E2=80=
=99t need to guess; you can compare a hex dump of your disk with the docs a=
nd see exactly what=E2=80=99s gone wrong.
>
> As I recall, the ROM is very unforgiving:
>
> * The CHS geometry used in the MBR has to exactly match the MSDOS format =
geometry.  Attempts to align the partition on round boundaries can screw th=
is up badly.
>

I didn't see anything in the TI document about alignment and
it works fine for me with 1MB on eMMC with patched newfs_msdos.
The problem is with the check that requires the number of sectors
to equal the partition size.
newfs_msdos trims the sector count so the condition isn't met.

Page 4574 - Figure 26-22. FAT Detection Procedure
BPB_TotSec16 or
BPB_TotSec32
=3D
MBR_Partition_Size


> * The FAT format type (12, 16, or 32) has to match the ROM expectations
>
> If any of the ROM checks fail, it will assume the device is not usable an=
d try a different device (ultimately ending up with CCCC on the serial port=
).
>
> The corresponding code in Crochet uses
>
> $ gpart add -a 63 -b 63 -s 2m -t =E2=80=98!12=E2=80=99 <device>
>
> to create the MSDOS partition and then uses
>
> $ newfs_msdos -L <label> -F 12 <device>
>
> Note: Use -F 12 for an MSDOS partition of 16MB or less, otherwise use -F =
16.
>
> Tim
>
>

On my BeagleBone Black Rev A5C eMMC C/H/S is 20/183/1024 not NN/255/63.

Alignment on sector 63 and newfs_msdos will create a
FAT boot sector with incorrect number of sectors.
Before kern.geom.part.mbr.enforce_chs was introduced "-a 63"
didn't really align on sector 63 when C/H/S was different.


# diskinfo -v /dev/mmcsd0
/dev/mmcsd0
        512             # sectorsize
        1920991232      # mediasize in bytes (1.8G)
        3751936         # mediasize in sectors
        524288          # stripesize
        0               # stripeoffset
        20              # Cylinders according to firmware.
        183             # Heads according to firmware.
        1024            # Sectors according to firmware.
        ........        # Disk ident.


Example with md device:
# dd if=3D/dev/zero of=3Ddisk.img bs=3D524288 count=3D3664
# mdconfig -a -u 0 -t vnode -S 512 -x 1024 -y 183 -f disk.img

# gpart create -s MBR md0
# gpart add -a 63 -b 63 -s 2m -t '\!12' md0

# newfs_msdos -L label -F 12 md0s1
newfs_msdos: trim 1023 sectors to adjust to a multiple of 1024
/dev/md0s1: 3021 sectors in 3021 FAT12 clusters (512 bytes/cluster)
BytesPerSec=3D512 SecPerClust=3D1 ResSectors=3D1 FATs=3D2 RootDirEnts=3D512
Sectors=3D3072 Media=3D0xf0 FATsecs=3D9 SecPerTrack=3D1024 Heads=3D183 Hidd=
enSecs=3D0

With kern.geom.part.mbr.enforce_chs=3D0 (default on head)
# gpart show md0
=3D>   1024  3750912  md0  MBR  (1.8G)
     1024       47       - free -  (24K)
     1071     4095    1  !12  (2.0M)
     5166  3746770       - free -  (1.8G)


3072 !=3D 4095 causing the boot to fail.


With kern.geom.part.mbr.enforce_chs=3D1
# gpart show md0
=3D>   1024  3750912  md0  MBR  (1.8G)
     1024     1024       - free -  (512K)
     2048     3072    1  !12  (1.5M)
     5120  3746816       - free -  (1.8G)

# newfs_msdos -L label -F 12 md0s1
/dev/md0s1: 3021 sectors in 3021 FAT12 clusters (512 bytes/cluster)
BytesPerSec=3D512 SecPerClust=3D1 ResSectors=3D1 FATs=3D2 RootDirEnts=3D512
Sectors=3D3072 Media=3D0xf0 FATsecs=3D9 SecPerTrack=3D1024 Heads=3D183 Hidd=
enSecs=3D0



Guy



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAC67Hz_wmSLi3Om=03ids1ZvFpqPtNfOVAhTR5JMBnTS1zFEwQ>