FAT partition format

Hi,

I'm having trouble with getting an SD Card programmed from an image
working. Basically, I'm formatting the FAT partition of a loop device
and the writin the loopback image to the card. On boot and power, I
just see the ASIC id and nothing else. However formatting the sdcard
directly and copying the bootloader etc works.

This doesn't work:
losetup /dev/loop2 <img-name>
mkfs.msdos /dev/loop2 -n boot
mount /dev/loop2 /tmp/mnt
cp MLO ... /tmp/mnt

But this does work,
mkfs.msdos /dev/mmcblk0p1 -n boot
mount /dev/mmcblk0p1 /tmp/mnt
cp MLO ... /tmp/mnt

I initially thought since I was not specifying the loop device size,
it was switching to FAT32, but specifying a smaller loop device size
using --sizelimit doesn't change anything. Specifying -F 16 doesn't
make it work either.

I am curious to know what is different. Let me know if I'm missing
something obvious.

Thanks,
Joel

Hi,

I'm having trouble with getting an SD Card programmed from an image
working. Basically, I'm formatting the FAT partition of a loop device
and the writin the loopback image to the card. On boot and power, I
just see the ASIC id and nothing else. However formatting the sdcard
directly and copying the bootloader etc works.

This doesn't work:
losetup /dev/loop2 <img-name>

So you're in superfloppy mode now

mkfs.msdos /dev/loop2 -n boot
mount /dev/loop2 /tmp/mnt
cp MLO ... /tmp/mnt

And how are you writing that back to the card?

Joel,

Are you certain that the master boot record is the same in both cases? The ROM boot loader is very picky about that. Also ensure that all data between the MBR and the first partition start is 0. I presume you are creating the SD card image blank from /dev/zero but you don't show that below.

Also have you tried reading the image back and doing a comparison? If you control the environment you should be able to get a decent compare. (Zero the first N MB of the fat partition on the card before formating it. Don't zero all of it, people have seen issues with SD cards not handling that well.)

Bill

Joel,

Are you certain that the master boot record is the same in both cases? The
ROM boot loader is very picky about that. Also ensure that all data between
the MBR and the first partition start is 0. I presume you are creating the
SD card image blank from /dev/zero but you don't show that below.

Hi William,

I don't think its an MBR issue because just reformatting the FAT
partition after writing to the MMC card fixes it, so the issue is with
FAT

My loopback file is sparse to begin so it should read back zeros.

dd if=/dev/zero of=image bs=4k count=1 seek=$((256*1024))

Also have you tried reading the image back and doing a comparison? If you
control the environment you should be able to get a decent compare. (Zero
the first N MB of the fat partition on the card before formating it. Don't
zero all of it, people have seen issues with SD cards not handling that
well.)

Thanks, I'll try this.

Regards,
Joel

Hi Koen,

So you're creating a 'superfloppy' with no partition table and the fs on the full disk.

And stop putting me in CC:, this is a subscriber only list, so if I can post to it I can receive your mails without CC:

Hi Koen,

Hi,

I'm having trouble with getting an SD Card programmed from an image
working. Basically, I'm formatting the FAT partition of a loop device
and the writin the loopback image to the card. On boot and power, I
just see the ASIC id and nothing else. However formatting the sdcard
directly and copying the bootloader etc works.

This doesn't work:
losetup /dev/loop2 <img-name>

So you're in superfloppy mode now

mkfs.msdos /dev/loop2 -n boot
mount /dev/loop2 /tmp/mnt
cp MLO ... /tmp/mnt

And how are you writing that back to the card?

I'm doing:
dd if=image of=/dev/mmcblk0 bs=10M

So you're creating a 'superfloppy' with no partition table and the fs on the full disk.

The dd command writes the whole image including the partition table,
fat and fs partitions to the card. The image file is an SD card image.

And stop putting me in CC:, this is a subscriber only list, so if I can post to it I can receive your mails without CC:

OK.

Thanks,
Joel

You said you're doing:

1) losetup /dev/loop2 <img-name>

That assigns the full image to loop2, so loop2 is like the complete sd card

2) mkfs.msdos /dev/loop2 -n boot

Now you format the complete card as fat, overwriting any partition table you had

3) mount /dev/loop2 /tmp/mnt

mount, nothing strange here

4) cp MLO ... /tmp/mnt

and nothing strange there.

But if you dd this to your SD card, you will only no partition table, only a fat fs -> superfloppy

Sorry that I didn't mention I was passing an offet to losetup [1]

Thanks,
Joel

[1] https://github.com/joelagnel/oe-core/blob/04efd0c02dd004df260cb8e64875e5c046eec9a9/meta/classes/image_types.bbclass#L113

Joel A Fernandes wrote:

You said you're doing:

1) losetup /dev/loop2<img-name>

Sorry that I didn't mention I was passing an offet to losetup [1]

Thanks,
Joel

[1] https://github.com/joelagnel/oe-core/blob/04efd0c02dd004df260cb8e64875e5c046eec9a9/meta/classes/image_types.bbclass#L113

32256, a truly magic number :slight_smile:

Joel A Fernandes wrote:

This seems to be it, I can boot now. Thank you!:slight_smile:

-Joel