Skip to contentSkip to conversation

disk: dos: Add all options for EFI System Partitions

PATCH In review Peter Robinson 4 participants 4 messages Mar 2, 2024 – Mar 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 disk: dos: Add all options for EFI System Partitions

The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the EFI partition table ID of 0xef. A number of arm devices will not find their firmware on a FAT partition with an ID of 0xef so also allow the original FAT12/16/32 partition IDs as they are also permissable for an ESP.

---

v2:
- Add 0x0c option
- Make hex constants consistent
- Move from if to switch statement
v3:
- Fix switch brain fart
v4:
- Drop boot_ind out of switch

 disk/part_dos.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
disk/part_dos.c +12 -1
index 567ead7511d..a35181dff4f 100644
@@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p)
 {
 	int ret = 0;
 
-	if (p->sys_ind == 0xef)
+	switch (p->sys_ind) {
+	case 0x01:
+	case 0x06:
+	case 0x0b:
+	case 0x0c:
+	case 0xef:
 		ret |= PART_EFI_SYSTEM_PARTITION;
+		break;
+	default:
+		break;
+	}
+
 	if (p->boot_ind == 0x80)
 		ret |= PART_BOOTABLE;
+
 	return ret;
 }
 
Signature · 1 line
2.44.0
Reviewed-by on v4 1/1
#1 lore raw
Quoted 11 lines

From: Peter Robinson <[email protected]>
Date: Sat, 2 Mar 2024 11:20:31 +0000

The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the EFI partition table ID of 0xef. A number of arm devices will not find their firmware on a FAT partition with an ID of 0xef so also allow the original FAT12/16/32 partition IDs as they are also permissable for an ESP.

Quoted 45 lines

---

v2:
- Add 0x0c option
- Make hex constants consistent
- Move from if to switch statement
v3:
- Fix switch brain fart
v4:
- Drop boot_ind out of switch

 disk/part_dos.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
disk/part_dos.c +12 -1
index 567ead7511d..a35181dff4f 100644
@@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p)
 {
 	int ret = 0;
 
-	if (p->sys_ind == 0xef)
+	switch (p->sys_ind) {
+	case 0x01:
+	case 0x06:
+	case 0x0b:
+	case 0x0c:
+	case 0xef:
 		ret |= PART_EFI_SYSTEM_PARTITION;
+		break;
+	default:
+		break;
+	}
+
 	if (p->boot_ind == 0x80)
 		ret |= PART_BOOTABLE;
+
 	return ret;
 }
 
Signature · 1 line
2.44.0
Reviewed-by on v4 1/1
#2 lore raw
In reply to Peter Robinson
Quoted 51 lines · Peter Robinson

The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the EFI partition table ID of 0xef. A number of arm devices will not find their firmware on a FAT partition with an ID of 0xef so also allow the original FAT12/16/32 partition IDs as they are also permissable for an ESP.

---

v2:
- Add 0x0c option
- Make hex constants consistent
- Move from if to switch statement
v3:
- Fix switch brain fart
v4:
- Drop boot_ind out of switch

 disk/part_dos.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
disk/part_dos.c +12 -2
index 567ead7511d..a35181dff4f 100644
@@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p)
 {
        int ret = 0;
 
-       if (p->sys_ind == 0xef)
+       switch (p->sys_ind) {
+       case 0x01:
+       case 0x06:
+       case 0x0b:
+       case 0x0c:
+       case 0xef:
                ret |= PART_EFI_SYSTEM_PARTITION;
+               break;
+       default:
+               break;
+       }
+
        if (p->boot_ind == 0x80)
                ret |= PART_BOOTABLE;
+
        return ret;
 }
 
--
Quoted 2 lines

2.44.0

#3 lore raw
In reply to Peter Robinson
Quoted 10 lines · Peter Robinson

The EFI spec states that the ESP can be any of FAT12/16/32 but for compatibility doesn't necssarily require the partition to be the EFI partition table ID of 0xef. A number of arm devices will not find their firmware on a FAT partition with an ID of 0xef so also allow the original FAT12/16/32 partition IDs as they are also permissable for an ESP.

This leads to these failures in CI:
https://source.denx.de/u-boot/u-boot/-/jobs/794519#L598

Signature · 1 line
Tom