configs/pc: refactor to use genimage and grub.cfg
PATCH v2 1/3 configs/pc: refactor to use genimage and grub.cfg
This simplifies the pc configs and respective post image scripts to use the shared genimage script and separate grub config files. Separate grub files are cleaner to maintain and easier to copy and modify, for example to support booting the pc defconfigs in qemu.
---
Changes v1 -> v2:
- Drop the BR2_TARGET_GRUB2_CFG proposed use since the patch was dropped.
--- board/pc/grub-bios.cfg | 6 ++++++ board/pc/grub-efi.cfg | 6 ++++++ board/pc/post-image.sh | 29 ++++------------------------- configs/pc_x86_64_bios_defconfig | 3 ++- configs/pc_x86_64_efi_defconfig | 3 ++- 5 files changed, 20 insertions(+), 27 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 +4 -25
@@ -1,35 +1,14 @@ #!/bin/sh +BOARD_DIR="$(dirname $0)" + # 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__ + cp -f ${BOARD_DIR}/grub-efi.cfg ${BINARIES_DIR}/efi-part/EFI/BOOT/grub.cfg else - BOOT_TYPE=bios + cp -f ${BOARD_DIR}/grub-bios.cfg ${TARGET_DIR}/boot/grub/grub.cfg # 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 +2 -1
@@ -19,7 +19,8 @@ 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 +2 -1
@@ -22,7 +22,8 @@ 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-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 v2 2/3 board/pc: add documentation for testing with qemu
Add 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.
---
Changes v1 -> v2:
- Made the images path relative to output/ to match in-tree Buildroot builds.
--- 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=output/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=output/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
PATCH v2 2/3 board/pc: add documentation for testing with qemu
Hello,
board/pc/readme.txt Bare PC sample config · line 76
Quoted 8 lines · Erico Nunes
board/pc/readme.txt +8
-0+qemu-system-x86_64 \ + -M pc \ + -bios </path/to/OVMF_CODE.fd> \ + -drive file=output/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
You meant OVMF_CODE.fd here, so I've fixed that up and applied. Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH v2 2/3 board/pc: add documentation for testing with qemu
In reply to Erico NunesQuoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Erico" == Erico Nunes <[email protected]> writes:
Add 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.
Signed-off-by Erico Nunes <[email protected]>Cc Peter Korsgaard <[email protected]>
...
Quoted 5 lines
board/pc/readme.txt +5
-0+Emulation in qemu (UEFI) +======================== + +1. Edit grub-efi.cfg +
board/pc/readme.txt Bare PC sample config · line 72
Quoted 10 lines
board/pc/readme.txt +10
-0+ 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=output/images/disk.img,if=virtio,format=raw \
Maybe it would be better to not use virtio for the disk image so we can keep root=/dev/sda? Unless the UEFI firmware doesn't support normal sata controllers?
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 3/3 DEVELOPERS: add maintainer for pc_x86_64_* defconfigs
In reply to Erico NunesI've been using this packages to test changes in the grub package, so I can maintain them.
--- DEVELOPERS | 1 + 1 file changed, 1 insertion(+)
DEVELOPERS +1 -0
@@ -535,6 +535,7 @@ F: package/efivar/ F: package/fwts/ F: package/spi-tools/ F: package/xdotool/ +F: configs/pc_x86_64_* N: Erik Stromdahl <[email protected]> F: package/mxsldr/
Signature · 1 line
2.13.6
Thomas Petazzoni
AppliedPATCH v2 3/3 DEVELOPERS: add maintainer for pc_x86_64_* defconfigs
Hello,
Quoted 8 lines · Erico Nunes
I've been using this packages to test changes in the grub package, so I can maintain them.
Signed-off-by Erico Nunes <[email protected]>Cc Thomas Petazzoni <[email protected]>--- DEVELOPERS | 1 + 1 file changed, 1 insertion(+)
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Thomas Petazzoni
AppliedPATCH v2 1/3 configs/pc: refactor to use genimage and grub.cfg
In reply to Erico NunesHello,
Quoted 11 lines · Erico Nunes
This simplifies the pc configs and respective post image scripts to use the shared genimage script and separate grub config files. Separate grub files are cleaner to maintain and easier to copy and modify, for example to support booting the pc defconfigs in qemu.
Signed-off-by Erico Nunes <[email protected]>Cc Thomas Petazzoni <[email protected]>---
Changes v1 -> v2:
- Drop theBR2_TARGET_GRUB2_CFGproposed use since the patch was dropped.
Quoted 9 lines
--- board/pc/grub-bios.cfg | 6 ++++++ board/pc/grub-efi.cfg | 6 ++++++ board/pc/post-image.sh | 29 ++++------------------------- configs/pc_x86_64_bios_defconfig | 3 ++- configs/pc_x86_64_efi_defconfig | 3 ++- 5 files changed, 20 insertions(+), 27 deletions(-) create mode 100644 board/pc/grub-bios.cfg create mode 100755 board/pc/grub-efi.cfg
Applied to master, thanks.
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com