Build and host testsDraft
This page builds the boot image and runs the tests that need no hardware. Install the software on Prerequisites first.
First build recipe#
Work from a git clone of the repository, not from a tarball: the build
embeds git describe --tags --always --dirty, and the UEFI firmware needs the
uefi/edk2 submodule. Then, from the repository root:
python3 -m venv ~/venv-openboot
~/venv-openboot/bin/pip install cairosvg pillow fonttools pytest pyserial
export PATH=~/venv-openboot/bin:$PATH
rustup target add aarch64-unknown-none-softfloat
make -C openboot -j"$(nproc)" USE_CLANG=1 MTFW_NONE=1 build/openboot.bin
The makefiles run python3 -I, so the packages must be installed in the first
python3 on PATH, which the export does. The other tools are listed on
Prerequisites.
The trackpad firmware is not part of the repository. The build needs one of
two things: MTFW_NONE=1, which links an empty firmware (the image has no
trackpad; the keyboard still works), or MTFW_PLIST=<path>, the path of the
trackpad firmware file taken from your own machine. Without either, the build
stops with the message mtfw: no trackpad firmware plist at ....
The output is openboot/build/openboot.bin. The production image needs
no diagnostic flags. The makefile runs its own checks as part of the build,
including a check that the linked image keeps its fixed layout; a failing
check stops the build.
Options worth knowing:
| Variable | Effect |
|---|---|
USE_CLANG=1 |
builds with Clang and LLD; on macOS this is the default |
CHAINLOADING=1 |
additionally enables loading a chainload image from NVMe |
OB_STANDALONE=1 |
the image reads the boot menu settings from NVRAM; it needs the NVMe mediator or the native ANS path to be enabled |
OB_SETTINGS_WRITE=1 |
lets the settings writer store OpenBoot's own ob- variables; with 0 (the default) nothing is written |
MTFW_NONE=1 |
builds without the trackpad firmware; the keyboard still works. Forced by OB_PROFILE=release, which also refuses MTFW_PLIST (the release image takes the firmware from the install slot) |
MTFW_PLIST=<path> |
the trackpad firmware file, taken from your own machine, from which the build generates the firmware blob |
The build embeds the output of git describe --tags --always --dirty, so
rebuild after your final commit if you want the image to identify its exact
source state. The firmware is never part of the repository.
The Makefile has further options for individual subsystems. They are documented in the makefile itself and are not needed for a first build.
Run the host tests#
Host tests exercise the production code with bounded fake devices. They do not prove that anything works on hardware.
python3 -m pytest -q tests/ui_host
make -C tests/dbg_host -j"$(nproc)" test
python3 efi/tests/test_xhci.py
python3 efi/tests/test_usb_msc.py
| Command | Covers |
|---|---|
tests/ui_host |
the boot menu and user interface model, rendering and assets |
tests/dbg_host |
the debug monitor, the descriptor table and layout code, settings, NVMe mediation and many EL2 helpers, built as one test program per group |
efi/tests |
the filesystem and USB mass-storage readers and the xHCI model |
make -C tests/dbg_host test needs no trackpad firmware and no extra flags:
when the firmware plist is absent it builds its images with MTFW_NONE=1
itself. Checks that compare against a finished firmware build (SKIP ...: no firmware build lines) are skipped until you have built openboot.bin. The
tests need clang; gdb-multiarch and lldb are optional and their checks
are skipped when missing. The UI tests need the Python packages of the recipe
above in the python3 you run them with.
Other test directories exist under tests/, one per subsystem; run the
make or pytest target of the directory you changed.
The FAT32, exFAT, NTFS and boot media tests build their disk images with
independent tools (exfatprogs, ntfs-3g, dosfstools, mtools). These
tools run only on the development machine and are never linked into the
product. A helper downloads them without root access:
efi/tests/fetch_fs_tools.sh /tmp/openboot/fstools
export OPENBOOT_FSTOOLS=/tmp/openboot/fstools
python3 efi/tests/test_fat32.py
Check the device descriptors#
python3 -I tools/devgen/devgen.py --devices devices --check
python3 -I -m unittest discover -s tools/devgen/tests -q
Build the UEFI firmware#
The UEFI part builds from EDK II, which is a submodule:
git submodule update --init uefi/edk2
./uefi/build.sh
The default output is Build/OpenBoot-AArch64/RELEASE_CLANGDWARF/FV/OPENBOOT.fd.
The script supports BUILD_TARGET=DEBUG, JOBS=N (parallel jobs of the
EDK II BaseTools build) and EDK2_TOOLCHAIN=GCC.
It needs the toolchain that EDK II supports and Python 3. This step was
not run for this page.
Run on hardware (advanced, needs a host computer)#
Running an image on a target machine needs a second computer (the host) on the target's debug USB port and a boot object installed on the target. A freshly built image can be loaded into RAM for one run without replacing the installed boot volume: the host pushes the image over the OBLink link and starts it with the monitor's sideload command, and the target runs it until the next reboot. The steps are in OBLink bring-up. They are not covered by the host tests. Installing a boot object changes the boot configuration of the machine: this documentation does not give an install procedure, so do not do it on a machine whose data you cannot lose. Hardware claims on these pages follow the Hardware facts policy; for how a hardware run is made and judged see Hardware runs.
Building the documentation#
These pages are built from docs-src/ with the scripts in tools/docs/.
Install the pinned dependencies of tools/docs/requirements.txt first, then
run from the repository root:
python3 -I tools/docs/gen_ref.py --check
python3 tools/docs/build.py --src docs-src --out site
python3 tools/docs/gates.py --site site --facts-root .
The first command checks that the generated pages (the device pages, the
status pages, the hardware blocks page) are current; without --check it
rewrites them. The second writes the site. The third runs the checks that
every published number has a source and that generic pages stay neutral. The
format of a page is in tools/docs/CONTRACT.md.
What was verified#
The descriptor checks and the tests/dbg_host suite were run on a Linux
host with the Python packages of the recipe in a clean virtual environment,
on a tree without a trackpad firmware file, and passed. tests/ui_host
passed in full in that environment; without fonttools installed in the
python3 that runs it, the test that compares the generated 5x7 font header with
a fresh render fails. The image build was run with MTFW_NONE=1. The UEFI
build, the filesystem test tools and the other efi tests were not run for this
page. The page stays a draft until a clean-machine run confirms them.