kumquat-buildroot/board/pc
Yann E. MORIN 086c96b452 configs/pc_x86_64_bios_defconfig: fix image generation after grub2 rework
Commit 82d1e8c628 (boot/grub2: use none platform when building for
host) changed host-grub2 to only install the tools, not the actual
bootloader or its modules, as they are of no use on the host.

It so happened that, when not instructed to built for a specific
platform, the grub2 buildsystem would default to build the legacy bios
platform (at least when the build happens on an x86 or x86_64 host).

However, because the host is more often than not an x86 or x86_64, when
the target was also an x68 or x86_64, the modules built for the host
could be re-used for the target, and this is what was done for our
pc_x86_64_bios_defconfig.

But now that we explicitly tell the grub2 buildsystem to not build any
platform when we build host-grub2, we no longer have access to the grub2
modules from the host directory, and the build fails when assembling the
final image.

We fix that in two ways:

First, we ensure that individual modules from the target grub2 get installed
in target/; we can only do that if the target grub2 tools are also
installed, so we enable that in the configuration.

Second, we fix the post-build script to look in target/ rather than in
host/.

All that, just for the 512-byte boot.img bootstrap, which pulls in all
the other modules (4.3MiB), the tools (8.8MiB)... But we are not going
to cherry-pick individual modules; this is error prone and
unmaintainable...

Reported-by: Adam Duskett <aduskett@gmail.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Köry Maincent <kory.maincent@bootlin.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2021-12-05 12:32:24 +01:00
..
genimage-bios.cfg board/pc/genimage-bios.cfg: beautify file 2021-11-08 22:59:32 +01:00
genimage-efi.cfg board/pc/genimage-efi.cfg: beautify file 2021-11-08 22:59:32 +01:00
grub-bios.cfg
grub-efi.cfg
linux.config
post-build.sh configs/pc_x86_64_bios_defconfig: fix image generation after grub2 rework 2021-12-05 12:32:24 +01:00
post-image-efi.sh
readme.txt

Bare PC sample config
=====================

1. Build

  First select the appropriate target you want.

  For BIOS-based boot strategy:

  $ make pc_x86_64_bios_defconfig

  For EFI-based boot strategy on a GPT-partitioned disk:

  $ make pc_x86_64_efi_defconfig

  Add any additional packages required and build:

  $ make

2. Write the pendrive

  The build process will create a pendrive image called sdcard.img in
  output/images.

  Write the image to a pendrive:

  $ dd if=output/images/disk.img of=/dev/sdc; sync

  Once it's done insert it into the target PC and boot.

  Remember that if said PC has another boot device you might need to
  select this alternative for it to boot.

  In the case of EFI boot you might need to disable Secure Boot from
  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)
========================

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/OVMF.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 .