raspberrypi / rpi-eeprom

Installation scripts and binaries for the Raspberry Pi 4 and Raspberry Pi 5 bootloader EEPROMs
https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-boot-eeprom
Other
1.26k stars 203 forks source link

GPT ESP Partition: Unable to read partition as FAT #558

Closed ragazenta closed 6 months ago

ragazenta commented 6 months ago

Describe the bug

Hi, I'm unable to boot SD Card if I use GPT scheme with EFI System Partition (ESP) as bootfs.

I've read previous related issue #359 and it should've already been fixed in e87bc4da8d983aa6e7c3edcf8cd823b76e50e65e, but currently it's not.

Steps to reproduce the behaviour

I'm using custom OS image in SD Card and official RaspiOS Bookworm Lite in USB.

Booting from USB to see bootloader version.

pi@raspberrypi:~$ vcgencmd bootloader_version 
2023/01/11 17:40:52
version 8ba17717fbcedd4c3b6d4bce7e50c7af4155cba9 (release)
timestamp 1673458852
update-time 1712134741
capabilities 0x0000007f

Disk partition

pi@raspberrypi:~$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda           8:0    1 57.3G  0 disk 
├─sda1        8:1    1  512M  0 part /boot/firmware
└─sda2        8:2    1 56.8G  0 part /
mmcblk0     179:0    0 29.7G  0 disk 
├─mmcblk0p1 179:1    0  512M  0 part 
└─mmcblk0p2 179:2    0  1.3G  0 part 
Click to show output of fdisk -l ``` pi@raspberrypi:~$ sudo fdisk -l /dev/mmcblk0 Disk /dev/mmcblk0: 29.73 GiB, 31927042048 bytes, 62357504 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 58C0F1B1-E142-405A-8F9B-D1206CEE54FD Device Start End Sectors Size Type /dev/mmcblk0p1 2048 1050623 1048576 512M EFI System /dev/mmcblk0p2 1050624 3795719 2745096 1.3G Linux root (ARM-64) ```
Click to show output of gdisk -l ``` pi@raspberrypi:~$ sudo gdisk -l /dev/mmcblk0 GPT fdisk (gdisk) version 1.0.9 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Disk /dev/mmcblk0: 62357504 sectors, 29.7 GiB Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): 58C0F1B1-E142-405A-8F9B-D1206CEE54FD Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 2048, last usable sector is 62357470 Partitions will be aligned on 2048-sector boundaries Total free space is 58561751 sectors (27.9 GiB) Number Start (sector) End (sector) Size Code Name 1 2048 1050623 512.0 MiB EF00 bootfs 2 1050624 3795719 1.3 GiB 8305 rootfs ```
Click to show Partition GUID ``` pi@raspberrypi:~$ sudo gdisk /dev/mmcblk0 GPT fdisk (gdisk) version 1.0.9 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): i Partition number (1-2): 1 Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI system partition) Partition unique GUID: 9AB42A2C-2354-426F-9ADD-B4B5BF492FB5 First sector: 2048 (at 1024.0 KiB) Last sector: 1050623 (at 513.0 MiB) Partition size: 1048576 sectors (512.0 MiB) Attribute flags: 0000000000000000 Partition name: 'bootfs' ```

Device (s)

Raspberry Pi 5, Raspberry Pi 4 Mod. B

Bootloader configuration.

pi@raspberrypi:~$ rpi-eeprom-config 
[all]
BOOT_UART=1
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0
BOOT_ORDER=0xf41

System

No response

Bootloader logs

In this log, the bootloader failed to read ESP partition in SD Card, so then it will boot to USB.

BOOTMODE: 0x06 partition 0 build-ts BUILD_TIMESTAMP=1673458852 serial f983c8f3 boardrev b03115 stc 508925
PM_RSTS: 0x00001020
part 00000000 reset_info 00000000
uSD voltage 3.3V
Initialising SDRAM 'Samsung' 16Gb x1 total-size: 16 Gbit 3200
DDR 3200 0 0 16 152

XHCI-STOP
xHC ver: 256 HCS: 05000420 fc000031 00e70004 HCC: 002841eb
USBSTS 11
xHC ver: 256 HCS: 05000420 fc000031 00e70004 HCC: 002841eb
xHC ports 5 slots 32 intrs 4
Boot mode: SD (01) order f4
USB3[2] 00281203 connected enabled
USB3 root HUB port 2 init
USB2[1] 400202e1 connected
DEV [01:00] 3.32 000000:02 class 0 VID 0781 PID 5583
MSD device [01:00] 3.32 000000:02 conf 0 iface 0 ep 81#1024 02#1024
MSD [01:00] 3.32 000000:02 register MSD
USB2 root HUB port 1 init
DEV [02:00] 2.16 000000:01 class 9 VID 2109 PID 3431
HUB init [02:00] 2.16 000000:01
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SD HOST: 200000000 CTL0: 0x00800f00 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
OCR c0ff8000 [55]
CID: 00035344534433324785fcf380b20163
CSD: 400e00325b590000eddf7f800a400000
SD: bus-width: 4 spec: 2 SCR: 0x02358083 0x01006432
SD HOST: 200000000 CTL0: 0x00800f04 BUS: 50000000 Hz actual: 50000000 HZ div: 4 (2) status: 0x1fff0000 delay: 2
MBR: 0x00000001,62357503 type: 0xee
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
Trying partition: 0
GPT b1f1c05842e15a408f9bd1206cee54fd 000000001 003b77fff num-partitions 128 entry-size 128
GPT partition: 0 c12a7328-f81f-11d2-ba4b-00a0c93ec93b 000000800..0001007ff
Matched GUID bootable-part-idx 0 want partition 0
Unable to read partition as FAT
type: 16 lba: 2048 oem: 'mkfs.fat' volume: ' BOOTFS     '
rsc 32 fat-sectors 128 c-count 0 c-size 1
root dir cluster 0 sectors 0 entries 0
Trying partition: 0
GPT b1f1c05842e15a408f9bd1206cee54fd 000000001 003b77fff num-partitions 128 entry-size 128
GPT partition: 0 c12a7328-f81f-11d2-ba4b-00a0c93ec93b 000000800..0001007ff
Matched GUID bootable-part-idx 0 want partition 0
Unable to read partition as FAT
type: 16 lba: 2048 oem: 'mkfs.fat' volume: ' BOOTFS     '
rsc 32 fat-sectors 128 c-count 0 c-size 1
root dir cluster 0 sectors 0 entries 0
Retry SD 1
SD HOST: 200000000 CTL0: 0x00800000 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
SD HOST: 200000000 CTL0: 0x00800f00 BUS: 400000 Hz actual: 390625 HZ div: 512 (256) status: 0x1fff0000 delay: 276
OCR c0ff8000 [3]
CID: 00035344534433324785fcf380b20163
CSD: 400e00325b590000eddf7f800a400000
SD: bus-width: 4 spec: 2 SCR: 0x02358083 0x01006432
SD HOST: 200000000 CTL0: 0x00800f04 BUS: 50000000 Hz actual: 50000000 HZ div: 4 (2) status: 0x1fff0000 delay: 2
MBR: 0x00000001,62357503 type: 0xee
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
MBR: 0x00000000,       0 type: 0x00
Trying partition: 0
GPT b1f1c05842e15a408f9bd1206cee54fd 000000001 003b77fff num-partitions 128 entry-size 128
GPT partition: 0 c12a7328-f81f-11d2-ba4b-00a0c93ec93b 000000800..0001007ff
Matched GUID bootable-part-idx 0 want partition 0
Unable to read partition as FAT
type: 16 lba: 2048 oem: 'mkfs.fat' volume: ' BOOTFS     '
rsc 32 fat-sectors 128 c-count 0 c-size 1
root dir cluster 0 sectors 0 entries 0
Trying partition: 0
GPT b1f1c05842e15a408f9bd1206cee54fd 000000001 003b77fff num-partitions 128 entry-size 128
GPT partition: 0 c12a7328-f81f-11d2-ba4b-00a0c93ec93b 000000800..0001007ff
Matched GUID bootable-part-idx 0 want partition 0
Unable to read partition as FAT
type: 16 lba: 2048 oem: 'mkfs.fat' volume: ' BOOTFS     '
rsc 32 fat-sectors 128 c-count 0 c-size 1
root dir cluster 0 sectors 0 entries 0
Boot mode: USB-MSD (04) order f

USB boot

No response

NVMe boot

No response

Network (TFTP boot)

No response

ragazenta commented 6 months ago

Is it because FAT 16?

It's weird why the bootloader detect it as type: 16 when lsblk shows FAT32?

pi@raspberrypi:~$ lsblk -f /dev/mmcblk0
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
mmcblk0

├─mmcblk0p1
│    vfat   FAT32 BOOTFS
│                       069C-A08E                                           
└─mmcblk0p2
     ext4   1.0   rootfs
                        048f37e1-864f-4d4f-aeb9-16f7734b888d
ragazenta commented 6 months ago

I guess this is not issue from here, but from the tool I use to create os image (mkosi, see here)

Also, it doesn't feel right to use esp (efi system partition) as raspi bootloader is not uefi.