Closed andreiw closed 4 years ago
Looks like this won't be needed after all, see my comment in the megathread.
According to @Googulator:
OK, looks like we won't need that ugly SD driver hack at all.
**The Pi, in addition to MBR, can also boot from a so-called "superfloppy" SD card, which has no partition table, just the file system header (VBR) right at the beginning. Additionally, the only thing it actually checks for is the FAT32 BPB (BIOS parameter block), located at address 0x0B-0x56 (inclusive) in the VBR sector. Since the partition table is in 0x1BE-0x1EE, you can have both a BPB and a protective MBR in sector 0. In such a scenario, Windows and UEFI give precedence to the protective MBR and the GPT, while the boot ROM prefers the BPB.
Additionally, FAT32 allows having an arbitrary number of reserved sectors between the VBR and the beginning of the file system proper.
So, assuming that the first GPT partition on the drive is the ESP formatted to FAT32, beginning in sector #2048 (Windows typically creates the ESP there), it's possible to copy the BPB from sector 2048 to sector 0 (copy offset 0x10000B-0x100056 to offset 0x0B-0x56), and then add 2048 to the "reserved sector count" value (a 16-bit little-endian integer at offset 0x0E-0x0F - the boot ROM uses it to find the FAT). This way, the boot ROM will see a superfloppy, and everything else will parse the GPT, as intended.**
Basically at this point this issue tracks the development of a tool to patch a a GPT SD image/device into a Pi-bootable "superfloppy"
So, all that the tool needs to do is this (assuming ESP at sector 2048):
On Linux, this is trivial. On Windows, it's a PITA due to how Windows handles physical device writes.
Setting the FAT32 boot MBR partition as active also fixes the first boot error. The only issue is that after Windows finishes the configuration it will hang at a black screen and restart if any USB device is plugged in. After that it will boot normally.
So there is no need for a hybrid GPT?
A
On Jul 8, 2018, at 11:48 AM, Mario Bălănică notifications@github.com wrote:
Setting the FAT32 boot MBR partition as active also fixes the first boot error. The only issue is that after Windows finishes the configuration it will hang at a black screen and restart if any USB device is plugged in. After that it will boot normally.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
No.
Merge https://github.com/Googulator/RaspberryPiPkg/commit/844a02a473b147e621e8d4709b6eaababd8fa2d9 in a TBD fashion