OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 4:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: debugging uefi
PostPosted: Sat Jan 21, 2023 3:13 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 20, 2004 12:00 am
Posts: 382
Location: Wellesley, Ontario, Canada
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:
$ 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:
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:
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


Top
 Profile  
 
 Post subject: Re: debugging uefi
PostPosted: Sat Jan 21, 2023 3:26 pm 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
Did you set the subsystem to EFI and place the executable at \EFI\BOOT\BOOTX64.EFI?


Top
 Profile  
 
 Post subject: Re: debugging uefi
PostPosted: Sat Jan 21, 2023 3:56 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
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.


Top
 Profile  
 
 Post subject: Re: debugging uefi
PostPosted: Sat Jan 21, 2023 6:12 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 20, 2004 12:00 am
Posts: 382
Location: Wellesley, Ontario, Canada
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group