All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg
@ 2017-10-22 13:54 Erico Nunes
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu Erico Nunes
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Erico Nunes @ 2017-10-22 13:54 UTC (permalink / raw)
  To: buildroot

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 <nunes.erico@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
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

diff --git a/board/pc/grub-bios.cfg b/board/pc/grub-bios.cfg
new file mode 100644
index 0000000000..bd3e3f0006
--- /dev/null
+++ b/board/pc/grub-bios.cfg
@@ -0,0 +1,6 @@
+set default="0"
+set timeout="5"
+
+menuentry "Buildroot" {
+	linux /boot/bzImage root=/dev/sda1 rootwait console=tty1
+}
diff --git a/board/pc/grub-efi.cfg b/board/pc/grub-efi.cfg
new file mode 100755
index 0000000000..222301a4e0
--- /dev/null
+++ b/board/pc/grub-efi.cfg
@@ -0,0 +1,6 @@
+set default="0"
+set timeout="5"
+
+menuentry "Buildroot" {
+	linux /bzImage root=/dev/sda2 rootwait console=tty1
+}
diff --git a/board/pc/post-image.sh b/board/pc/post-image.sh
index c88ecb1dc2..bdd0847ec5 100755
--- a/board/pc/post-image.sh
+++ b/board/pc/post-image.sh
@@ -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 $?
diff --git a/configs/pc_x86_64_bios_defconfig b/configs/pc_x86_64_bios_defconfig
index ddbd776154..47787bc118 100644
--- a/configs/pc_x86_64_bios_defconfig
+++ b/configs/pc_x86_64_bios_defconfig
@@ -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
diff --git a/configs/pc_x86_64_efi_defconfig b/configs/pc_x86_64_efi_defconfig
index 94385252b9..67ba5bcf5b 100644
--- a/configs/pc_x86_64_efi_defconfig
+++ b/configs/pc_x86_64_efi_defconfig
@@ -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
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu
  2017-10-22 13:54 [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Erico Nunes
@ 2017-10-22 13:54 ` Erico Nunes
  2017-10-22 14:36   ` Thomas Petazzoni
  2017-10-22 15:26   ` Peter Korsgaard
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 3/3] DEVELOPERS: add maintainer for pc_x86_64_* defconfigs Erico Nunes
  2017-10-22 14:36 ` [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Thomas Petazzoni
  2 siblings, 2 replies; 7+ messages in thread
From: Erico Nunes @ 2017-10-22 13:54 UTC (permalink / raw)
  To: buildroot

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 <nunes.erico@gmail.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
---
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(+)

diff --git a/board/pc/readme.txt b/board/pc/readme.txt
index 68ca21166f..5277ea5bc6 100644
--- a/board/pc/readme.txt
+++ b/board/pc/readme.txt
@@ -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 .
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 3/3] DEVELOPERS: add maintainer for pc_x86_64_* defconfigs
  2017-10-22 13:54 [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Erico Nunes
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu Erico Nunes
@ 2017-10-22 13:54 ` Erico Nunes
  2017-10-22 14:36   ` Thomas Petazzoni
  2017-10-22 14:36 ` [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Thomas Petazzoni
  2 siblings, 1 reply; 7+ messages in thread
From: Erico Nunes @ 2017-10-22 13:54 UTC (permalink / raw)
  To: buildroot

I've been using this packages to test changes in the grub package, so
I can maintain them.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 DEVELOPERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index 448dd4bbce..f0f83b0f42 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -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 <erik.stromdahl@gmail.com>
 F:	package/mxsldr/
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg
  2017-10-22 13:54 [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Erico Nunes
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu Erico Nunes
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 3/3] DEVELOPERS: add maintainer for pc_x86_64_* defconfigs Erico Nunes
@ 2017-10-22 14:36 ` Thomas Petazzoni
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2017-10-22 14:36 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 22 Oct 2017 15:54:24 +0200, Erico Nunes wrote:
> 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 <nunes.erico@gmail.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> 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

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu Erico Nunes
@ 2017-10-22 14:36   ` Thomas Petazzoni
  2017-10-22 15:26   ` Peter Korsgaard
  1 sibling, 0 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2017-10-22 14:36 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 22 Oct 2017 15:54:25 +0200, Erico Nunes wrote:

> +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
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 3/3] DEVELOPERS: add maintainer for pc_x86_64_* defconfigs
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 3/3] DEVELOPERS: add maintainer for pc_x86_64_* defconfigs Erico Nunes
@ 2017-10-22 14:36   ` Thomas Petazzoni
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2017-10-22 14:36 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 22 Oct 2017 15:54:26 +0200, Erico Nunes wrote:
> I've been using this packages to test changes in the grub package, so
> I can maintain them.
> 
> Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  DEVELOPERS | 1 +
>  1 file changed, 1 insertion(+)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu
  2017-10-22 13:54 ` [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu Erico Nunes
  2017-10-22 14:36   ` Thomas Petazzoni
@ 2017-10-22 15:26   ` Peter Korsgaard
  1 sibling, 0 replies; 7+ messages in thread
From: Peter Korsgaard @ 2017-10-22 15:26 UTC (permalink / raw)
  To: buildroot

>>>>> "Erico" == Erico Nunes <nunes.erico@gmail.com> 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 <nunes.erico@gmail.com>
 > Cc: Peter Korsgaard <peter@korsgaard.com>

...

 > +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 \

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?

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-22 15:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-22 13:54 [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Erico Nunes
2017-10-22 13:54 ` [Buildroot] [PATCH v2 2/3] board/pc: add documentation for testing with qemu Erico Nunes
2017-10-22 14:36   ` Thomas Petazzoni
2017-10-22 15:26   ` Peter Korsgaard
2017-10-22 13:54 ` [Buildroot] [PATCH v2 3/3] DEVELOPERS: add maintainer for pc_x86_64_* defconfigs Erico Nunes
2017-10-22 14:36   ` Thomas Petazzoni
2017-10-22 14:36 ` [Buildroot] [PATCH v2 1/3] configs/pc: refactor to use genimage and grub.cfg Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.