Page 1 of 1

debugging uefi

Posted: Sat Jan 21, 2023 3:13 pm
by carbonBased
Hello,

I've gotten back into osdev after a long hiatus, and I'm trying to stitch together some uefi info online to produce a simple uefi bootable image, but each attempt results in qemu not finding any bootable images.

I first went through this tutorial ( https://wiki.osdev.org/UEFI ) to produce a PE executable using gnu-efi, which appears to produce a correct app (but how else to assert that this is a loadable UEFI application?)

Code: Select all

$ file main.efi 
main.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows, 6 sections
I then followed the "Linux, root required" instructions to create a disk image for it, and booted it as:

Code: Select all

qemu-system-x86_64 -drive if=pflash,format=raw,unit=0,file=./ovmf-x86_64-code.bin,readonly=on -drive if=pflash,format=raw,unit=1,file=./ovmf-x86_64-vars.bin -net none -hda hdimage.bin
But the loader claims "No bootable option or device was found"

Although qemu contained a warning:

Code: Select all

WARNING: Image format was not specified for 'hdimage.bin' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.
So I suspect the disk image, and so tried these steps instead:
https://wiki.osdev.org/UEFI_Bare_Bones

But still no luck (and same warning).

Any suggestions on how to move forward here?

Thanks,
Jeff

Re: debugging uefi

Posted: Sat Jan 21, 2023 3:26 pm
by Gigasoft
Did you set the subsystem to EFI and place the executable at \EFI\BOOT\BOOTX64.EFI?

Re: debugging uefi

Posted: Sat Jan 21, 2023 3:56 pm
by Octocontrabass
You can greatly speed up your development cycle by telling QEMU to dynamically generate the disk image.

Is your file named "\EFI\BOOT\BOOTX64.EFI"? If not, automatic boot will fail. You can still run your application from the EFI shell by typing "fs0:" to select your filesystem and then browsing with "cd" and "ls" to locate your application.

Re: debugging uefi

Posted: Sat Jan 21, 2023 6:12 pm
by carbonBased
OMG, that was it... improperly named application.

Thanks!

The first link just mentioned to copy the file over, and I read about some firmwares searching for any/all EFI apps, so it seemed like the name didn't matter... I should've known to try BOOTX64.EFI.

Thanks again!
--Jeff