debugging uefi

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

debugging uefi

Post 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
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: debugging uefi

Post by Gigasoft »

Did you set the subsystem to EFI and place the executable at \EFI\BOOT\BOOTX64.EFI?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: debugging uefi

Post 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.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: debugging uefi

Post 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
Post Reply