efi application doesn't appear on iso image
Posted: Mon Dec 28, 2020 4:53 pm
I am following the https://wiki.osdev.org/EFI page instead of the https://wiki.osdev.org/UEFI_App_Bare_Bones since it's more complete
I've got the "hello world" code building succesfully for x64_64 with clang.
When I start qemu, I can see the FS0 drive and go there.
I expect the BOOTX64.EFI application to be in there so I can boot it, but it's not there.
So I can't run it.
I'm losing my mind a little over it.
the commands I'm executing to build the image, together with (some of) the buildcommands:
Relevant parts of my stack are:
gnu-efi,
clang,
cmake,
qemu-system-x86_64,
The md5 hashes of all my inbetween files are different, so they are being changed by every step.
I don't know of any way how to see if there is no BOOTX64.EFI file in there or not, if I don't trust my setup (yet).
Is it possible that the file isn't being copied into the image?
Is it possible that the image itsself is malformed?
Or is it possible that the application isn't being recognised as some runnable kernel?
Any suggestions on next steps on how to find out where I made a mistake?
Thanks in advance!
I've got the "hello world" code building succesfully for x64_64 with clang.
When I start qemu, I can see the FS0 drive and go there.
I expect the BOOTX64.EFI application to be in there so I can boot it, but it's not there.
So I can't run it.
I'm losing my mind a little over it.
the commands I'm executing to build the image, together with (some of) the buildcommands:
Code: Select all
add_executable(BOOTX64.EFI src/hello.c)
target_link_options(BOOTX64.EFI PRIVATE -nostdlib)
target_link_options(BOOTX64.EFI PRIVATE -shared)
target_link_options(BOOTX64.EFI PRIVATE)
target_include_directories(BOOTX64.EFI PRIVATE /usr/include/efi)
target_include_directories(BOOTX64.EFI PRIVATE /usr/include/efi/x86_64)
target_include_directories(BOOTX64.EFI PRIVATE /usr/include/efi/protocol)
target_link_libraries(BOOTX64.EFI PRIVATE /usr/lib/libefi.a)
target_link_libraries(BOOTX64.EFI PRIVATE /usr/lib/libgnuefi.a)
target_compile_options(BOOTX64.EFI PRIVATE -Wl,-subsystem:efi_application)
target_compile_options(BOOTX64.EFI PRIVATE -Wl,-entry:efi_main)
target_compile_options(BOOTX64.EFI PRIVATE -fPIC)
target_compile_options(BOOTX64.EFI PRIVATE -Wno-error=unused-command-line-argument)
add_custom_command( # Make empty image
COMMAND dd if=/dev/zero of=empty_uefi_partition.img bs=512 count=93750
OUTPUT empty_uefi_partition.img
)
add_custom_command( # Make EFI partition from empty image
COMMAND cp --reflink=auto -rf empty_uefi_partition.img uefi_partition.img && parted uefi_partition.img -s -a minimal mklabel gpt && parted uefi_partition.img -s -a minimal mkpart EFI FAT16 2048s 93716s && parted uefi_partition.img -s -a minimal toggle 1 boot
DEPENDS empty_uefi_partition.img
OUTPUT uefi_partition.img
)
add_custom_command( # Format temporary EFI partition
COMMAND dd if=/dev/zero of=temporary_partition.img bs=512 count=91669 && mformat -i temporary_partition.img -h 32 -t 321 -n 64 -c 1
OUTPUT temporary_partition.img
)
add_custom_command( # CP the kernel to EFI partition
COMMAND cp --reflink=auto -rf temporary_partition.img filled_partition.img && mcopy -i filled_partition.img BOOTX64.EFI ::
DEPENDS temporary_partition.img BOOTX64.EFI
OUTPUT filled_partition.img
)
add_custom_command( # Write filled EFI partition to an image.
COMMAND cp --reflink=auto -rf temporary_partition.img BOOTX64.ISO && dd if=filled_partition.img of=BOOTX64.ISO bs=512 count=91669 seek=2048 conv=notrunc
DEPENDS uefi_partition.img filled_partition.img
OUTPUT BOOTX64.ISO
)
add_custom_target( lauch_BOOTX64.ISO
COMMAND qemu-system-x86_64 -cpu qemu64 -bios /usr/share/ovmf/OVMF.fd -drive file=BOOTX64.ISO,if=ide -vga std -usb -serial stdio -no-reboot -net none
DEPENDS BOOTX64.ISO
)
gnu-efi,
clang,
cmake,
qemu-system-x86_64,
The md5 hashes of all my inbetween files are different, so they are being changed by every step.
I don't know of any way how to see if there is no BOOTX64.EFI file in there or not, if I don't trust my setup (yet).
Is it possible that the file isn't being copied into the image?
Is it possible that the image itsself is malformed?
Or is it possible that the application isn't being recognised as some runnable kernel?
Any suggestions on next steps on how to find out where I made a mistake?
Thanks in advance!