Refactor in pc defconfigs
cover Refactor in pc defconfigs
This series makes a small refactor in the pc configs and out grub usage in them.
I am working on a aarch64-efi defconfig which will be very similar to these pc defconfigs.
These refactors are some improvements that I backported to the pc defconfigs while working on the future aarch64-efi one.
Erico Nunes (4):
configs/pc: bump kernel version
grub2: introduce BR2_TARGET_GRUB2_CFG configs/pc: refactor to use genimage and grub.cfg board/pc: add documentation for testing with qemu
board/pc/grub-bios.cfg | 6 ++++++ board/pc/grub-efi.cfg | 6 ++++++ board/pc/post-image.sh | 28 +-------------------------- board/pc/readme.txt | 42 ++++++++++++++++++++++++++++++++++++++++ boot/grub2/Config.in | 7 +++++++ boot/grub2/grub2.mk | 5 +++-- configs/pc_x86_64_bios_defconfig | 10 ++++++---- configs/pc_x86_64_efi_defconfig | 10 ++++++---- 8 files changed, 77 insertions(+), 37 deletions(-) create mode 100644 board/pc/grub-bios.cfg create mode 100755 board/pc/grub-efi.cfg
Signature · 1 line
2.13.6
PATCH 1/4 configs/pc: bump kernel version
Bump the kernel version to 4.13.8.
Tested with qemu 2.9.1 on bios and UEFI virtual machines.
--- configs/pc_x86_64_bios_defconfig | 6 +++--- configs/pc_x86_64_efi_defconfig | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
configs/pc_x86_64_bios_defconfig +3 -3
@@ -21,13 +21,13 @@ BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image.sh" -# Linux headers same as kernel, a 4.11 series -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y +# Linux headers same as kernel, a 4.13 series +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y # Kernel BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.5" +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.13.8" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config" BR2_LINUX_KERNEL_INSTALL_TARGET=y
configs/pc_x86_64_efi_defconfig +3 -3
@@ -24,13 +24,13 @@ BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image.sh" -# Linux headers same as kernel, a 4.11 series -BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_11=y +# Linux headers same as kernel, a 4.13 series +BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y # Kernel BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y -BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.5" +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.13.8" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config" BR2_LINUX_KERNEL_INSTALL_TARGET=y
Signature · 1 line
2.13.6
Thomas Petazzoni
AppliedPATCH 1/4 configs/pc: bump kernel version
Hello,
Quoted 8 lines · Erico Nunes
Bump the kernel version to 4.13.8.
Tested with qemu 2.9.1 on bios and UEFI virtual machines.Signed-off-by Erico Nunes <[email protected]>--- configs/pc_x86_64_bios_defconfig | 6 +++--- configs/pc_x86_64_efi_defconfig | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
Applied to master, thanks. Would you volunteer to maintain those PC defconfigs? That would be nice. If you're happy with doing this, you can send a patch to update the DEVELOPERS file :)
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 2/4 grub2: introduce BR2_TARGET_GRUB2_CFG
In reply to Erico NunesThis config can be used to provide a custom Grub 2 configuration file containing menu entries. Previously, this had to be always done by an external script which would overwrite the default file. This is backwards compatible for existing configs as the default value is the previously hardcoded value.
--- boot/grub2/Config.in | 7 +++++++ boot/grub2/grub2.mk | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-)
boot/grub2/Config.in +7 -0
@@ -76,6 +76,13 @@ config BR2_TARGET_GRUB2_BUILTIN_CONFIG device and other configuration parameters, but however menu entries cannot be described in this embedded configuration. +config BR2_TARGET_GRUB2_CFG + string "grub2 menu entries config" + default "boot/grub2/grub.cfg" + help + Path to a Grub 2 configuration file containing the grub2 menu + entries. + endif # BR2_TARGET_GRUB2 comment "grub2 needs a toolchain w/ wchar"
boot/grub2/grub2.mk +3 -2
@@ -95,8 +95,9 @@ define GRUB2_IMAGE_INSTALLATION -p "$(GRUB2_PREFIX)" \ $(if $(GRUB2_BUILTIN_CONFIG),-c $(GRUB2_BUILTIN_CONFIG)) \ $(GRUB2_BUILTIN_MODULES) - mkdir -p $(dir $(GRUB2_CFG)) - $(INSTALL) -D -m 0644 boot/grub2/grub.cfg $(GRUB2_CFG) + $(if $(BR2_TARGET_GRUB2_CFG), \ + mkdir -p $(dir $(GRUB2_CFG)) && \ + $(INSTALL) -D -m 0644 $(BR2_TARGET_GRUB2_CFG) $(GRUB2_CFG)) $(GRUB2_IMAGE_INSTALL_ELTORITO) endef GRUB2_POST_INSTALL_TARGET_HOOKS += GRUB2_IMAGE_INSTALLATION
Signature · 1 line
2.13.6
PATCH 2/4 grub2: introduce BR2_TARGET_GRUB2_CFG
Hello,
Quoted 8 lines · Erico Nunes
This config can be used to provide a custom Grub 2 configuration file containing menu entries. Previously, this had to be always done by an external script which would overwrite the default file. This is backwards compatible for existing configs as the default value is the previously hardcoded value.
Signed-off-by Erico Nunes <[email protected]>Cc Thomas Petazzoni <[email protected]>
I think we had similar proposals in the past (but perhaps it was for grub legacy, not grub2), and I believe our answer was that this config file can be trivially replaced in a post-build hook or rootfs overlay, because it is not used during the grub2 build process.
Hence a separate option is not really needed because you can already do that easily with a post-build or a rootfs overlay.
So, I'm not saying no entirely, but I'm not sure there is really a huge benefit in having a separate option for this.
Peter? Arnout?
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 2/4 grub2: introduce BR2_TARGET_GRUB2_CFG
Quoted 17 lines · Thomas Petazzoni
Hello,
Quoted 8 lines · Erico Nunes
This config can be used to provide a custom Grub 2 configuration file containing menu entries. Previously, this had to be always done by an external script which would overwrite the default file. This is backwards compatible for existing configs as the default value is the previously hardcoded value.
Signed-off-by Erico Nunes <[email protected]>Cc Thomas Petazzoni <[email protected]>I think we had similar proposals in the past (but perhaps it was for grub legacy, not grub2), and I believe our answer was that this config file can be trivially replaced in a post-build hook or rootfs overlay, because it is not used during the grub2 build process.
Quoted 5 lines
Hence a separate option is not really needed because you can already do that easily with a post-build or a rootfs overlay.
So, I'm not saying no entirely, but I'm not sure there is really a huge benefit in having a separate option for this.
I agree.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 3/4 configs/pc: refactor to use genimage and grub.cfg
In reply to Erico NunesThis refactors the pc configs and respective config files to use common Buildroot features instead of reimplementing them in the post image script.
The genimage script in support/ can be used as is done in many configs. The grub.cfg file can be set with BR2_TARGET_GRUB2_CFG instead of overwriting it in the script.
--- board/pc/grub-bios.cfg | 6 ++++++ board/pc/grub-efi.cfg | 6 ++++++ board/pc/post-image.sh | 28 +--------------------------- configs/pc_x86_64_bios_defconfig | 4 +++- configs/pc_x86_64_efi_defconfig | 4 +++- 5 files changed, 19 insertions(+), 29 deletions(-) create mode 100644 board/pc/grub-bios.cfg create mode 100755 board/pc/grub-efi.cfg
board/pc/grub-bios.cfg new file +6 -0
@@ -0,0 +1,6 @@ +set default="0" +set timeout="5" + +menuentry "Buildroot" { + linux /boot/bzImage root=/dev/sda1 rootwait console=tty1 +}
board/pc/grub-efi.cfg new file +6 -0
@@ -0,0 +1,6 @@ +set default="0" +set timeout="5" + +menuentry "Buildroot" { + linux /bzImage root=/dev/sda2 rootwait console=tty1 +}
board/pc/post-image.sh +1 -27
@@ -1,35 +1,9 @@ #!/bin/sh # Detect boot strategy, EFI or BIOS -if [ -f ${BINARIES_DIR}/efi-part/startup.nsh ]; then - BOOT_TYPE=efi - # grub.cfg needs customization for EFI since the root partition is - # number 2, and bzImage is in the EFI partition (1) - cat >${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg <<__EOF__ -set default="0" -set timeout="5" - -menuentry "Buildroot" { - linux /bzImage root=/dev/sda2 rootwait console=tty1 -} -__EOF__ -else - BOOT_TYPE=bios +if [ ! -f ${BINARIES_DIR}/efi-part/startup.nsh ]; then # Copy grub 1st stage to binaries, required for genimage cp -f ${HOST_DIR}/lib/grub/i386-pc/boot.img ${BINARIES_DIR} fi -BOARD_DIR="$(dirname $0)" -GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOOT_TYPE}.cfg" -GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" - -rm -rf "${GENIMAGE_TMP}" - -genimage \ - --rootpath "${TARGET_DIR}" \ - --tmppath "${GENIMAGE_TMP}" \ - --inputpath "${BINARIES_DIR}" \ - --outputpath "${BINARIES_DIR}" \ - --config "${GENIMAGE_CFG}" - exit $?
configs/pc_x86_64_bios_defconfig +3 -1
@@ -13,13 +13,15 @@ BR2_PACKAGE_HOST_GENIMAGE=y # Bootloader BR2_TARGET_GRUB2=y +BR2_TARGET_GRUB2_CFG="board/pc/grub-bios.cfg" # Filesystem / image BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set -BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image.sh support/scripts/genimage.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-bios.cfg" # Linux headers same as kernel, a 4.13 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y
configs/pc_x86_64_efi_defconfig +3 -1
@@ -16,13 +16,15 @@ BR2_PACKAGE_HOST_MTOOLS=y # Bootloader BR2_TARGET_GRUB2=y BR2_TARGET_GRUB2_X86_64_EFI=y +BR2_TARGET_GRUB2_CFG="board/pc/grub-efi.cfg" # Filesystem / image BR2_TARGET_ROOTFS_EXT2=y BR2_TARGET_ROOTFS_EXT2_4=y BR2_TARGET_ROOTFS_EXT2_SIZE="120M" # BR2_TARGET_ROOTFS_TAR is not set -BR2_ROOTFS_POST_IMAGE_SCRIPT="board/pc/post-image.sh" +BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="-c board/pc/genimage-efi.cfg" # Linux headers same as kernel, a 4.13 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_13=y
Signature · 1 line
2.13.6
PATCH 4/4 board/pc: add documentation for testing with qemu
In reply to Erico NunesAdd some documentation about running the pc defconfigs in qemu. In particular, document the use of the -bios parameter to use the OVMF firmware to test the UEFI image.
--- board/pc/readme.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
board/pc/readme.txt +42 -0
@@ -35,3 +35,45 @@ Bare PC sample config the setup as well. 3. Enjoy + + +Emulation in qemu (BIOS) +======================== + +1. Edit grub-bios.cfg + + Since the driver will show up in the virtual machine as /dev/vda, + change board/pc/grub-bios.cfg to use root=/dev/vda2 instead of + root=/dev/sda2. Then rebuild grub2 and the image. + +2. Run the emulation with: + +qemu-system-x86_64 \ + -M pc \ + -drive file=images/disk.img,if=virtio,format=raw \ + -net nic,model=virtio \ + -net user + + +Emulation in qemu (UEFI) +======================== + +1. Edit grub-efi.cfg + + Since the driver will show up in the virtual machine as /dev/vda, + change board/pc/grub-efi.cfg to use root=/dev/vda2 instead of + root=/dev/sda2. Then rebuild grub2 and the image. + +2. Run the emulation with: + +qemu-system-x86_64 \ + -M pc \ + -bios </path/to/OVMF_CODE.fd> \ + -drive file=images/disk.img,if=virtio,format=raw \ + -net nic,model=virtio \ + -net user + +Note that </path/to/QEMU_EFI.fd> needs to point to a valid x86_64 UEFI +firmware image for qemu. +It may be provided by your distribution as a edk2 or OVMF package, in +path such as /usr/share/edk2/ovmf/OVMF_CODE.fd .
Signature · 1 line
2.13.6