summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2025-04-30 12:44:07 +0800
committerSteve Sakoman <steve@sakoman.com>2025-05-14 08:33:40 -0700
commit84bf4efc11ec166b0711b4d17345a0ac95b96d65 (patch)
tree0b8c4232a3f2fe31e1394fdae709dd51081ba93c /meta/recipes-devtools
parentbe58b8a46a50f1ffb34b32fd580d98c68c6ea270 (diff)
downloadpoky-84bf4efc11ec166b0711b4d17345a0ac95b96d65.tar.gz
cdrtools-native: fix booting EFI ISO live failed
In ISO live, if the size of efi.img > 32MB, and copy EFI application (bootx64.efi) to efi.img behind of kernel and initrd, UEFI system could not find EFI application bootx64.efi Using QEMU+OVMF to boot ISO live image, press ESC to enter UEFI shell: ... Shell> ls FS0:\ Directory of: FS0:\ 04/05/2011 23:00 12,985,344 bzImage 04/05/2011 23:00 <DIR> 2,048 EFI 04/05/2011 23:00 20,494,696 initrd 04/05/2011 23:00 26 startup.nsh 3 File(s) 33,480,066 bytes 1 Dir(s) Shell> ls FS0:\EFI Directory of: FS0:\EFI 0 File(s) 0 bytes 0 Dir(s) ... In following case, add 64MB extra space to bootable image efi.img, and the partition table of EFI is truncated to 26.3M $ echo 'IMAGE_FSTYPES:pn-core-image-minimal = " live"' >> conf/local.conf $ echo 'MACHINE_FEATURES:append = " efi pcbios"' >> conf/local.conf $ echo '# 64MB extra space to bootable image efi.img' >> conf/local.conf $ echo 'BOOTIMG_EXTRA_SPACE = "65535"' >> conf/local.conf $ bitbake core-image-minimal $ fdisk -l tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso ... Device Boot Start End Sectors Size Id Type tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso1 * 0 376831 376832 184M 0 Empty tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso2 120 54079 53960 26.3M ef EFI (FAT-12/16/32) According to page 11: `Figure 5 - Section Entry' in El Torito Bootable CD-ROM Format Specification [1]. The sector count takes 2 byte which means max sector count is 0xffff (65535), for 512-byte sector, the size of bootable image is no more than 32MB (65536 * 512 / 1024 / 1024) This commit truncate to 32MB if image size larger than 32MB, and report a warning, then save the extra image sector count to vendor unique selection criteria After apply this commit, the partition table of EFI is truncated to 32M $ fdisk -l tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso ... Device Boot Start End Sectors Size Id Type tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso1 * 0 376831 376832 184M 0 Empty tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.rootfs.iso2 120 65654 65535 32M ef EFI (FAT-12/16/32) [1]https://pdos.csail.mit.edu/6.828/2017/readings/boot-cdrom.pdf (From OE-Core rev: 259bb8907d8bfe1217e88a3b6935c160e5a92f8d) (From OE-Core rev: d184f119c26983c2f15b47a25204049d0525c871) Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/cdrtools/cdrtools-native_3.01.bb1
-rw-r--r--meta/recipes-devtools/cdrtools/cdrtools/0001-fix-nsectors-exceeds-0xffff-situation.patch69
2 files changed, 70 insertions, 0 deletions
diff --git a/meta/recipes-devtools/cdrtools/cdrtools-native_3.01.bb b/meta/recipes-devtools/cdrtools/cdrtools-native_3.01.bb
index 085384064d..428202c258 100644
--- a/meta/recipes-devtools/cdrtools/cdrtools-native_3.01.bb
+++ b/meta/recipes-devtools/cdrtools/cdrtools-native_3.01.bb
@@ -15,6 +15,7 @@ SRC_URI = " \
15 file://0001-Don-t-set-uid-gid-during-install.patch \ 15 file://0001-Don-t-set-uid-gid-during-install.patch \
16 file://riscv64-linux-gcc.rul \ 16 file://riscv64-linux-gcc.rul \
17 file://gcc14-fix.patch \ 17 file://gcc14-fix.patch \
18 file://0001-fix-nsectors-exceeds-0xffff-situation.patch \
18 " 19 "
19 20
20SRC_URI[md5sum] = "7d45c5b7e1f78d85d1583b361aee6e8b" 21SRC_URI[md5sum] = "7d45c5b7e1f78d85d1583b361aee6e8b"
diff --git a/meta/recipes-devtools/cdrtools/cdrtools/0001-fix-nsectors-exceeds-0xffff-situation.patch b/meta/recipes-devtools/cdrtools/cdrtools/0001-fix-nsectors-exceeds-0xffff-situation.patch
new file mode 100644
index 0000000000..8b0fbb3fe6
--- /dev/null
+++ b/meta/recipes-devtools/cdrtools/cdrtools/0001-fix-nsectors-exceeds-0xffff-situation.patch
@@ -0,0 +1,69 @@
1From ab6b5ee4c23099bf15ddd145fdf1ff4f5e34e802 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Sat, 26 Apr 2025 03:38:32 +0000
4Subject: [PATCH] fix nsectors exceeds 0xffff situation
5
6According to page 11: `Figure 5 - Section Entry' in El Torito Bootable
7CD-ROM Format Specification [1]. The sector count takes 2 byte which
8means max sector count is 0xffff (65535), for 512-byte sector, the
9size of bootable image is no more than 32MB (65536 * 512 / 1024 / 1024)
10
11If the size of efi.img > 32MB, the partition table will be truncated
12in ISO, which caused UEFI system or grub-efi read efi.img broken
13occasionally.
14
15In this patch, nsectors means sector count, if it exceeds 0xffff,
16truncate to 0xffff and set selection criteria type = 2, then save
17extra nsectors to vendor unique selection criteria
18
19[1]https://pdos.csail.mit.edu/6.828/2017/readings/boot-cdrom.pdf
20
21Upstream-Status: Inappropriate [upstream https://sourceforge.net/projects/cdrtools/ is not alive since 2019]
22
23Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
24---
25 mkisofs/eltorito.c | 28 ++++++++++++++++++++++++++++
26 1 file changed, 28 insertions(+)
27
28diff --git a/mkisofs/eltorito.c b/mkisofs/eltorito.c
29index 5dd04bc..a391003 100644
30--- a/mkisofs/eltorito.c
31+++ b/mkisofs/eltorito.c
32@@ -568,6 +568,34 @@ fill_boot_desc(boot_desc_entry, boot_entry)
33 fprintf(stderr, "Extent of boot images is %d\n",
34 get_733(de->isorec.extent));
35 #endif
36+
37+ // Boot sectors exceeds 0xffff
38+ if (nsectors > 0xffff) {
39+ unsigned int extra_nsectors = nsectors - 0xffff;
40+
41+ fprintf(stderr, "Warning: Boot sectors 0x%x(%u) exceeds 0xffff(65535), save extra %u to pad2\n",
42+ nsectors, nsectors, extra_nsectors);
43+
44+ // Set nsectors to maximum 0xffff(65535)
45+ nsectors = 0xffff;
46+
47+ // Offset : 0C byte
48+ // Type : Byte
49+ // Description: Selection criteria type. This defines a vendor unique format
50+ // for bytes 0D-1F.
51+ // The following formats is reserved by Yocto:
52+ // 2 - Save extra sector count to vendor unique selection criteria
53+ boot_desc_entry->pad2[0] = 2;
54+
55+
56+ // Offset : 0D-0E-0F-10 byte
57+ // Type : D Word
58+ // Description: Save extra sector count to vendor unique selection criteria.
59+ // It takes 4 bytes in pad2, starting at pad2[1]
60+ set_731(&boot_desc_entry->pad2[1], extra_nsectors);
61+
62+ }
63+
64 set_721(boot_desc_entry->nsect, (unsigned int) nsectors);
65 set_731(boot_desc_entry->bootoff,
66 (unsigned int) get_733(de->isorec.extent));
67--
682.44.1
69