pico-bootrom icon indicating copy to clipboard operation
pico-bootrom copied to clipboard

No FAT signature 55-AA in boot sector

Open hathach opened this issue 4 years ago • 10 comments
trafficstars

I have issues using Elm Cham's fatfs to mount pico's uf2 disk and figure out that Boot sector doesn't include FAT signature 55-AA at offset 510. Current implementation has FAT signature at MBR which is not correct/enough https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/virtual_disk.c#L295

ideally would be defined here https://github.com/raspberrypi/pico-bootrom/blob/master/bootrom/virtual_disk.c#L63

static const uint8_t boot_sector[] = {
  // existing code
  [510] = 0x55,
  [511] = 0xAA
}

If you think the change make sense I could make an PR for it.

hathach avatar Feb 26 '21 05:02 hathach

This isn't going to be fixed in any short period of time since it requires a metal mod to the chip. So for the moment, it's probably best to 'not check' for it in the software.

ghollingworth avatar Mar 30 '21 07:03 ghollingworth

thanks for the reply, I am well aware this is burn into rom and a fix will need a re-fab or some sort. I have already implement and walkaround for this. Basically just insert the magic into 510 offset when reading lba=1 (skip the check will need to modify the fatfs library). Hope this will help others, feel free to close it at anytime.

    // sector 0 is MBR
    // sector 1 is boot sector, but it doesn't have FAT signature
    if (sector == 1)
    {
      buff[510] = 0x55;
      buff[511] = 0xAA;
    }

hathach avatar Mar 30 '21 13:03 hathach

Its a bit of a weird one to be checking actually, since Windows itself will happily mount such a volume, and those fields are supposed to indicate a bootable volume (which this isn't). Windows FYI is happy without these two bytes, but still seems to require valid boot code in the first 3 bytes) go figure.

kilograham avatar Oct 05 '21 16:10 kilograham

We recently made a change in FreeBSD to accommodate this (after a user discovered we did not automount a pico): https://github.com/freebsd/freebsd-src/commit/e06ce938ddc0222c6ed10a70108f71685923bd45

There's some commentary in a FreeBSD bug report at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262964 - FreeBSD shouldn't be checking for 55 AA at all, instead doing more thorough validation of the BPB.

/*
 * XXX the signature 0x55 0xAA as the last two bytes of 512 is not required
 * by specifications, but was historically required by fstyp.  This check
 * should be removed, with a more comprehensive BPB validation instead.
 */

emaste avatar Apr 24 '22 14:04 emaste

I am working on using the pico as device connected to android tablets. Tested on two android devices (One with android 10 & one with android 11) and both come up with "Format of the device is needed" popup.

So i think also android has such an detection issue!

The really bad thing about is, with issue in the rom itself, i can not auto update the RPI from the android hosts.

popy2k14 avatar Dec 01 '22 10:12 popy2k14

Is it possible for someone to fork this repo with the required fixes and with clear instructions to compile as a Second Stage bootloader? IE to test functionality on existing silicon?

Zitt avatar Jan 16 '23 00:01 Zitt

I've not tried it myself, but I spotted this project a while ago and thought it looked interesting: https://github.com/brendena/pico_drag_n_drop_programmer Perhaps it can be adapted to do what you're asking for?

lurch avatar Jan 16 '23 23:01 lurch