Skip to content

Latest commit

 

History

History
61 lines (42 loc) · 2.31 KB

BUILDING.md

File metadata and controls

61 lines (42 loc) · 2.31 KB

Building and running UEFI applications

UEFI binaries

UEFI applications are simple COFF (Windows) executables, with the special EFI_Application subsystem, and some limitations (such as no dynamic linking).

The Rust compiler supports building UEFI applications for the aarch64-unknown-uefi, i686-unknown-uefi, and x86_64-unknown-uefi targets.

Building for a UEFI target

For instructions on building the uefi-rs crates, see the README. This section is for building your own crates, outside of the uefi-rs repo.

  • Install a nightly version of the Rust toolchain and include the rust-src component. The easiest way to do this is with a rust-toolchain.toml file, for example:

    [toolchain]
    channel = "nightly"
    components = ["rust-src"]
  • Build the crate:

    cargo build --target x86_64-unknown-uefi.

  • The target directory will contain a x86_64-unknown-uefi subdirectory, where you will find a <crate name>.efi file - a normal UEFI executable.

Running

  • To run an .efi executable on a real computer:

    • Find a USB drive which is FAT12 / FAT16 / FAT32 formatted
    • Copy the file to the USB drive, to /EFI/Boot/Bootx64.efi
    • In the UEFI BIOS, choose "Boot from USB" or similar
  • To run this in QEMU:

    • You will need a recent version of QEMU as well as OVMF to provide UEFI support

    • Check the qemu.rs module for an idea of what arguments to pass to QEMU.

      In principle, you need to replicate the file structure described above for an USB drive, then mount the directory as if it were a FAT drive.

Template

The template provides a quick way to get started building UEFI applications.