Giter Site home page Giter Site logo

pbatard / uefi-simple Goto Github PK

View Code? Open in Web Editor NEW

This project forked from utshina/uefi-simple

230.0 20.0 42.0 91 KB

UEFI development made easy

License: Other

Makefile 38.81% C 27.90% VBScript 33.29%
uefi gnu-efi visual-studio gcc qemu arm aarch64 ia32 x64 arm64

uefi-simple's Introduction

UEFI:SIMPLE - EFI development made easy

A simple UEFI "Hello World!" style application that can:

  • be compiled on Windows or Linux, using Visual Studio 2022, MinGW or gcc.
  • be compiled for x86_32, x86_64, ARM, ARM64 or RISCV64 targets
  • be tested on the fly, through a QEMU + OVMF or QEMU_EFI virtual machine.

Prerequisites

  • Visual Studio 2022 or gcc/make
  • QEMU v2.7 or later (NB: You can find QEMU Windows binaries here)
  • git
  • wget, unzip, if not using Visual Studio

Sub-Module initialization

For convenience, the project relies on the gnu-efi library, so you need to initialize the git submodule either through git commandline with:

git submodule init
git submodule update

Or, if using a UI client (such as TortoiseGit) by selecting Submodule Update in the context menu.

Compilation and testing

If using Visual Studio, just press F5 to have the application compiled and launched in the QEMU emulator.

If using MinGW or Linux, issue the following from a command prompt:

make

If needed you can also add ARCH=<arch> and CROSS_COMPILE=<tuple>, e.g.:

  • make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  • make ARCH=aa64 CROSS_COMPILE=aarch64-linux-gnu-
  • make ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu-

where <arch> can be x64, ia32, arm, aa64 or riscv64.

You can also add qemu as your make target to run the application under QEMU, in which case a relevant UEFI firmware (OVMF for x86 or QEMU_EFI for Arm) will be automatically downloaded to run your application against it.

Visual Studio 2022 and ARM/ARM64 support

Please be mindful that, to enable ARM or ARM64 compilation support in Visual Studio 2022, you MUST go to the Individual components screen in the setup application and select the ARM/ARM64 build tools there, as they do NOT appear in the default Workloads screen:

VS2019 Individual Components

uefi-simple's People

Contributors

pbatard avatar schierlm avatar utshina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uefi-simple's Issues

Having issues..

Hi Pete,

I have VS 2015 installed and used the git console to clone the project but running into a few roadblocks. 1. VS says project out of date. 2. When i try to compile it VS errs and says missing v141 project tools. How can i fix this?

Thanks

Launch debug from Visual Studio but nothing happens

I followed your guide on the blog but I'm not able to see anything when launching Debug from Visual Studio 2015.
I can see VS in debug mode and qemu process between active processes but no interface.
I doublechecked everything but the result is the same.
Also if I try to launch qemu from the command line I have the same issue.
I'm working on windows 10 with visual studio 2015, no compilation error.
Thank you

qemu crashes

fresh install of visual studio with all build tools, followed instructions on your blog. but qemu crashes after "guest has not yet initialized the display". any help?

Edit: might be useful to attach a log from qemu (with args -d int)

WARNING: Image format was not specified for 'json:{"fat-type": 0, "backing": {"driver": "vvfat_write_target"}, "dir": "image", "driver": "vvfat", "floppy": false, "rw": true, "write-target": {"driver": "qcow", "file": {"driver": "file", "filename": "C:\\Users\\thego\\AppData\\Local\\Temp\\qem9DA4.tmp"}}' 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.
     0: v=68 e=0000 i=0 cpl=0 IP=0028:0000000007eae450 pc=0000000007eae450 SP=0008:0000000007f94be0 env->regs[R_EAX]=00000000000000fe
RAX=00000000000000fe RBX=00000000fffec0e4 RCX=0000000000000021 RDX=0000000000000021
RSI=0000000000000000 RDI=000000000000fffe RBP=0000000007f94c10 RSP=0000000007f94be0
R8 =0000000000000000 R9 =0000000007d4df18 R10=0000000007422f60 R11=0000000007f94ad0
R12=0000000000000000 R13=0000000000000000 R14=0000000000000000 R15=0000000000000000
RIP=0000000007eae450 RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
CS =0028 0000000000000000 ffffffff 00af9b00 DPL=0 CS64 [-RA]
SS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
DS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
FS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
GS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT=     0000000007f1ce98 0000003f
IDT=     0000000007c07018 00000fff
CR0=80000033 CR2=0000000000000000 CR3=0000000007f33000 CR4=00000660
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000030 CCD=0000000007f94be0 CCO=SUBQ
EFER=0000000000000500
WARNING: Image format was not specified for 'json:{"fat-type": 0, "backing": {"driver": "vvfat_write_target"}, "dir": "image", "driver": "vvfat", "floppy": false, "rw": true, "write-target": {"driver": "qcow", "file": {"driver": "file", "filename": "C:\\Users\\thego\\AppData\\Local\\Temp\\qem9DA4.tmp"}}' 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.
     0: v=68 e=0000 i=0 cpl=0 IP=0028:0000000007eae450 pc=0000000007eae450 SP=0008:0000000007f94be0 env->regs[R_EAX]=00000000000000fe
RAX=00000000000000fe RBX=00000000fffec0e4 RCX=0000000000000021 RDX=0000000000000021
RSI=0000000000000000 RDI=000000000000fffe RBP=0000000007f94c10 RSP=0000000007f94be0
R8 =0000000000000000 R9 =0000000007d4df18 R10=0000000007422f60 R11=0000000007f94ad0
R12=0000000000000000 R13=0000000000000000 R14=0000000000000000 R15=0000000000000000
RIP=0000000007eae450 RFL=00000202 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
CS =0028 0000000000000000 ffffffff 00af9b00 DPL=0 CS64 [-RA]
SS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
DS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
FS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
GS =0008 0000000000000000 ffffffff 00cf9300 DPL=0 DS   [-WA]
LDT=0000 0000000000000000 0000ffff 00008200 DPL=0 LDT
TR =0000 0000000000000000 0000ffff 00008b00 DPL=0 TSS64-busy
GDT=     0000000007f1ce98 0000003f
IDT=     0000000007c07018 00000fff
CR0=80000033 CR2=0000000000000000 CR3=0000000007f33000 CR4=00000660
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000
DR6=00000000ffff0ff0 DR7=0000000000000400
CCS=0000000000000030 CCD=0000000007f94be0 CCO=SUBQ
EFER=0000000000000500

Broken on QEMU 2.9.0 Windows x64

Thank you for this project.

It does not work for me on Windows x64 with QEMU 2.9.0. It does work with 2.8.0. Probably not an issue in this project, but figured I would mention it in case someone else is having issues with the latest QEMU.

debug.vbs

In my case I had to add the rw permission for the virtual hdd at the end of the debug.vbs.

Call shell.Run("""" & QEMU_PATH & QEMU_EXE & """ " & QEMU_OPTS & " -L . -bios " & FW_FILE & " -hda fat:rw:image", 1, True)

Without the permission the debug.vbs couldn't start the qemu.exe.

Fails on Linux/QEMU

QEMU reports:

!!!! X64 Exception Type - 0000000000000006 !!!!

This seems to be due to using a pre 4.7 MinGW-w64 gcc when compiling gnulib

Creating fat image for usb on windows ?

Hi,

I finished my project.

I want to run it on a real hardware. Unfortunately I am not sure about correct way of creating image on windows10x64

Here steps mentioned:

Creating the FAT image
Next, create a FAT filesystem image.

dd if=/dev/zero of=fat.img bs=1k count=1440
mformat -i fat.img -f 1440 ::
mmd -i fat.img ::/EFI
mmd -i fat.img ::/EFI/BOOT
mcopy -i fat.img BOOTX64.EFI ::/EFI/BOOT

Running as a USB stick image
The FAT image can either be written directly to a USB stick and used in in a UEFI machine, or it can be run directly in QEMU:

qemu-system-x86_64 -L OVMF_dir/ -bios OVMF.fd -usb -usbdevice disk::fat.img

I am not good about this what should I do on windows ?

ER: ARM64 support

While this shouldn't be much trouble for gcc toolchains, the big hurdle is the lack of Visual Studio support for ARM64 compilation tools. The framework is most certainly there, and provisions for the tools DO exist, but Microsoft doesn't seem to want to release them in the open... ๐Ÿ˜ญ

Even switching to Clang/C2 doesn't help, as there are no ARM64 c2.dll's in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Clang 3.7\bin\.

Once again, that's what you get for using a "ยฃ$%^&*( BSD license... โ€” Because Microsoft are "entitled" to create derivative work of Clang/LLVM, without releasing any of their changes, what would have been a quick affair (clone the source, add ARM64 support and produce a compatible c2.dll) suddenly becomes an impossibility. And people still say that BSD offers more "freedom" than the GPL. Yeah, right... ๐Ÿ˜ 

Debugging arguments not working properly in Visual Studio (2015)

When running this project using default configuration, TARGET became "-".

Looking through the script and manually printing messages, I figured out that WScript.Arguments(1) == "-", because my PATH got cut-off in the middle... So the argument I was looking for as a TargetPlatform was located at a far later index (I think 4). I solved this by enclosing variables in Debugging --> Command Arguments in double quotes.

So for future ease, change Debugging --> Command Arguments to:
//d .msvc\debug.vbs "$(TargetPath)" "$(PlatformShortName)"

uefi-simple & QEMU Issue

I tried to follow the instructions on your blog: "Easily create UEFI applications using Visual Studio 2013." This was very useful, and I am able to create applications but I am not able to get the emulator to work under a windows environment. In your text, you give the link to the QEMU site, but there are no binaries at the download link anymore. I found where the old link pointed to (http://www.h7.dion.ne.jp/~qemu-win/) and tried those binaries. I had to edit the debug.vbs file to point to "Programs (x86)" and also the .exe filename. I'm still not sure I did that right. In any event, I could not get it to work properly. I downloaded some more recent binaries from here: http://qemu.weilnetz.de/w64/, and I get further, but when QEMU opens, I get the "Guest has not initialized the display (yet)." message. If I try running QEMU from the command line:

C:\uefi-simple>"C:\Program Files\qemu\qemu-system-x86_64w.exe" -L . -bios OVMF_x86_64.fd -net none -hda fat:image

I get the same thing.

Any advice you might have would be greatly appreciated.
-Don

uefi application and network

Thank you for your example!
Is it possible to make some http requests in such kind of applications?
Where to read about it? Or may be you could make example?

Can not use any C function

Hello, thank you for providing this project. That was really helpful. However, I got an interesting issue. I debug project . I write efi code but I can not use any of C library function. I get errors. Something like unresolved external... What is the reason of that ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.