Add support for ISO9660 image compatible with Legacy and EFI BIOS
v2 cover Add support for ISO9660 image compatible with Legacy and EFI BIOS
This series of patches aims to support the generation of an ISO9660 hybrid image compatible with Legacy BIOS and EFI BIOS. To implement this, we need to improve the grub2 package and modify the ISO9660 image support
Grub2 was written to build only one configuration at a time. For the hybrid image we need to have several configuration of Grub2 in the same image. For example we might want to have Grub2 built for BIOS, EFI 32 bits and EFI 64 bits in the same image. To support this, we chose to fill a list of configuration name tuples, and then build each Grub2 configuration in a separate build-$(tuple) folder. It seems simpler than having multiple duplicated grub2 packages for each possible configuration.
The generation of ISO9660 image was only supporting bootloaders based on Legacy BIOS boot. We first change the ISO9660 image generation to use xorriso instead of genimageiso, in order to be able to build an image compatible with both legacy and EFI BIOS. Then we add the generation of an EFI System Partition in iso9660 so that we can install the EFI-compatible bootloader."
In detail:
- PATCH 1 implements simultaneous build of GRUB for different configurations
- PATCH 2 implements the generation of ISO9660 image booting on a EFI BIOS
- PATCH 3 implements the generation of hybrid image compatible with Legacy and EFI BIOS
- PATCH 4 updates the encoding of the text return from testing emulator
- PATCH 5 add support to i386 architecture to edk2 package
- PATCH 6 updates iso9660 tests and implements a test for EFI image and hybrid image.
Changes in v2:
- Update the typo of Grub2 configuration tuples to make more legible code
- Expand explanation in few commit messages.
- Fix typos.
- Fix Grub2 Legacy builtin configurations.
- Add mkfs and mcopy parameters in iso9660 package to build reproducible images.
- Remove the implementation of host-efi-bios package.
- Add support for i386 architecture to edk2 package.
Thanks in advance for your review and feedback
Kory Maincent (6):
boot/grub2: add support to build multiple Grub2 configurations in the
same build
fs/iso9660: add support to Grub EFI bootloader in the image fs/iso9660: add support for hybrid image using Grub bootloader on BIOS
and EFI
support/testing/infra/emulator.py: update encoding when calling qemu boot/edk2: add support to i386 architecture support/testing/tests/fs/test_iso9660.py: add support to test using
EFI BIOS
Config.in.legacy | 24 ++++ boot/edk2/Config.in | 12 +- boot/edk2/edk2.mk | 12 +- boot/grub2/Config.in | 53 ++++++-- boot/grub2/grub2.mk | 165 +++++++++++++---------- fs/iso9660/Config.in | 30 ++++- fs/iso9660/iso9660.mk | 60 ++++++++- support/testing/conf/grub2-efi.cfg | 2 + support/testing/infra/emulator.py | 2 +- support/testing/tests/fs/test_iso9660.py | 80 ++++++++++- 10 files changed, 337 insertions(+), 103 deletions(-) create mode 100644 support/testing/conf/grub2-efi.cfg
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/6 boot/grub2: add support to build multiple Grub2 configurations in the same build
When Grub2 is build it is configured only for one boot set-up, BIOS Legacy, EFI 32 bit or EFI 64 bit. It can not deal with several boot set-up on the same image.
This patch allows to build Grub2 for different configurations simultaneously. To cover Grub2 configuration of legacy BIOS platforms (32-bit), 32-bit EFI BIOS and 64-bit EFI BIOS in the same build, multi-build system felt much more reasonable to just extend the grub2 package into 3 packages.
We can no longer use autotools-package as a consequence of this multi-build, and we have to resort to generic-package and a partial duplication of the autotools-infra. Grub2 was already using custom option like --prefix or --exec-prefix so this won't add much more weirdness.
We use a GRUB2_TUPLES list to describe all the configurations selected. For each boot case described in the GRUB2_TUPLES list, it configures and builds Grub2 in a separate folder named build-$(tuple).
We use a foreach loop to make actions on each tuple selected.
We have to separate the BR2_TARGET_GRUB2_BUILTIN_MODULES and the BR2_TARGET_GRUB2_BUILTIN_CONFIG for each BIOS or EFI boot cases.
---
Changes in v2:
Following the review from Yann E. Morin:
- Update the tuples configurations to makes the code more readable.
- Move "--target" and "--with-platform" parameters into the GRUB2_CONFIGURE_CMD.
- Fix startup.nsh installation.
- Fix Grub2 configuration to be sure that at least one platform is always enabled.
- Fix legacy builtin configurations to string in place of bool.
Config.in.legacy | 24 ++++ boot/grub2/Config.in | 53 ++++++-- boot/grub2/grub2.mk | 165 +++++++++++++---------- support/testing/tests/fs/test_iso9660.py | 6 +- 4 files changed, 164 insertions(+), 84 deletions(-)
Config.in.legacy +24 -0
@@ -168,6 +168,30 @@ config BR2_KERNEL_HEADERS_5_12 comment "Legacy options removed in 2021.08" +config BR2_TARGET_GRUB2_BUILTIN_MODULES + string "the grub2 builtin modules has been renamed" + help + This option has been split to separate the builtin modules + between BR2_TARGET_GRUB2_BUILTIN_MODULES_PC and + BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI. + +config BR2_TARGET_GRUB2_BUILTIN_MODULES_WRAP + bool + default y if BR2_TARGET_GRUB2_BUILTIN_MODULES != "" + select BR2_LEGACY + +config BR2_TARGET_GRUB2_BUILTIN_CONFIG + string "the grub2 builtin configuration has been renamed" + help + This option has been split to separate the builtin configuration + between BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC and + BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI. + +config BR2_TARGET_GRUB2_BUILTIN_CONFIG_WRAP + bool + default y if BR2_TARGET_GRUB2_BUILTIN_CONFIG != "" + select BR2_LEGACY + config BR2_PACKAGE_LIBMCRYPT bool "libmcrypt package was removed" select BR2_LEGACY
boot/grub2/Config.in +41 -12
109 lines not on this page · raw message
boot/grub2/grub2.mk +96 -69
190 lines not on this page · raw message
support/testing/tests/fs/test_iso9660.py +3 -3
@@ -54,7 +54,7 @@ class TestIso9660Grub2External(infra.basetest.BRTest): # BR2_TARGET_ROOTFS_ISO9660_INITRD is not set BR2_TARGET_GRUB2=y BR2_TARGET_GRUB2_BOOT_PARTITION="cd" - BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660" + BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660" BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}" """.format(infra.filepath("conf/grub2.cfg"))
@@ -75,7 +75,7 @@ class TestIso9660Grub2ExternalCompress(infra.basetest.BRTest): BR2_TARGET_ROOTFS_ISO9660_TRANSPARENT_COMPRESSION=y BR2_TARGET_GRUB2=y BR2_TARGET_GRUB2_BOOT_PARTITION="cd" - BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660" + BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660" BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}" """.format(infra.filepath("conf/grub2.cfg"))
@@ -95,7 +95,7 @@ class TestIso9660Grub2Internal(infra.basetest.BRTest): BR2_TARGET_ROOTFS_ISO9660_INITRD=y BR2_TARGET_GRUB2=y BR2_TARGET_GRUB2_BOOT_PARTITION="cd" - BR2_TARGET_GRUB2_BUILTIN_MODULES="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660" + BR2_TARGET_GRUB2_BUILTIN_MODULES_PC="boot linux ext2 fat part_msdos part_gpt normal biosdisk iso9660" BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU="{}" """.format(infra.filepath("conf/grub2.cfg"))
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/6] boot/grub2: add support to build multiple Grub2 configurations in the same build
Köry, All,
On 2021-09-21 15:28 +0200, Kory Maincent spake thusly:
Quoted 19 lines
When Grub2 is build it is configured only for one boot set-up, BIOS Legacy, EFI 32 bit or EFI 64 bit. It can not deal with several boot set-up on the same image.
This patch allows to build Grub2 for different configurations simultaneously. To cover Grub2 configuration of legacy BIOS platforms (32-bit), 32-bit EFI BIOS and 64-bit EFI BIOS in the same build, multi-build system felt much more reasonable to just extend the grub2 package into 3 packages.
We can no longer use autotools-package as a consequence of this multi-build, and we have to resort to generic-package and a partial duplication of the autotools-infra. Grub2 was already using custom option like --prefix or --exec-prefix so this won't add much more weirdness.
We use a
GRUB2_TUPLESlist to describe all the configurations selected. For each boot case described in theGRUB2_TUPLESlist, it configures and builds Grub2 in a separate folder named build-$(tuple).
We use a foreach loop to make actions on each tuple selected.
Quoted 5 lines
We have to separate the
BR2_TARGET_GRUB2_BUILTIN_MODULESand theBR2_TARGET_GRUB2_BUILTIN_CONFIGfor each BIOS or EFI boot cases.Signed-off-by Kory Maincent <[email protected]>---
[--SNIP--]
boot/grub2/Config.in config BR2_TARGET_GRUB2
Quoted 5 lines
boot/grub2/Config.in +0
-0@@ -10,6 +10,13 @@ config BR2_TARGET_GRUB2
[--SNIP--]
Except for very minor formatting issues (mostly, jsut because it hurts my eyes...), Config.in looks OK now, thanks.
Quoted 7 lines
boot/grub2/grub2.mk +0
-0@@ -57,52 +57,65 @@ GRUB2_INSTALL_TARGET = NO endif GRUB2_CPE_ID_VENDOR = gnu
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 66
Quoted 10 lines
boot/grub2/grub2.mk +4
-2-GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES)) -GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG)) +GRUB2_BUILTIN_MODULES_PC = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES_PC)) +GRUB2_BUILTIN_MODULES_EFI = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI)) +GRUB2_BUILTIN_CONFIG_PC = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC)) +GRUB2_BUILTIN_CONFIG_EFI = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI)) GRUB2_BOOT_PARTITION = $(call qstrip,$(BR2_TARGET_GRUB2_BOOT_PARTITION)) ifeq ($(BR2_TARGET_GRUB2_I386_PC),y)
[--SNIP removals--]
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 74
Quoted 8 lines
boot/grub2/grub2.mk +8
-0+GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img +GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg +GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub +GRUB2_TARGET_i386-pc = i386 +GRUB2_PLATFORM_i386-pc = pc +GRUB2_BUILTIN_i386-pc = PC +GRUB2_TUPLES += i386-pc +endif
Any reason why you have decided not to got with the construct I suggested:
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pc
and then use $(GRUB2_TUPLES-y) when iterating?
Note: this is used everywhere in the kernel tree, and we already use that construct in quite a few places, so it would not be totally new and not totally unkown either:
$ git grep -E -- '[_-]\$\([^)]+\)[[:space:]]*\+=' '*.mk'
But OK, the multi-conditions work as good if you don't like the -y stuff.
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 81
Quoted 7 lines
boot/grub2/grub2.mk +7
-0+ifeq ($(BR2_TARGET_GRUB2_I386_EFI),y) +GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi +GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX_i386-efi = /EFI/BOOT +GRUB2_TARGET_i386-efi = i386 +GRUB2_PLATFORM_i386-efi = efi +GRUB2_BUILTIN_i386-efi = EFI
All those GRUB2_BUILTIN_$(tuple) variables are just so that you can do a double indeirection alter on, which is highly unreadable.
What about assigning the options directly:
GRUB2_CONFIG_i386-pc = $(GRUB2_BUILTIN_CONFIG_PC)
GRUB2_MODULES_i386-pc = $(GRUB2_BUILTIN_MODULES_PC)
GRUB2_CONFIG_i386-efi = $(GRUB2_BUILTIN_CONFIG_EFI)
GRUB2_MODULES_i386-efi = $(GRUB2_BUILTIN_MODULES_EFI)[...] and so on [...]
[--SNIP--]
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 99
Quoted 7 lines
boot/grub2/grub2.mk +7
-0+ifeq ($(BR2_TARGET_GRUB2_ARM_UBOOT),y) +GRUB2_IMAGE_arm-uboot = $(BINARIES_DIR)/boot-part/grub/grub.img +GRUB2_CFG_arm-uboot = $(BINARIES_DIR)/boot-part/grub/grub.cfg +GRUB2_PREFIX_arm-uboot = ($(GRUB2_BOOT_PARTITION))/boot/grub +GRUB2_TARGET_arm-uboot = arm +GRUB2_PLATFORM_arm-uboot = uboot +GRUB2_BUILTIN_arm-uboot = PC
[...] even for this sole outlier:
GRUB2_CONFIG_arm-uboot = $(GRUB2_BUILTIN_CONFIG_PC)
GRUB2_MODULES_arm-uboot = $(GRUB2_BUILTIN_MODULES_PC)(and where we see that the _PC suffix is not necessarily appropriate. but naming is really hard...)
[--SNIP--]
Quoted 12 lines
boot/grub2/grub2.mk +2
-2@@ -128,8 +141,8 @@ GRUB2_CONF_ENV = \ TARGET_STRIP="$(TARGET_CROSS)strip" GRUB2_CONF_OPTS = \ - --target=$(GRUB2_TARGET) \ - --with-platform=$(GRUB2_PLATFORM) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \ --prefix=/ \ --exec-prefix=/ \ --disable-grub-mkfont \
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 161
Quoted 2 lines
boot/grub2/grub2.mk +0
-0@@ -147,34 +160,48 @@ HOST_GRUB2_CONF_OPTS = \ --enable-libzfs=no \ --disable-werror
As Thomas previously suggested, I think we can just drop GRUB2_CONF_OPTS and just put the options, even shared , directly in the loop [...]
Quoted 5 lines
boot/grub2/grub2.mk +1
-4-ifeq ($(BR2_TARGET_GRUB2_I386_PC),y) -define GRUB2_IMAGE_INSTALL_ELTORITO - cat $(HOST_DIR)/lib/grub/$(GRUB2_TUPLE)/cdboot.img $(GRUB2_IMAGE) > \ - $(BINARIES_DIR)/grub-eltorito.img +define GRUB2_CONFIGURE_CMDS
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 173
Quoted 10 lines
boot/grub2/grub2.mk +10
-0+ $(foreach tuple, $(GRUB2_TUPLES), \ + mkdir -p $(@D)/build-$(tuple) ; \ + cd $(@D)/build-$(tuple) ; \ + $(TARGET_CONFIGURE_OPTS) \ + $(TARGET_CONFIGURE_ARGS) \ + $(GRUB2_CONF_ENV) \ + ../configure \ + --target=$(GRUB2_TARGET_$(tuple)) \ + --with-platform=$(GRUB2_PLATFORM_$(tuple)) \ + $(GRUB2_CONF_OPTS)
[...] here.
[--SNIP--]
Quoted 11 lines
boot/grub2/grub2.mk +5
-4+define GRUB2_BUILD_CMDS + $(foreach tuple, $(GRUB2_TUPLES), \ + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple) + ) endef -ifeq ($(GRUB2_PLATFORM),efi) -define GRUB2_EFI_STARTUP_NSH - echo $(notdir $(GRUB2_IMAGE)) > \ - $(BINARIES_DIR)/efi-part/startup.nsh +define GRUB2_INSTALL_IMAGES_CMDS
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 193
Quoted 10 lines
boot/grub2/grub2.mk +10
-0+ $(foreach tuple, $(GRUB2_TUPLES), \ + mkdir -p $(dir $(GRUB2_IMAGE_$(tuple))) ; \ + $(HOST_DIR)/usr/bin/grub-mkimage \ + -d $(@D)/build-$(tuple)/grub-core/ \ + -O $(tuple) \ + -o $(GRUB2_IMAGE_$(tuple)) \ + -p "$(GRUB2_PREFIX_$(tuple))" \ + $(if $(GRUB2_BUILTIN_CONFIG_$(GRUB2_BUILTIN_$(tuple))), \ + -c $(GRUB2_BUILTIN_CONFIG_$(GRUB2_BUILTIN_$(tuple)))) \ + $(GRUB2_BUILTIN_MODULES_$(GRUB2_BUILTIN_$(tuple))) ; \
Those double indirections are really tricky to read, and I think we can pretty easily get rid of them (see above).
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 201
Quoted 8 lines
boot/grub2/grub2.mk +8
-0+ $(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple)) ; \ + $(if $(findstring $(GRUB2_PLATFORM_$(tuple)), pc), \ + cat $(HOST_DIR)/lib/grub/$(tuple)/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \ + $(BINARIES_DIR)/grub-eltorito.img \ + ) \ + $(if $(findstring $(GRUB2_PLATFORM_$(tuple)), efi), \ + echo $(notdir $(GRUB2_IMAGE_$(tuple))) > \ + $(BINARIES_DIR)/efi-part/startup_$(GRUB2_TARGET_$(tuple)).nsh \
But the previous path 'efi-part/startup.nsh' is where the post-build scripts and genimage config files look for:
$ git grep -E '\.nsh'
So, by changing the place where the .nsh is stored, you are breaking those boards... Unless I missed something?
And I am not sure how to fix that, in the end... Especially the systemd case (meh).
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/6] boot/grub2: add support to build multiple Grub2 configurations in the same build
Quoted 3 lines · Yann E. MORIN
Köry, All,
On 2021-09-21 15:28 +0200, Kory Maincent spake thusly:
[snip]
Quoted 13 lines
Quoted 1 line
ifeq ($(BR2_TARGET_GRUB2_I386_PC),y)[--SNIP removals--]
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 74
Quoted 8 lines
boot/grub2/grub2.mk +8
-0+GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img +GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg +GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub +GRUB2_TARGET_i386-pc = i386 +GRUB2_PLATFORM_i386-pc = pc +GRUB2_BUILTIN_i386-pc = PC +GRUB2_TUPLES += i386-pc +endifAny reason why you have decided not to got with the construct I suggested:
Quoted 3 lines
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pcand then use $(GRUB2_TUPLES-y) when iterating?
Well, it's a bigger diff compared to what you have now. Especially because you
have to keep the GRUB2_IMAGE_i386-pc etc. part, it's only TUPLES that you can use like that.
Also, I think the -y approach is good only when you have may options (because
it is slightly more difficult to parse) - we have 5 options here, which is a bit borderline.
However, this approach becomes a lot more attractive if we eliminate the
conditions:
GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub GRUB2_TARGET_i386-pc = i386 GRUB2_PLATFORM_i386-pc = pc
GRUB2_BUILTIN_i386-pc = PC GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pc
GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg GRUB2_PREFIX_i386-efi = /EFI/BOOT
GRUB2_TARGET_i386-efi = i386
GRUB2_PLATFORM_i386-efi = efi
GRUB2_BUILTIN_i386-efi = EFI GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_EFI) += i386-efi
Quoted 21 lines
Note: this is used everywhere in the kernel tree, and we already use that construct in quite a few places, so it would not be totally new and not totally unkown either:
$ git grep -E -- '[_-]\$\([^)]+\)[[:space:]]*\+=' '*.mk'But OK, the multi-conditions work as good if you don't like the -y stuff.
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 81
Quoted 7 lines
boot/grub2/grub2.mk +7
-0+ifeq ($(BR2_TARGET_GRUB2_I386_EFI),y) +GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi +GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX_i386-efi = /EFI/BOOT +GRUB2_TARGET_i386-efi = i386 +GRUB2_PLATFORM_i386-efi = efi +GRUB2_BUILTIN_i386-efi = EFIAll those GRUB2_BUILTIN_$(tuple) variables are just so that you can do a double indeirection alter on, which is highly unreadable.
Quoted 6 lines
What about assigning the options directly:
GRUB2_CONFIG_i386-pc = $(GRUB2_BUILTIN_CONFIG_PC) GRUB2_MODULES_i386-pc = $(GRUB2_BUILTIN_MODULES_PC) GRUB2_CONFIG_i386-efi = $(GRUB2_BUILTIN_CONFIG_EFI) GRUB2_MODULES_i386-efi = $(GRUB2_BUILTIN_MODULES_EFI)
Still feels over-complicated, but I can't think of anything better. But it's
definitely an improvement over the BUILTIN_$(tuple).
Regards,
Arnout
[snip]
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/6] boot/grub2: add support to build multiple Grub2 configurations in the same build
Arnout, All,
On 2021-09-21 19:20 +0200, Arnout Vandecappelle spake thusly:
Quoted 24 lines · Yann E. MORIN
Quoted 1 line
On 2021-09-21 15:28 +0200, Kory Maincent spake thusly:
[snip]
Quoted 13 lines
Quoted 1 line
ifeq ($(BR2_TARGET_GRUB2_I386_PC),y)
[--SNIP removals--]
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 74
Quoted 8 lines
boot/grub2/grub2.mk +8
-0+GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img +GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg +GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub +GRUB2_TARGET_i386-pc = i386 +GRUB2_PLATFORM_i386-pc = pc +GRUB2_BUILTIN_i386-pc = PC +GRUB2_TUPLES += i386-pc +endifAny reason why you have decided not to got with the construct I suggested:
Quoted 3 lines
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pcand then use $(GRUB2_TUPLES-y) when iterating?
Well, it's a bigger diff compared to what you have now. Especially because
you have to keep the GRUB2_IMAGE_i386-pc etc. part, it's only TUPLES that you can use like that.
Quoted 6 lines
Also, I think the -y approach is good only when you have may options
(because it is slightly more difficult to parse) - we have 5 options here, which is a bit borderline.However, this approach becomes a lot more attractive if we eliminate the
conditions:
Of course! I should have stated that explicitly, but in my mind it was obvious that the conditions would disapear, and that'd we'd keep only the -y assignments.
Quoted 8 lines
GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub GRUB2_TARGET_i386-pc = i386 GRUB2_PLATFORM_i386-pc = pc
GRUB2_BUILTIN_i386-pc = PC GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pc
Quoted 7 lines
GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg GRUB2_PREFIX_i386-efi = /EFI/BOOT
GRUB2_TARGET_i386-efi = i386
GRUB2_PLATFORM_i386-efi = efi
GRUB2_BUILTIN_i386-efi = EFI GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_EFI) += i386-efi
Exactly!
Quoted 22 lines
Quoted 22 lines
Note: this is used everywhere in the kernel tree, and we already use that construct in quite a few places, so it would not be totally new and not totally unkown either:
$ git grep -E -- '[_-]\$\([^)]+\)[[:space:]]*\+=' '*.mk'But OK, the multi-conditions work as good if you don't like the -y stuff.
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 81
Quoted 7 lines
boot/grub2/grub2.mk +7
-0+ifeq ($(BR2_TARGET_GRUB2_I386_EFI),y) +GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi +GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX_i386-efi = /EFI/BOOT +GRUB2_TARGET_i386-efi = i386 +GRUB2_PLATFORM_i386-efi = efi +GRUB2_BUILTIN_i386-efi = EFIAll those GRUB2_BUILTIN_$(tuple) variables are just so that you can do a double indeirection alter on, which is highly unreadable.
What about assigning the options directly:
Quoted 7 lines
Quoted 4 lines
GRUB2_CONFIG_i386-pc = $(GRUB2_BUILTIN_CONFIG_PC) GRUB2_MODULES_i386-pc = $(GRUB2_BUILTIN_MODULES_PC) GRUB2_CONFIG_i386-efi = $(GRUB2_BUILTIN_CONFIG_EFI) GRUB2_MODULES_i386-efi = $(GRUB2_BUILTIN_MODULES_EFI)Still feels over-complicated, but I can't think of anything better. But
it's definitely an improvement over the BUILTIN_$(tuple).
Agreed, it's not a panacea, but it's still more legible.
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/6] boot/grub2: add support to build multiple Grub2 configurations in the same build
In reply to Yann E. MORINHello Yann,
Thanks for the two reviews.
Quoted 27 lines · On Tue, 21 Sep 2021 18:37:27 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 11 lines
boot/grub2/grub2.mk +1
-2-GRUB2_BUILTIN_MODULES = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES)) -GRUB2_BUILTIN_CONFIG = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG)) +GRUB2_BUILTIN_MODULES_PC = $(callqstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES_PC)) +GRUB2_BUILTIN_MODULES_EFI = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI)) +GRUB2_BUILTIN_CONFIG_PC = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG_PC)) +GRUB2_BUILTIN_CONFIG_EFI = $(call qstrip,$(BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI))
GRUB2_BOOT_PARTITION= $(call qstrip,$(BR2_TARGET_GRUB2_BOOT_PARTITION)) ifeq ($(BR2_TARGET_GRUB2_I386_PC),y)[--SNIP removals--]
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 74
Quoted 8 lines
boot/grub2/grub2.mk +8
-0+GRUB2_IMAGE_i386-pc = $(BINARIES_DIR)/grub.img +GRUB2_CFG_i386-pc = $(TARGET_DIR)/boot/grub/grub.cfg +GRUB2_PREFIX_i386-pc = ($(GRUB2_BOOT_PARTITION))/boot/grub +GRUB2_TARGET_i386-pc = i386 +GRUB2_PLATFORM_i386-pc = pc +GRUB2_BUILTIN_i386-pc = PC +GRUB2_TUPLES += i386-pc +endifAny reason why you have decided not to got with the construct I suggested:
GRUB2_TUPLES-$(BR2_TARGET_GRUB2_I386_PC) += i386-pcand then use $(GRUB2_TUPLES-y) when iterating?
Quoted 8 lines
Note: this is used everywhere in the kernel tree, and we already use that construct in quite a few places, so it would not be totally new and not totally unkown either:
$ git grep -E -- '[_-]\$\([^)]+\)[[:space:]]*\+=' '*.mk'But OK, the multi-conditions work as good if you don't like the -y stuff.
Oh sorry, I have forgotten that part.
It seems better indeed, I will do that in v3.
Quoted 32 lines
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 81
Quoted 8 lines
boot/grub2/grub2.mk +7
-0+ifeq ($(BR2_TARGET_GRUB2_I386_EFI),y) +GRUB2_IMAGE_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/bootia32.efi +GRUB2_CFG_i386-efi = $(BINARIES_DIR)/efi-part/EFI/BOOT/grub.cfg +GRUB2_PREFIX_i386-efi = /EFI/BOOT +GRUB2_TARGET_i386-efi = i386 +GRUB2_PLATFORM_i386-efi = efi +GRUB2_BUILTIN_i386-efi = EFIAll those GRUB2_BUILTIN_$(tuple) variables are just so that you can do a double indeirection alter on, which is highly unreadable.
What about assigning the options directly:
GRUB2_CONFIG_i386-pc = $(GRUB2_BUILTIN_CONFIG_PC) GRUB2_MODULES_i386-pc = $(GRUB2_BUILTIN_MODULES_PC) GRUB2_CONFIG_i386-efi = $(GRUB2_BUILTIN_CONFIG_EFI) GRUB2_MODULES_i386-efi = $(GRUB2_BUILTIN_MODULES_EFI)[...] and so on [...]
[--SNIP--]
boot/grub2/grub2.mk GRUB2_INSTALL_TARGET = NO · line 99
Quoted 7 lines
boot/grub2/grub2.mk +7
-0+ifeq ($(BR2_TARGET_GRUB2_ARM_UBOOT),y) +GRUB2_IMAGE_arm-uboot = $(BINARIES_DIR)/boot-part/grub/grub.img +GRUB2_CFG_arm-uboot = $(BINARIES_DIR)/boot-part/grub/grub.cfg +GRUB2_PREFIX_arm-uboot = ($(GRUB2_BOOT_PARTITION))/boot/grub +GRUB2_TARGET_arm-uboot = arm +GRUB2_PLATFORM_arm-uboot = uboot +GRUB2_BUILTIN_arm-uboot = PC[...] even for this sole outlier:
Quoted 5 lines
GRUB2_CONFIG_arm-uboot = $(GRUB2_BUILTIN_CONFIG_PC) GRUB2_MODULES_arm-uboot = $(GRUB2_BUILTIN_MODULES_PC)(and where we see that the
_PCsuffix is not necessarily appropriate. but naming is really hard...)
True, I did not thought of that solution.
Quoted 5 lines
[--SNIP--]
Quoted 3 lines
boot/grub2/grub2.mk +0
-0@@ -128,8 +141,8 @@ GRUB2_CONF_ENV = \ TARGET_STRIP="$(TARGET_CROSS)strip"
Quoted 14 lines
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 161
Quoted 11 lines
boot/grub2/grub2.mk +2
-2GRUB2_CONF_OPTS = \ - --target=$(GRUB2_TARGET) \ - --with-platform=$(GRUB2_PLATFORM) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \ --prefix=/ \ --exec-prefix=/ \ --disable-grub-mkfont \@@ -147,34 +160,48 @@ HOST_GRUB2_CONF_OPTS = \ --enable-libzfs=no \ --disable-werrorAs Thomas previously suggested, I think we can just drop
GRUB2_CONF_OPTSand just put the options, even shared , directly in the loop [...]
His suggestion was to only keep out of GRUB2_CONF_OPTS the two parameterized options "--target" and "--with-platform". If you prefer to drop all the options from GRUB2_CONF_OPTS, I can do that.
Quoted 16 lines
Review HOST_GRUB2_CONF_OPTS = \ · line 172
Quoted 12 lines
(quoted diff) +8
-0+ $(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple)) ; \ + $(if $(findstring $(GRUB2_PLATFORM_$(tuple)), pc), \ + cat $(HOST_DIR)/lib/grub/$(tuple)/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \ + $(BINARIES_DIR)/grub-eltorito.img \ + ) \ + $(if $(findstring $(GRUB2_PLATFORM_$(tuple)), efi), \ + echo $(notdir $(GRUB2_IMAGE_$(tuple))) > \ + $(BINARIES_DIR)/efi-part/startup_$(GRUB2_TARGET_$(tuple)).nsh \But the previous path 'efi-part/startup.nsh' is where the post-build scripts and genimage config files look for:
Quoted 4 lines
$ git grep -E '\.nsh'So, by changing the place where the .nsh is stored, you are breaking those boards... Unless I missed something?
Yes, indeed it will break few post-build script.
By default the EFI will look at efi/boot/bootx64.efi or efi/boot/bootia32.efi if the startup.nsh file is not present. So board should boot without that file.
Quoted 3 lines
And I am not sure how to fix that, in the end... Especially the systemd case (meh).
Me neither. Maybe we can let it like v1, and the 64-bit EFI configuration will be the one used if both 32-bit EFI and 64-bit EFI are selected.
Regards,
Köry
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/6] boot/grub2: add support to build multiple Grub2 configurations in the same build
Köry, All,
On 2021-09-21 19:49 +0200, Köry Maincent spake thusly:
Quoted 2 lines
On Tue, 21 Sep 2021 18:37:27 +0200
"Yann E. MORIN" <[email protected]> wrote:
[--SNIP--]
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
GRUB2_CONF_OPTS= \boot/grub2/grub2.mk +2
-2- --target=$(GRUB2_TARGET) \ - --with-platform=$(GRUB2_PLATFORM) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \Quoted 8 lines
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 161
Quoted 6 lines
boot/grub2/grub2.mk +0
-0--prefix=/ \ --exec-prefix=/ \ --disable-grub-mkfont \@@ -147,34 +160,48 @@ HOST_GRUB2_CONF_OPTS = \ --enable-libzfs=no \ --disable-werrorAs Thomas previously suggested, I think we can just drop
GRUB2_CONF_OPTSand just put the options, even shared , directly in the loop [...]
Quoted 3 lines
His suggestion was to only keep out of
GRUB2_CONF_OPTSthe two parameterized options "--target" and "--with-platform". If you prefer to drop all the options fromGRUB2_CONF_OPTS, I can do that.
Ah, right, I misread what he wrote. But once we move some options out of GRUB2_CONF_OPTS, and since it is used in a single place, does it make sense to keep it now that we no longer are an autotools-package?
Quoted 15 lines
Quoted 15 lines
Review HOST_GRUB2_CONF_OPTS = \ · line 172
Quoted 11 lines
(quoted diff) +8
-0+ $(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG_$(tuple)) ; \ + $(if $(findstring $(GRUB2_PLATFORM_$(tuple)), pc), \ + cat $(HOST_DIR)/lib/grub/$(tuple)/cdboot.img $(GRUB2_IMAGE_$(tuple)) > \ + $(BINARIES_DIR)/grub-eltorito.img \ + ) \ + $(if $(findstring $(GRUB2_PLATFORM_$(tuple)), efi), \ + echo $(notdir $(GRUB2_IMAGE_$(tuple))) > \ + $(BINARIES_DIR)/efi-part/startup_$(GRUB2_TARGET_$(tuple)).nsh \But the previous path 'efi-part/startup.nsh' is where the post-build scripts and genimage config files look for:
Quoted 6 lines
Quoted 4 lines
$ git grep -E '\.nsh'So, by changing the place where the .nsh is stored, you are breaking those boards... Unless I missed something?
Yes, indeed it will break few post-build script.
Then those that are broken must be fixed.
Quoted 2 lines
By default the EFI will look at efi/boot/bootx64.efi or efi/boot/bootia32.efi if the startup.nsh file is not present. So board should boot without that file.
But then, is startup_{i386,x86_64,arm,aarch64}.nsh even consulted?
As I understand it, and without access to the UEFI specifications, it looks like startup.nsh is the only file to be read by a (compliant?) UEFI bios.
Quoted 4 lines
Quoted 2 lines
And I am not sure how to fix that, in the end... Especially the systemd case (meh).
Me neither. Maybe we can let it like v1, and the 64-bit EFI configuration will be the one used if both 32-bit EFI and 64-bit EFI are selected.
Well, the ultimate goal is to haev a single USB-stick or CDROM that can boot on all three systems:
- legacy BIOS
- 32-bit UEFI
- 64-bit UEFI
So, if the startup.nsh script is to be provided, it should cover the two UEFI cases. A 32-bit UEFI bios can't load a 64-bit payload, and conversely, a 65-bit UEFI bios can't load a 32-bit payload.
So, if startup.nsh is mandatory, we have an impossible situation...
So, I wonder if startup.nsh is even needed at all, and if we should not just drop it altogether, and just rely, s you explained earlier, on the actual naming of the payload: efi/boot/bootia32.efi on 32-bit UEFI, or efi/boot/bootx64.efi on 64-bit UEFI.
And drop the creation of startup.nsh in gummiboot and systemd.
And fixup the post-build scripts accordingly...
But as I said earlier: I do not have access to the UEFI specifications (they are free-as-in-beer to download and read, not implement or use, so by downloading them, I would have to stop reviewing this series as that would count as a use of the specs...)
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 1/6] boot/grub2: add support to build multiple Grub2 configurations in the same build
Hello Yann,
Quoted 13 lines · On Tue, 21 Sep 2021 21:41:05 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 13 lines
Quoted 13 lines
boot/grub2/grub2.mk HOST_GRUB2_CONF_OPTS = \ · line 161
Quoted 11 lines
GRUB2_CONF_OPTS= \boot/grub2/grub2.mk +2
-2- --target=$(GRUB2_TARGET) \ - --with-platform=$(GRUB2_PLATFORM) \ + --host=$(GNU_TARGET_NAME) \ + --build=$(GNU_HOST_NAME) \ --prefix=/ \ --exec-prefix=/ \ --disable-grub-mkfont \@@ -147,34 +160,48 @@ HOST_GRUB2_CONF_OPTS = \ --enable-libzfs=no \ --disable-werrorAs Thomas previously suggested, I think we can just drop
GRUB2_CONF_OPTSand just put the options, even shared , directly in the loop [...]
Quoted 7 lines
Quoted 3 lines
His suggestion was to only keep out of
GRUB2_CONF_OPTSthe two parameterized options "--target" and "--with-platform". If you prefer to drop all the options fromGRUB2_CONF_OPTS, I can do that.Ah, right, I misread what he wrote. But once we move some options out of
GRUB2_CONF_OPTS, and since it is used in a single place, does it make sense to keep it now that we no longer are an autotools-package?
Alright
Quoted 22 lines
Quoted 4 lines
Quoted 2 lines
And I am not sure how to fix that, in the end... Especially the systemd case (meh).
Me neither. Maybe we can let it like v1, and the 64-bit EFI configuration will be the one used if both 32-bit EFI and 64-bit EFI are selected.
Well, the ultimate goal is to haev a single USB-stick or CDROM that can boot on all three systems:
- legacy BIOS
- 32-bit UEFI
- 64-bit UEFISo, if the startup.nsh script is to be provided, it should cover the two UEFI cases. A 32-bit UEFI bios can't load a 64-bit payload, and conversely, a 65-bit UEFI bios can't load a 32-bit payload.
So, if startup.nsh is mandatory, we have an impossible situation...
So, I wonder if startup.nsh is even needed at all, and if we should not just drop it altogether, and just rely, s you explained earlier, on the actual naming of the payload: efi/boot/bootia32.efi on 32-bit UEFI, or efi/boot/bootx64.efi on 64-bit UEFI.
Quoted 8 lines
And drop the creation of startup.nsh in gummiboot and systemd.
And fixup the post-build scripts accordingly...
But as I said earlier: I do not have access to the UEFI specifications (they are free-as-in-beer to download and read, not implement or use, so by downloading them, I would have to stop reviewing this series as that would count as a use of the specs...)
If I ask someone to read it and confirm the boot files name, is it ok as I have not opened it? ;)
Here is the file name convention that need to be install in efi/boot folder 32bit : bootia32.efi
x64 : bootx64.efi
aarch32 : bootarm.efi
aarch64 : bootaa64.efi
It seems dropping the creation of the startup.nsh is the best idea.
Regards,
Köry
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 2/6 fs/iso9660: add support to Grub EFI bootloader in the image
In reply to Kory MaincentAdd support to boot the Grub bootloader from an EFI BIOS in the ISO9660 image.
For that we need to create EFI System Partition (ESP). The ESP is a vfat partition which contain the Grub2 binary at the /EFI/BOOT/ location. xorriso command will generate the iso image including the ESP.
We notice Grub can not read and mount the ESP, therefore we place the Grub configuration file in the ISO9660 partition. A Grub2 builtin configuration need to be used to tell Grub2 to search automatically its configuration file in the ISO9660 partition. Use 'set root=(cd0)' in the configuration file passed to BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI.
---
Changes in v2:
Following the review from Yann E. Morin:
- Add parameter to mkfs and mcopy to allow reproducible builds
- Fix typos and variable multi-line assignement
fs/iso9660/Config.in | 30 ++++++++++++++++++++++++------ fs/iso9660/iso9660.mk | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 9 deletions(-)
fs/iso9660/Config.in +24 -6
@@ -3,6 +3,7 @@ config BR2_TARGET_ROOTFS_ISO9660 depends on (BR2_i386 || BR2_x86_64) depends on BR2_LINUX_KERNEL depends on BR2_TARGET_GRUB2_I386_PC || \ + BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI || \ BR2_TARGET_SYSLINUX_ISOLINUX select BR2_LINUX_KERNEL_INSTALL_TARGET \ if (!BR2_TARGET_ROOTFS_ISO9660_INITRD && !BR2_TARGET_ROOTFS_INITRAMFS)
@@ -27,22 +28,38 @@ choice config BR2_TARGET_ROOTFS_ISO9660_GRUB2 bool "grub2" - depends on BR2_TARGET_GRUB2_I386_PC + depends on BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_I386_EFI || \ + BR2_TARGET_GRUB2_X86_64_EFI + select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER \ + if BR2_TARGET_GRUB2_I386_PC + select BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER \ + if (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI) help Use Grub 2 as the bootloader for the ISO9660 image. Make sure to enable the 'iso9660' module in - BR2_TARGET_GRUB2_BUILTIN_MODULES and to use 'cd' as the boot - partition in BR2_TARGET_GRUB2_BOOT_PARTITION=. + BR2_TARGET_GRUB2_BUILTIN_MODULES_PC or + BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI. Use 'cd' as the boot + partition in BR2_TARGET_GRUB2_BOOT_PARTITION= for GRUB on BIOS + or 'set root=(cd0)' in the configuration file passed to + BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI for GRUB on EFI. config BR2_TARGET_ROOTFS_ISO9660_ISOLINUX bool "isolinux" depends on BR2_TARGET_SYSLINUX_ISOLINUX + select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER endchoice +config BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER + bool + +config BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER + bool + config BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU string "Boot menu config file" - default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2 + default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2_PC || \ + BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI default "fs/iso9660/isolinux.cfg" if BR2_TARGET_ROOTFS_ISO9660_ISOLINUX help Use this option to provide a custom bootloader configuration
@@ -83,7 +100,8 @@ config BR2_TARGET_ROOTFS_ISO9660_HYBRID endif -comment "iso image needs a Linux kernel and either grub2 i386-pc or isolinux to be built" +comment "iso image needs a Linux kernel and either grub2 or isolinux to be built" depends on BR2_i386 || BR2_x86_64 depends on !BR2_LINUX_KERNEL || \ - !(BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_SYSLINUX_ISOLINUX) + !(BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_I386_EFI || \ + BR2_TARGET_GRUB2_X86_64_EFI || BR2_TARGET_SYSLINUX_ISOLINUX)
fs/iso9660/iso9660.mk +35 -3
@@ -57,7 +57,11 @@ else ROOTFS_ISO9660_TMP_TARGET_DIR = $(TARGET_DIR) endif -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2),y) +ifeq ($(BR2_REPRODUCIBLE),y) +ROOTFS_ISO9660_MKFS_OPTS = --invariant +endif + +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),yy) ROOTFS_ISO9660_DEPENDENCIES += grub2 ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg
@@ -66,6 +70,21 @@ define ROOTFS_ISO9660_INSTALL_BOOTLOADER $(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img endef +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy) +ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools +ROOTFS_ISO9660_EFI_PARTITION = boot/fat.efi +ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION) +ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part +ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ + $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg +define ROOTFS_ISO9660_INSTALL_BOOTLOADER + rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH) + mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH)) + dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1M count=1 + $(HOST_DIR)/sbin/mkfs.vfat $(ROOTFS_ISO9660_MKFS_OPTS) $(ROOTFS_ISO9660_EFI_PARTITION_PATH) + $(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \ + $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/ +endef else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y) ROOTFS_ISO9660_DEPENDENCIES += syslinux ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
@@ -128,9 +147,22 @@ ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD endif # ROOTFS_ISO9660_USE_INITRD +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y) +ROOTFS_ISO9660_OPTS += \ + -J \ + -R \ + -boot-load-size 4 \ + -boot-info-table \ + -no-emul-boot \ + -b $(ROOTFS_ISO9660_BOOT_IMAGE) +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y) +ROOTFS_ISO9660_OPTS += \ + --efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \ + -no-emul-boot +endif + define ROOTFS_ISO9660_CMD - $(HOST_DIR)/bin/xorriso -as mkisofs -J -R -b $(ROOTFS_ISO9660_BOOT_IMAGE) \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ + $(HOST_DIR)/bin/xorriso -as mkisofs \ $(ROOTFS_ISO9660_OPTS) \ -o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR) endef
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 2/6] fs/iso9660: add support to Grub EFI bootloader in the image
Köry, All,
On 2021-09-21 15:28 +0200, Kory Maincent spake thusly:
Quoted 29 lines
Add support to boot the Grub bootloader from an EFI BIOS in the ISO9660 image.
For that we need to create EFI System Partition (ESP). The ESP is a vfat partition which contain the Grub2 binary at the /EFI/BOOT/ location. xorriso command will generate the iso image including the ESP.We notice Grub can not read and mount the ESP, therefore we place the Grub configuration file in the ISO9660 partition. A Grub2 builtin configuration need to be used to tell Grub2 to search automatically its configuration file in the ISO9660 partition. Use 'set root=(cd0)' in the configuration file passed to
BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI.Signed-off-by Kory Maincent <[email protected]>---
Changes in v2:
Following the review from Yann E. Morin:
- Add parameter to mkfs and mcopy to allow reproducible builds
- Fix typos and variable multi-line assignementfs/iso9660/Config.in | 30 ++++++++++++++++++++++++------ fs/iso9660/iso9660.mk | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 9 deletions(-)fs/iso9660/Config.in +0
-0
fs/iso9660/Config.in config BR2_TARGET_ROOTFS_ISO9660 · line 6
Quoted 4 lines
fs/iso9660/Config.in +1
-0@@ -3,6 +3,7 @@ config BR2_TARGET_ROOTFS_ISO9660 depends on (BR2_i386 || BR2_x86_64) depends on BR2_LINUX_KERNEL depends on BR2_TARGET_GRUB2_I386_PC || \ + BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI || \
iso9660 already depends on (BR2_i386 || BR2_x86_64), and thanks to the select of a default platform for i386 and x86_64, we know that at least one of the three i386-pc, i386-efi, or x86_64-efi is set, so we can simplify the condition to just:
depends on BR2_TARGET_GRUB2 || BR2_TARGET_SYSLINUX_ISOLINUX
No?
fs/iso9660/Config.in choice · line 32
Quoted 10 lines
fs/iso9660/Config.in +2
-1BR2_TARGET_SYSLINUX_ISOLINUX select BR2_LINUX_KERNEL_INSTALL_TARGET \ if (!BR2_TARGET_ROOTFS_ISO9660_INITRD && !BR2_TARGET_ROOTFS_INITRAMFS)@@ -27,22 +28,38 @@ choice config BR2_TARGET_ROOTFS_ISO9660_GRUB2 bool "grub2" - depends on BR2_TARGET_GRUB2_I386_PC + depends on BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_I386_EFI || \ + BR2_TARGET_GRUB2_X86_64_EFI
Similarly here, the condition can be simplified to just:
depends on BR2_TARGET_GRUB2
Quoted 23 lines
fs/iso9660/Config.in +11
-2+ select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER \ + if BR2_TARGET_GRUB2_I386_PC + select BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER \ + if (BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI) help Use Grub 2 as the bootloader for the ISO9660 image. Make sure to enable the 'iso9660' module in - BR2_TARGET_GRUB2_BUILTIN_MODULES and to use 'cd' as the boot - partition in BR2_TARGET_GRUB2_BOOT_PARTITION=. + BR2_TARGET_GRUB2_BUILTIN_MODULES_PC or + BR2_TARGET_GRUB2_BUILTIN_MODULES_EFI. Use 'cd' as the boot + partition in BR2_TARGET_GRUB2_BOOT_PARTITION= for GRUB on BIOS + or 'set root=(cd0)' in the configuration file passed to + BR2_TARGET_GRUB2_BUILTIN_CONFIG_EFI for GRUB on EFI. config BR2_TARGET_ROOTFS_ISO9660_ISOLINUX bool "isolinux" depends on BR2_TARGET_SYSLINUX_ISOLINUX + select BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER endchoice +config BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
fs/iso9660/Config.in choice · line 62
Quoted 10 lines
fs/iso9660/Config.in +7
-1+ bool + +config BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER + bool + config BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU string "Boot menu config file" - default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2 + default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2_PC || \ + BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI
I forgot to state so in the previous review, but I think it is more appropriate to duplicate the default for each case; that's nicer to read:
default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2_PC
default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFIHowever, BR2_TARGET_ROOTFS_ISO9660_GRUB2_PC and BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFI are defined nowhere...
Did you mean BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER or BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER by chance?
Quoted 4 lines
fs/iso9660/Config.in +0
-0default "fs/iso9660/isolinux.cfg" if BR2_TARGET_ROOTFS_ISO9660_ISOLINUX help Use this option to provide a custom bootloader configuration
fs/iso9660/Config.in config BR2_TARGET_ROOTFS_ISO9660_HYBRID · line 107
Quoted 10 lines
fs/iso9660/Config.in +3
-2@@ -83,7 +100,8 @@ config BR2_TARGET_ROOTFS_ISO9660_HYBRID endif -comment "iso image needs a Linux kernel and either grub2 i386-pc or isolinux to be built" +comment "iso image needs a Linux kernel and either grub2 or isolinux to be built" depends on BR2_i386 || BR2_x86_64 depends on !BR2_LINUX_KERNEL || \ - !(BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_SYSLINUX_ISOLINUX) + !(BR2_TARGET_GRUB2_I386_PC || BR2_TARGET_GRUB2_I386_EFI || \ + BR2_TARGET_GRUB2_X86_64_EFI || BR2_TARGET_SYSLINUX_ISOLINUX)
Ditto, the condition can be simplified, as in the comment iself:
depends on !BR2_LINUX_KERNEL || \
!(BR2_TARGET_GRUB2 || BR2_TARGET_SYSLINUX_ISOLINUX)fs/iso9660/iso9660.mk else · line 61
Quoted 11 lines
fs/iso9660/iso9660.mk +2
-1@@ -57,7 +57,11 @@ else ROOTFS_ISO9660_TMP_TARGET_DIR = $(TARGET_DIR) endif -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2),y) +ifeq ($(BR2_REPRODUCIBLE),y) +ROOTFS_ISO9660_MKFS_OPTS = --invariant
'MKFS' is ambiguous: it seems to imply it applies to the iso9660 mkfs, while in fact it applies to the vfat mkfs. So, maybe (yes, bikesheding, and naming is hard): ROOTFS_ISO9660_VFAT_OPTS ?
Quoted 14 lines
fs/iso9660/iso9660.mk +7
-0+endif + +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),yy) ROOTFS_ISO9660_DEPENDENCIES += grub2 ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg@@ -66,6 +70,21 @@ define ROOTFS_ISO9660_INSTALL_BOOTLOADER $(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img endef +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy) +ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools +ROOTFS_ISO9660_EFI_PARTITION = boot/fat.efi +ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION)
fs/iso9660/iso9660.mk define ROOTFS_ISO9660_INSTALL_BOOTLOADER · line 86
Quoted 10 lines
fs/iso9660/iso9660.mk +10
-0+ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part +ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ + $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg +define ROOTFS_ISO9660_INSTALL_BOOTLOADER + rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH) + mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH)) + dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1M count=1 + $(HOST_DIR)/sbin/mkfs.vfat $(ROOTFS_ISO9660_MKFS_OPTS) $(ROOTFS_ISO9660_EFI_PARTITION_PATH) + $(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \ + $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/
Ah, but the whole point of reproducible, and thus --invariant and -p -m, is that the generated filesystem is reproducible. Here, the VFAT fs itself is reproducible thanks to --invariant, but you copy a file with the date/time the build occurs, which by definition is not reproducible. You should touch the file to $(SOURCE_DATE_EPOCH) before copying into the vfat.
Yes, reproducibility is hard, but not as much as naming is. ;-]
Quoted 5 lines
fs/iso9660/iso9660.mk +1
-0+endef else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y) ROOTFS_ISO9660_DEPENDENCIES += syslinux ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \
fs/iso9660/iso9660.mk ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD · line 156
Quoted 10 lines
fs/iso9660/iso9660.mk +7
-0@@ -128,9 +147,22 @@ ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD endif # ROOTFS_ISO9660_USE_INITRD +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y) +ROOTFS_ISO9660_OPTS += \ + -J \ + -R \ + -boot-load-size 4 \ + -boot-info-table \ + -no-emul-boot \
--no-emul-boot is in both cases, so maybe it can be left in the constant options, in _CMDS below, no?
fs/iso9660/iso9660.mk ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD · line 158
Quoted 2 lines
fs/iso9660/iso9660.mk +2
-0+ -b $(ROOTFS_ISO9660_BOOT_IMAGE) +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)
Note that BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER and BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER are mutually exclusive, by definition, but we also know at least one will be set, also by definition.
So, the else clause can be a simple one, without the ifeq.
/methink.
fs/iso9660/iso9660.mk ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD · line 161
Quoted 3 lines
fs/iso9660/iso9660.mk +3
-0+ROOTFS_ISO9660_OPTS += \ + --efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \ + -no-emul-boot
So with an EFI bootloader, we do not need to generate an ISO with Joliet and RockRidge externsions? Or is that implied by the mere fact that it is using an efi-boot?
Regards,
Yann E. MORIN.
Quoted 12 lines
fs/iso9660/iso9660.mk +3
-2+endif + define ROOTFS_ISO9660_CMD - $(HOST_DIR)/bin/xorriso -as mkisofs -J -R -b $(ROOTFS_ISO9660_BOOT_IMAGE) \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ + $(HOST_DIR)/bin/xorriso -as mkisofs \ $(ROOTFS_ISO9660_OPTS) \ -o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR) endefSignature · 1 line
2.25.1
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 2/6] fs/iso9660: add support to Grub EFI bootloader in the image
Yann,
Quoted 14 lines · On Tue, 21 Sep 2021 17:36:09 +0200 "Yann E. MORIN" <[email protected]>…
fs/iso9660/Config.in config BR2_TARGET_ROOTFS_ISO9660 · line 7
Quoted 8 lines
fs/iso9660/Config.in +1
-0@@ -3,6 +3,7 @@ config BR2_TARGET_ROOTFS_ISO9660 depends on (BR2_i386 || BR2_x86_64) depends on BR2_LINUX_KERNEL depends on BR2_TARGET_GRUB2_I386_PC || \ + BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI || \iso9660 already depends on (
BR2_i386||BR2_x86_64), and thanks to the select of a default platform for i386 andx86_64, we know that at least one of the three i386-pc, i386-efi, or x86_64-efi is set, so we can simplify the condition to just:
Quoted 3 lines
depends on BR2_TARGET_GRUB2 || BR2_TARGET_SYSLINUX_ISOLINUXNo?
Yes, nice catch!
Quoted 12 lines
Quoted 7 lines
fs/iso9660/Config.in +1
-1config BR2_TARGET_ROOTFS_ISO9660_BOOT_MENU string "Boot menu config file" - default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2 + default "fs/iso9660/grub.cfg" if
BR2_TARGET_ROOTFS_ISO9660_GRUB2_PC|| \
+BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFII forgot to state so in the previous review, but I think it is more appropriate to duplicate the default for each case; that's nicer to read:
Quoted 8 lines
default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2_PC default "fs/iso9660/grub.cfg" if BR2_TARGET_ROOTFS_ISO9660_GRUB2_EFIHowever,
BR2_TARGET_ROOTFS_ISO9660_GRUB2_PCandBR2_TARGET_ROOTFS_ISO9660_GRUB2_EFIare defined nowhere...Did you mean
BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADERorBR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADERby chance?
meh, how does these config are still there !!
Quoted 7 lines
fs/iso9660/Config.in
Quoted 3 lines
fs/iso9660/Config.in +2
-1-ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2),y) +ifeq ($(BR2_REPRODUCIBLE),y) +ROOTFS_ISO9660_MKFS_OPTS = --invariant'MKFS' is ambiguous: it seems to imply it applies to the iso9660 mkfs, while in fact it applies to the vfat mkfs. So, maybe (yes, bikesheding, and naming is hard):
ROOTFS_ISO9660_VFAT_OPTS?
Let's go for it.
Quoted 9 lines
Quoted 9 lines
fs/iso9660/Config.in +4
-0+define ROOTFS_ISO9660_INSTALL_BOOTLOADER + rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH) + mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH)) + dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1Mcount=1
fs/iso9660/Config.in +1
-0+ $(HOST_DIR)/sbin/mkfs.vfat $(ROOTFS_ISO9660_MKFS_OPTS)$(ROOTFS_ISO9660_EFI_PARTITION_PATH)
fs/iso9660/Config.in +1
-0+ $(HOST_DIR)/bin/mcopy -p -m -i$(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \
Quoted 8 lines
fs/iso9660/Config.in
Quoted 1 line
fs/iso9660/Config.in +1
-0+ $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/Ah, but the whole point of reproducible, and thus --invariant and -p -m, is that the generated filesystem is reproducible. Here, the VFAT fs itself is reproducible thanks to --invariant, but you copy a file with the date/time the build occurs, which by definition is not reproducible. You should touch the file to $(SOURCE_DATE_EPOCH) before copying into the vfat.
Ack
Quoted 10 lines
fs/iso9660/Config.in
Quoted 7 lines
fs/iso9660/Config.in +7
-0+ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y) +ROOTFS_ISO9660_OPTS += \ + -J \ + -R \ + -boot-load-size 4 \ + -boot-info-table \ + -no-emul-boot \--no-emul-boot is in both cases, so maybe it can be left in the constant options, in
_CMDSbelow, no?
True it could. -no-emul-boot need to be set in both boot cases, if fact I have added it like that to not need to separate it in the next patch. ;) I will add it to constant options.
Quoted 10 lines
fs/iso9660/Config.in
Quoted 3 lines
fs/iso9660/Config.in +2
-0+ -b $(ROOTFS_ISO9660_BOOT_IMAGE) +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)Note that
BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADERandBR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADERare mutually exclusive, by definition, but we also know at least one will be set, also by definition.So, the else clause can be a simple one, without the ifeq.
doh! you raise a point. In fact in the current configuration they are not mutually exclusive. I need to fix that with a Kconfig menu.
Quoted 10 lines
/methink.
fs/iso9660/Config.in
Quoted 3 lines
fs/iso9660/Config.in +3
-0+ROOTFS_ISO9660_OPTS += \ + --efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \ + -no-emul-bootSo with an EFI bootloader, we do not need to generate an ISO with Joliet and RockRidge externsions? Or is that implied by the mere fact that it is using an efi-boot?
No, you are right I should add them to constant options.
Thanks,
Regards,
Köry
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v2 2/6] fs/iso9660: add support to Grub EFI bootloader in the image
Köry, All,
On 2021-09-21 20:41 +0200, Köry Maincent spake thusly:
Quoted 2 lines
On Tue, 21 Sep 2021 17:36:09 +0200
"Yann E. MORIN" <[email protected]> wrote:
[--SNIP--]
Quoted 10 lines
Quoted 7 lines
fs/iso9660/iso9660.mk ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD · line 158
Quoted 2 lines
fs/iso9660/iso9660.mk +2
-0+ -b $(ROOTFS_ISO9660_BOOT_IMAGE) +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y)Note that
BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADERandBR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADERare mutually exclusive, by definition, but we also know at least one will be set, also by definition.
So, the else clause can be a simple one, without the ifeq.doh! you raise a point. In fact in the current configuration they are not mutually exclusive. I need to fix that with a
Kconfigmenu.
Ah, right! And this patch is not (yet) about making a fully hybrid image, so you *have* to have the user choose what boot payload to use, probably something like:
choice
bool "Boot payload"
config BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER
bool "legacy bios"
depends on something I guess...
config BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER
bool "UEFI"
depends on something else I guess...
endchoice
Regards,
Yann E. MORIN.
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 3/6 fs/iso9660: add support for hybrid image using Grub bootloader on BIOS and EFI
In reply to Kory MaincentAdd support for building an hybrid ISO9660 image compatible with legacy and UEFI BIOS.
The option -eltorito-alt-boot need to be used in the xorriso command to generate the hybrid image.
---
Changes in v2:
- Fix typos
fs/iso9660/iso9660.mk | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
fs/iso9660/iso9660.mk +24 -10
@@ -66,18 +66,20 @@ ROOTFS_ISO9660_DEPENDENCIES += grub2 ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg ROOTFS_ISO9660_BOOT_IMAGE = boot/grub/grub-eltorito.img -define ROOTFS_ISO9660_INSTALL_BOOTLOADER +define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS $(INSTALL) -D -m 0644 $(BINARIES_DIR)/grub-eltorito.img \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub-eltorito.img endef -else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy) +endif + +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_GRUB2)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy) ROOTFS_ISO9660_DEPENDENCIES += grub2 host-dosfstools host-mtools ROOTFS_ISO9660_EFI_PARTITION = boot/fat.efi ROOTFS_ISO9660_EFI_PARTITION_PATH = $(ROOTFS_ISO9660_TMP_TARGET_DIR)/$(ROOTFS_ISO9660_EFI_PARTITION) ROOTFS_ISO9660_EFI_PARTITION_CONTENT = $(BINARIES_DIR)/efi-part ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/boot/grub/grub.cfg -define ROOTFS_ISO9660_INSTALL_BOOTLOADER +define ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI rm -rf $(ROOTFS_ISO9660_EFI_PARTITION_PATH) mkdir -p $(dir $(ROOTFS_ISO9660_EFI_PARTITION_PATH)) dd if=/dev/zero of=$(ROOTFS_ISO9660_EFI_PARTITION_PATH) bs=1M count=1
@@ -85,12 +87,14 @@ define ROOTFS_ISO9660_INSTALL_BOOTLOADER $(HOST_DIR)/bin/mcopy -p -m -i $(ROOTFS_ISO9660_EFI_PARTITION_PATH) -s \ $(ROOTFS_ISO9660_EFI_PARTITION_CONTENT)/* ::/ endef -else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y) +endif + +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_ISOLINUX),y) ROOTFS_ISO9660_DEPENDENCIES += syslinux ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH = \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/isolinux.cfg ROOTFS_ISO9660_BOOT_IMAGE = isolinux/isolinux.bin -define ROOTFS_ISO9660_INSTALL_BOOTLOADER +define ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS $(INSTALL) -D -m 0644 $(BINARIES_DIR)/syslinux/* \ $(ROOTFS_ISO9660_TMP_TARGET_DIR)/isolinux/ $(INSTALL) -D -m 0644 $(HOST_DIR)/share/syslinux/ldlinux.c32 \
@@ -103,7 +107,8 @@ define ROOTFS_ISO9660_PREPARATION $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH) $(SED) "s%__KERNEL_PATH__%/boot/$(LINUX_IMAGE_NAME)%" \ $(ROOTFS_ISO9660_BOOTLOADER_CONFIG_PATH) - $(ROOTFS_ISO9660_INSTALL_BOOTLOADER) + $(ROOTFS_ISO9660_INSTALL_BOOTLOADER_BIOS) + $(ROOTFS_ISO9660_INSTALL_BOOTLOADER_EFI) endef ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_PREPARATION
@@ -147,23 +152,32 @@ ROOTFS_ISO9660_PRE_GEN_HOOKS += ROOTFS_ISO9660_DISABLE_EXTERNAL_INITRD endif # ROOTFS_ISO9660_USE_INITRD -ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y) -ROOTFS_ISO9660_OPTS += \ +ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS = \ -J \ -R \ -boot-load-size 4 \ -boot-info-table \ -no-emul-boot \ -b $(ROOTFS_ISO9660_BOOT_IMAGE) -else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y) -ROOTFS_ISO9660_OPTS += \ + +ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI = \ --efi-boot $(ROOTFS_ISO9660_EFI_PARTITION) \ -no-emul-boot + +ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER)$(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),yy) +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS) +ROOTFS_ISO9660_BOOTLOADER_OPTS += -eltorito-alt-boot +ROOTFS_ISO9660_BOOTLOADER_OPTS += $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI) +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_BIOS_BOOTLOADER),y) +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_BIOS) +else ifeq ($(BR2_TARGET_ROOTFS_ISO9660_EFI_BOOTLOADER),y) +ROOTFS_ISO9660_BOOTLOADER_OPTS = $(ROOTFS_ISO9660_BOOTLOADER_OPTS_EFI) endif define ROOTFS_ISO9660_CMD $(HOST_DIR)/bin/xorriso -as mkisofs \ $(ROOTFS_ISO9660_OPTS) \ + $(ROOTFS_ISO9660_BOOTLOADER_OPTS) \ -o $@ $(ROOTFS_ISO9660_TMP_TARGET_DIR) endef
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 4/6 support/testing/infra/emulator.py: update encoding when calling qemu
In reply to Kory MaincentWith UTF-8 got issue with wrong character returned by Qemu when using EFI BIOS. This breaks the test process with the following error. Update to ISO-8859-1 encoding to avoid it.
emulator.login()
File "/home/kmaincent/Documents/projects/ariane-groupe/buildroot/support/testing/infra/emulator.py", line 89, in login
index = self.qemu.expect(["buildroot login:", pexpect.TIMEOUT],
File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 340, in expect
return self.expect_list(compiled_pattern_list,
File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 369, in expect_list
return exp.expect_loop(timeout)
File "/usr/lib/python3/dist-packages/pexpect/expect.py", line 111, in expect_loop
incoming = spawn.read_nonblocking(spawn.maxread, timeout)
File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 485, in read_nonblocking
return super(spawn, self).read_nonblocking(size)
File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 178, in read_nonblocking
s = self._decoder.decode(s, final=False)
File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 0: invalid continuation byte
--- support/testing/infra/emulator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
support/testing/infra/emulator.py +1 -1
@@ -76,7 +76,7 @@ class Emulator(object): self.logfile.write("> starting qemu with '%s'\n" % " ".join(qemu_cmd)) self.qemu = pexpect.spawn(qemu_cmd[0], qemu_cmd[1:], timeout=5 * self.timeout_multiplier, - encoding='utf-8', + encoding='ISO-8859-1', env={"QEMU_AUDIO_DRV": "none"}) # We want only stdout into the log to avoid double echo self.qemu.logfile_read = self.logfile
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 5/6 boot/edk2: add support to i386 architecture
In reply to Kory MaincentAdd support the build the firmware for QEMU i386 pc machine
--- boot/edk2/Config.in | 12 +++++++++++- boot/edk2/edk2.mk | 12 ++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-)
boot/edk2/Config.in +11 -1
@@ -1,6 +1,6 @@ config BR2_TARGET_EDK2 bool "EDK2" - depends on BR2_x86_64 || BR2_aarch64 + depends on BR2_x86_64 || BR2_aarch64 || BR2_i386 depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 select BR2_PACKAGE_EDK2_PLATFORMS help
@@ -13,9 +13,18 @@ if BR2_TARGET_EDK2 choice prompt "Platform" + default BR2_TARGET_EDK2_PLATFORM_OVMF_I386 if BR2_i386 default BR2_TARGET_EDK2_PLATFORM_OVMF_X64 if BR2_x86_64 default BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU if BR2_aarch64 +config BR2_TARGET_EDK2_PLATFORM_OVMF_I386 + bool "i386" + depends on BR2_i386 || BR2_x86_64 + help + Platform configuration for a generic i386 target. + This platform will boot from flash address 0x0. + It should therefore be used as the first bootloader. + config BR2_TARGET_EDK2_PLATFORM_OVMF_X64 bool "x86-64" depends on BR2_x86_64
@@ -94,6 +103,7 @@ endchoice config BR2_TARGET_EDK2_FD_NAME string + default "OVMF" if BR2_TARGET_EDK2_PLATFORM_OVMF_I386 default "OVMF" if BR2_TARGET_EDK2_PLATFORM_OVMF_X64 default "QEMU_EFI" if BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU default "QEMU_EFI" if BR2_TARGET_EDK2_PLATFORM_ARM_VIRT_QEMU_KERNEL
boot/edk2/edk2.mk +10 -2
@@ -14,7 +14,9 @@ EDK2_DEPENDENCIES = edk2-platforms host-python3 host-acpica host-util-linux EDK2_INSTALL_TARGET = NO EDK2_INSTALL_IMAGES = YES -ifeq ($(BR2_x86_64),y) +ifeq ($(BR2_i386),y) +EDK2_ARCH = IA32 +else ifeq ($(BR2_x86_64),y) EDK2_ARCH = X64 else ifeq ($(BR2_aarch64),y) EDK2_ARCH = AARCH64
@@ -55,7 +57,13 @@ EDK2_GIT_SUBMODULES = YES EDK2_BUILD_PACKAGES = $(@D)/Build/Buildroot EDK2_PACKAGES_PATH = $(@D):$(EDK2_BUILD_PACKAGES):$(STAGING_DIR)/usr/share/edk2-platforms -ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y) +ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_I386),y) +EDK2_DEPENDENCIES += host-nasm +EDK2_PACKAGE_NAME = OvmfPkg +EDK2_PLATFORM_NAME = OvmfPkgIa32 +EDK2_BUILD_DIR = OvmfIa32 + +else ifeq ($(BR2_TARGET_EDK2_PLATFORM_OVMF_X64),y) EDK2_DEPENDENCIES += host-nasm EDK2_PACKAGE_NAME = OvmfPkg EDK2_PLATFORM_NAME = OvmfPkgX64
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 6/6 support/testing/tests/fs/test_iso9660.py: add support to test using EFI BIOS
In reply to Kory MaincentThe ISO9660 tests are only testing BIOS Legacy.
Add support to test an ISO9660 image based on EFI BIOS.
Add support to test an ISO9660 hybrid image based on Legacy and EFI BIOS. Add dedicated Grub2 builtin config for the EFI compatible cases.
--- support/testing/conf/grub2-efi.cfg | 2 + support/testing/tests/fs/test_iso9660.py | 74 +++++++++++++++++++++++- 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 support/testing/conf/grub2-efi.cfg
support/testing/conf/grub2-efi.cfg new file +2 -0
@@ -0,0 +1,2 @@ +set root=(cd0) +set prefix=/boot/grub
support/testing/tests/fs/test_iso9660.py +72 -2
105 lines not on this page · raw message
Signature · 6 lines
2.25.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot