This is a minimal, from-scratch 64-bit UEFI application (our "kernel") that prints "Hello World" directly using UEFI services, without external libraries like gnu-efi.
uefi.h: Defines the absolutely essential data types (EFI_SYSTEM_TABLE,EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL, etc.) required by the UEFI specification.main.c: The entry pointefi_main. It uses theSystemTablepassed by the firmware to write strings directly to the screen viaConOut->OutputString.Makefile: Usesclangandlld-linkto build a PE32+.efiexecutable (the format required by UEFI firmware).
We have compiled the kernel and placed it at EFI/BOOT/BOOTX64.EFI. This is the default fallback boot path on 64-bit UEFI systems.
To create the bootable USB drive (on Linux):
- Insert your USB drive (e.g.,
/dev/sdX). - Format the drive with a FAT32 filesystem. You can use tools like GParted or
mkfs.fat -F 32 /dev/sdX1. - Mount the USB drive.
- Copy the entire
EFIdirectory generated here to the root of the USB drive. The structure should look exactly like this:[USB Root] └── EFI └── BOOT └── BOOTX64.EFI - Unmount the drive, plug it into your modern PC, enter the BIOS/UEFI boot menu, and select the USB drive!
If you have QEMU and OVMF (UEFI firmware for QEMU) installed, you can test it virtually:
qemu-system-x86_64 -bios /usr/share/OVMF/OVMF_CODE.fd -drive file=fat:rw:.,format=raw