diff options
author | Alejandro Hernandez Samaniego <alejandro@enedino.org> | 2023-01-08 12:15:23 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-12 23:08:58 +0000 |
commit | 1149b4fbb6002aa5a4cfe90bd404834721593968 (patch) | |
tree | d3dc2b84a4390ef02ff8d20d4fd8f2923033755e /meta/classes-recipe | |
parent | dca9b920e08b102b377d74f870f73d5f3f377394 (diff) | |
download | poky-1149b4fbb6002aa5a4cfe90bd404834721593968.tar.gz |
baremetal-helloworld: Enable x86 and x86-64 ports
- The qemux86 port for helloworld-baremetal builds in the standard way, however,
it uses NASM syntax for the startup code, hence we include a dependency to
nasm-native, QEMU forces us to use an ELF file rather than a bin file to boot
from this architecture using the -kernel parameter.
- QEMU refuses to boot using the -kernel parameter for files containing an ELF64
header [1], instead, it requires a multiboot2 compatible image.
We could create an image that contains a multiboot2 header by piggybacking
into grub2-native, specifically grub-mkrescue, but it requires some extra
runtime dependencies (xorriso which is currently part of meta-oe), and assumes
a grub installation exists on the host.
Due to host contamination and dependency complications, we dont rely on grub2,
but rather do this process manually instead, the x86-64 port contains a stage1
bootloader, stage2 bootloader and a 64 bit baremetal app (multiboot2
compatible), booting into real (16 bit), protected (32 bit) and long (64 bit)
modes, eventually running the helloworld-baremetal app. This is the reason why
we need the code changes to use a separate Makefile, and create an image
specifically for qemux86-64.
$ runqemu nographic
Booting from ROM..
Hello OpenEmbedded on x86!
$ runqemu nographic
Starting Stage 1 Bootloader
Loading Stage 2 Bootloader
Stage 2 Loaded.
Jumping to Stage2 Bootloader
In Stage 2
Done
Hello OpenEmbedded on x86-64!
[1] https://gitlab.com/qemu-project/qemu/-/blob/v7.2.0/hw/i386/multiboot.c#L199
(From OE-Core rev: 1dffd81b2991f90ab95cb36d8ff7626efd21434f)
Signed-off-by: Alejandro Enedino Hernandez Samaniego <alejandro@enedino.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r-- | meta/classes-recipe/baremetal-image.bbclass | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/meta/classes-recipe/baremetal-image.bbclass b/meta/classes-recipe/baremetal-image.bbclass index 513155e9ae..70791f999a 100644 --- a/meta/classes-recipe/baremetal-image.bbclass +++ b/meta/classes-recipe/baremetal-image.bbclass | |||
@@ -86,6 +86,11 @@ QB_DEFAULT_FSTYPE ?= "bin" | |||
86 | QB_DTB ?= "" | 86 | QB_DTB ?= "" |
87 | QB_OPT_APPEND:append = " -nographic" | 87 | QB_OPT_APPEND:append = " -nographic" |
88 | 88 | ||
89 | # QEMU x86 requires an .elf kernel to boot rather than a .bin | ||
90 | QB_DEFAULT_KERNEL:qemux86 ?= "${IMAGE_LINK_NAME}.elf" | ||
91 | # QEMU x86-64 refuses to boot from -kernel, needs a multiboot compatible image | ||
92 | QB_DEFAULT_FSTYPE:qemux86-64 ?= "iso" | ||
93 | |||
89 | # RISC-V tunes set the BIOS, unset, and instruct QEMU to | 94 | # RISC-V tunes set the BIOS, unset, and instruct QEMU to |
90 | # ignore the BIOS and boot from -kernel | 95 | # ignore the BIOS and boot from -kernel |
91 | QB_DEFAULT_BIOS:qemuriscv64 = "" | 96 | QB_DEFAULT_BIOS:qemuriscv64 = "" |