UEFI firmware
The UEFI firmware port comes from Mu-Silicium. It supplies the services UniXNU and DarwinBoot use.
For repeated builds, save paths in unixnu.local.toml. After changing boot arguments, rebuild the payload and boot image using the argument workflow. Follow the green-bar diagnosis for a stall at loader handoff.
Procedure
- Prepare the device's Mu-Silicium checkout, vendor inputs and submodules. Match
board.tomlto its device configuration, DSC and FD path. - Complete required integration: add each module to the DSC/FDF and map its libraries. The payload needs its RAM-disk, DiskIo and FAT drivers.
- Save the firmware path in local build configuration and run the firmware build. Confirm the output FD path and size.
- Build the payload, then follow boot-image integration. Check
boot/boot.jsonand the packaged payload before booting. - On the device, confirm the configured menu entry and DarwinBoot handoff using verification. If the entry is absent, work through payload discovery.
CLANGPDB requires matching Clang and LLD releases. CLANG_BIN must contain executable clang, lld-link, llvm-lib and llvm-rc. The firmware toolchain is checked before other requested build stages.
Required integration
Build firmware from the UniXNU checkout after selecting the device:
./unixnu defconfig <device>_defconfig -D ../UniXNU-<device>
./unixnu build firmware --uefi ../uefi-<device>The firmware needs all of these modules in its DSC [Components] and FDF firmware volume:
| Module | Purpose |
|---|---|
UniXNUPkg/Application/UniXNU/UniXNU.inf | Boot menu and configuration reader |
UniXNUPkg/Driver/UniXNUDxe/UniXNUDxe.inf | Firmware boot option registration |
DarwinBootPkg/Driver/DarwinBoot.inf | XNU loader |
UniXNUPkg/Driver/UniXNURamDiskDxe/UniXNURamDiskDxe.inf | Publish the Mu-Silicium FDT initrd as a read-only block device |
MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf | Disk access for the filesystem driver |
FatPkg/EnhancedFatDxe/Fat.inf | Expose the payload's FAT filesystem |
List each path directly under DSC [Components]; use INF <path> in the FDF. Map the shared driver's libraries in DSC [LibraryClasses]:
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
FdtLib|MdePkg/Library/BaseFdtLib/BaseFdtLib.infAdd PartitionDxe when the payload uses a partition table. The FAT driver also needs the platform's Unicode collation service. The reference firmware's Include/DXE.inc contains these dependencies.
UniXNURamDiskDxe is shared by devices using Mu-Silicium's FDT handoff. Its source is in UniXNU's package/UniXNUPkg/Driver/UniXNURamDiskDxe/. Board memory reservations and memory expansion remain in the firmware platform.
A supplied .fd must contain this integration and match the board's firmware base and size. ./unixnu bootimg --fd <file> packages the supplied firmware. Rebuild the FD after changing its DSC, FDF or drivers.
Build the payload with the selected device's inputs, then pack the image:
./unixnu build payload --unique-chip-id <hex> --trust-cache <file> --data-ramdisk <seed>
./unixnu bootimg --uefi ../uefi-<device> --dtb /path/to/firmware.dtbUse the options required by the device's payload profile. See payload inputs.
Firmware logs
Follow log exporter integration to add Advanced Logger and AdvancedLogDxe, then enable the Tools menu. Use QR capture to save firmware output before storage adaptation and kernel handoff.
Payload discovery
The Android bootloader places the FAT payload in RAM and writes /chosen/linux,initrd-start and linux,initrd-end into the firmware FDT. Each property is a 32-bit or 64-bit big-endian address. The range must contain complete 512-byte sectors and remain reserved while UEFI uses it.
Mu-Silicium SEC preserves the incoming FDT address as a UINT64 in the entry-argument HOB (DAEE82E6-8090-4E72-BFB9-78C13CD4E359). UniXNURamDiskDxe reads this handoff and publishes Block I/O. DiskIoDxe and the FAT driver expose EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, allowing UniXNU to read \EFI\UniXNU\unixnu.toml and list its entries.
If the menu appears without the configured entries, check:
boot/boot.jsonreports a nonzeroramdisk_bytesvalue.- The FD contains
UniXNURamDiskDxe, DiskIoDxe and the FAT driver. - The firmware FDT has valid initrd start and end properties.
- The serial log contains
UNIXNURAMDISK: initrd block devicewith a successful status. - The payload FAT volume contains
EFI/UniXNU/unixnu.tomland its referenced files.
The RAM disk driver must be embedded in the firmware so the payload can be discovered before its configuration is read.
Required services
| Service | Consumer |
|---|---|
EFI_GRAPHICS_OUTPUT_PROTOCOL | UniXNU menu, DarwinBoot framebuffer handoff, XNU console |
EFI_SIMPLE_TEXT_IN_PROTOCOL | UniXNU menu input |
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL | Configuration, payload and kernel files |
EFI_BLOCK_IO_PROTOCOL | Userdata partition and block slices |
EFI_SERIAL_IO_PROTOCOL | Logs on boards with a UART |
EFI_ACPI_TABLE_PROTOCOL | Optional ACPI table injection |
EFI_FIRMWARE_VOLUME2_PROTOCOL | UniXNUDxe boot option registration |
A board that lacks one of these services limits the stages it can run. Add the driver to the firmware volume or to the UniXNU payload before the dependent stage.
Mu-Silicium layout
Mu-Silicium/
BootShim/
BootShim.S
Resources/
Configs/<device>.toml
Scripts/mkbootimg.py
Platforms/<Vendor>/<device>Pkg/
<device>.dsc
<device>.fdf
Silicon/
Common/The UniXNU driver reads Resources/Configs/<name>.toml and <device>.dsc. It uses Resources/Scripts/mkbootimg.py for the boot image.
Device configuration
Resources/Configs/<device>.toml supplies the addresses and image parameters:
[boot_shim]
requires_kernel_header = true
[uefi_fd]
base = 0x00000000
size = 0x000000
[boot_image_kernel]
kernel_compression = "gzip"
append_dtb = true
[boot_image]
header_version = 0
base = 0x00000000
kernel_offset = 0x8000
tags_offset = 0x1e00000
pagesize = 4096| Key | Meaning |
|---|---|
boot_shim.requires_kernel_header | The bootloader checks the ARM64 header at the start of the image |
uefi_fd.base | Physical address where the firmware volume is loaded |
uefi_fd.size | Exact firmware volume size |
boot_image_kernel.kernel_compression | Compression of the shim and firmware volume |
boot_image_kernel.append_dtb | Append the device tree to the kernel field |
boot_image.* | Android boot image header parameters |
The firmware base and size are compiled into BootShim. They are also checked when the boot image is packed.
DSC and FDF
The DSC lists the packages, libraries and components. The FDF places the components in the firmware volume.
UniXNU packages use PACKAGES_PATH:
{uefi}:{tree}/package:{tree}/drivers/DarwinBoot:{edk2}:...{uefi} is the Mu-Silicium checkout, {tree} is the assembled build tree, and {edk2} is the Mu_Basecore checkout. The board file lists every package path.
UniXNU and DarwinBoot are included through their INFs:
UniXNUPkg/Application/UniXNU/UniXNU.inf
UniXNUPkg/Driver/UniXNUDxe/UniXNUDxe.inf
UniXNUPkg/Driver/UniXNURamDiskDxe/UniXNURamDiskDxe.inf
DarwinBootPkg/Driver/DarwinBoot.infEmbed these modules in the firmware volume for an initrd payload. Place the configuration and kernel files in the payload FAT volume.
Preflight
[firmware] preflight lists scripts in the build tree that run before the EDK II build. A preflight script checks vendor inputs, firmware partitions or board files. --skip-preflight skips them.
Vendor inputs
A Mu-Silicium port needs the vendor binaries for the board, for example:
- UEFI DXE drivers for storage, display, input or power.
- ACPI tables.
- Firmware partition images.
- Configuration data.
The board preflight script validates the files and their hashes.
Submodules and patches
Mu-Silicium uses submodules for shared trees. The board file lists the ones it needs:
[firmware]
submodules = ["Common/Mu", "Silicon/Silicium", "Silicon/Qualcomm"]
patches = ["Resources/MuPatches/Gic-Spurious.patch"]A patch in patches is applied to the shared edk2 tree for the build and reverted afterwards. The driver checks each patch with git apply --check before applying it.
Build
With the device repository selected:
./unixnu build firmware --uefi /path/to/Mu-SiliciumThe driver:
- Runs the preflight scripts.
- Initializes the listed submodules.
- Builds BaseTools when
GenFwis absent. - Applies the board patches.
- Runs EDK II
buildwith the DSC,AARCH64,CLANGPDBand the board defines. - Reverts the patches.
- Checks the firmware volume size and path.
The output path comes from [firmware] fd:
fd = "Build/<device>Pkg/{target}_CLANGPDB/FV/SILICIUM_UEFI.fd"For boards selecting bootimg.image.ramdisk_compression = "uefi-chunks", bootimg encodes the FAT in independent 1 MiB UEFI-compressed chunks. The matching UniXNURamDiskDxe reads this format with a 1 MiB cache. ramdisk_max_bytes limits the encoded transfer; boot.json records both the encoding and logical FAT size.
sheng watchdog handoff
The sheng profile selects SHENG_BOOT_GUARD=1. Its preflight imports the device's BootResetCore.h into the firmware checkout. SEC verifies the PMIC bootloader reboot reason and arms Gunyah's 30000 ms watchdog. DXE pings every two seconds for a 180-second firmware budget; ExitBootServices sends the final firmware ping.
The matching XNU kernel uses uefi-watchdog=1 and takes over at EARLY_BOOT, pinging every ten seconds. autoreset=<seconds> bounds the run; a zero deadline keeps the watchdog serviced. Keep the firmware and kernel configuration together. The sheng lab builds COFF firmware with LLVM and LLD 22.1.8. CLANG_BIN points to a directory containing that toolchain's clang, lld-link, llvm-lib and llvm-rc.
From the UniXNU checkout, prepare that directory:
brew install llvm@22 lld@22
mkdir -p .cache/edk2-llvm22
for edk2_tool in clang llvm-lib llvm-rc; do
ln -sf "$(brew --prefix llvm@22)/bin/$edk2_tool" ".cache/edk2-llvm22/$edk2_tool"
done
ln -sf "$(brew --prefix lld@22)/bin/lld-link" .cache/edk2-llvm22/lld-linkSet clang_bin = ".cache/edk2-llvm22" in unixnu.local.toml.
To qualify the early return path, pack a known header-v0 XNU image with the selected firmware and a kernel-entry wait:
python3 ../UniXNU-sheng/scripts/prepare-sheng-watchdog-probe.py \
/path/to/known-boot.img /path/to/watchdog-probe.img \
--uefi ../uefi-sheng --fd /path/to/SILICIUM_UEFI.fd \
--dtb /path/to/sheng.dtb
fastboot -s SERIAL boot /path/to/watchdog-probe.imgThe probe waits before EARLY_BOOT and has a 120-second PSCI reset fallback. With firmware fb2b2ae1, fastboot returned 70.503 seconds after the boot command, before that fallback. The elapsed time includes firmware startup; the configured hardware timeout is 30 seconds.
The inherited kernel path pings the already running firmware timer and starts its service thread. patch-sheng-inherited-watchdog.py INPUT OUTPUT --kernel-args "uefi-watchdog=1" qualifies that path on an existing source-built kernel with the matching instruction sequence; boot the result with the inherited-watchdog profile.
External firmware builds
A firmware supplied with ./unixnu bootimg --fd <file> needs the same DSC/FDF modules, package paths, board defines and EDK II patches as the selected [firmware] configuration. Check the required integration and use the matching board configuration when packing the image.
Boot image integration
unixnu bootimg compiles BootShim with the firmware base and size:
clang --target=aarch64-none-elf -c \
-DFD_BASE=<base> -DFD_SIZE=<size> \
-DREQUIRES_KERNEL_HEADER=<0 or 1> \
BootShim/BootShim.S -o shim.oIt appends the firmware volume, compresses the pair with gzip, appends the device tree and packs the Android boot image.
Verification
| Check | Method |
|---|---|
| Firmware volume size | The driver compares the output size with [uefi_fd] size |
| Shim header | The driver checks ARM\x64 and the base and size fields |
| Boot image parts | The driver unpacks the image and compares every part |
| Menu | The serial log contains UNIXNU: lines |
| Payload | The menu lists the xnu entry and DarwinBoot logs the handoff |
Adding a UEFI driver
A driver can live in the firmware volume or in the payload.
| Location | Build | Load |
|---|---|---|
| Firmware volume | Add the INF to the DSC and FDF | Firmware dispatches it, or UniXNUDxe starts the application |
| Payload | Build a standalone .efi | [[driver]] in unixnu.toml or a kit |
See Develop a driver for the load options.