Skip to content
ajtajiPublic

About

Bare-metal mini-kernel, bootloader and recovery monitor in PureMetal. Raspberry Pi 3/4 support, with experimental UNO Q and ROCK Pi 4C ports.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

Anvil

A portable bare-metal mini-kernel, bootloader, and recovery monitor written in PureMetal.

MIT licensed · The Anvil Guide · Architecture · Portability · PureMetal Forge · Forums · Anvil forum · Issue tracker

Anvil keeps one hardware-independent monitor core and composes it with the drivers for a selected board. It remains resident while a payload runs, owns the machine's physical services, and exposes a versioned service-table ABI to payloads instead of making each payload bring a second hardware stack.

New here? Read the guide (PDF). The build, installing on a Raspberry Pi 4, the console, writing and running payloads, all four cores, replacing the monitor in place, how anything here is proven, and every command the monitor accepts. The notes under docs/ are the engineering record; the guide is the way in.

Important

Anvil is active development software for direct hardware access. It is not a finished distribution or a Vulkan-conformant implementation. Keep a known recovery path before installing a new image, and do not derive upload addresses from examples or previous builds. On the Pi, query and validate the running monitor's map response for every update.

Anvil running

Every picture below was read back off the board itself. The monitor draws its own console onto the panel it is driving; p streams the live frame over the network and shot streams a kept one, and tools/board_run.py decodes that into a PNG on every payload run. None of these is a mock-up or a desk render. See the screenshot service for how a frame is kept and for the two checks that stop a stale one passing as fresh.

A payload uploaded, verified and booted A payload arrives, is proved, and is entered. 1,578,488 bytes land at 03000000 over TCP in 174 ms — 8,856 KB/s — and the board hashes its own DRAM to show the bytes are the file's. Then the deadman is armed for 15 seconds and boot mem 3000000 shot places the payload at the address it was built for, re-checks the container's SHA-256, and enters it with the ABI 1.3 service table in x0.
The version command at EL3 version, under a table of measured public-key throughput. The monitor says which build it is, how large its own running image is, and — in its own words — why a build number is a label and the length plus a digest is the identity. The banner reads AArch64 at EL3: this board entered through the firmware stub at the highest privilege level the processor has.
The map command map — where a payload may go, and what the monitor owns. The two staging windows and every reserved region, measured from the running image rather than baked into a constant. Host tools parse this instead of carrying a staging address, which is why chapter 6 tells you never to copy an address out of a note.
The network console listening on both links The console arrives on the network by itself. Hourly group-key rekeys are serviced in passing; then the radio reports a deauthentication, one cooperative re-association fails and says so rather than going quiet, and it is retried until the link is back. The console then announces itself on UDP port 5555 on both links at once — the wired Ethernet and the Wi-Fi radio, each with its own address, neither displacing the other. Nothing was typed on the board to arrange any of it.
A frame drawn by a payload through V3D A frame the payload drew, not the monitor. Source-over blending done by the Pi's V3D through the experimental Vulkan path. The monitor copied this frame out of the way as the first thing it did after the payload returned, before printing a single character — the monitor's own report of the return would otherwise have painted over the frame being asked about.

Run it on a Raspberry Pi 4

You do not have to build anything. A compiled Pi 4 monitor package and its boot-volume skeleton are both in this repository. The current package has passed build and format checks; its exact image has not had a new hardware acceptance run:

Boards/RaspberryPi4/sdcard/
  kernel8.img            tracked Pi 4 monitor image
  armstub8.bin           required EL3 entry stub
  SHA256SUMS             check the package with one command
  config.txt             firmware settings, including armstub selection
  SETTINGS.TXT.example   optional; rename to SETTINGS.TXT
  README.md              the full card layout and first steps

The images. The card package includes both the Pi 4 monitor and the custom EL3 entry stub. The stub is required: Anvil refuses to run below EL3. Check the package hashes before copying it:

cd Boards/RaspberryPi4/sdcard && sha256sum -c SHA256SUMS

If a boot fails, type trail at the next prompt and send its output with any !! THE PREVIOUS BOOT STOPPED lines the board printed - see the card README.

The card. We recommend two partitions on an MBR medium: partition 1 of 1 GB, FAT32, for the boot set, and partition 2 taking the rest as exFAT for data — weights, voices, payloads, anything large, with no 4 GB file limit. Then settings set data.path 2:/ once, and every recipe's data:/models/... resolves there. A single FAT32 partition still works: leave data.path alone and data:/ is the root of partition 1. The exact partitioning commands for Windows, Linux and macOS are in the card README; repartitioning erases the medium.

On partition 1, put the three Raspberry Pi firmware files (start4.elf, fixup4.dat, bcm2711-rpi-4-b.dtb, which this repository does not redistribute), CONFIG.TXT, ARMSTUB8.BIN, and KERNEL8.IMG. There is no bootcode.bin on a Pi 4 — it boots its second stage from an onboard EEPROM. Names on the volume are 8.3. The skeleton README says where to get the firmware and what each file is for.

The first prompt. Wire a 3.3 V USB-to-serial adapter to header pins 6, 8 and 10 — ground, the Pi's transmit, the Pi's receive — at 115200 8N1, and leave the adapter's VCC disconnected. Power the board. The banner names the processor, the exception level and the two payload windows, and then pmf> is the prompt. Run version and map first.

The network console. The monitor listens on UDP port 5555 as soon as it holds an address, on whichever interface has one. A Pi 4 on a bare Ethernet cable into a laptop answers with nothing typed at either end — both sides take a link-local address, and the board's is seeded from its hardware address, so it is the same one across flashes.

python3 tools/anvil_wifi.py --find            # who is out there
python3 tools/anvil_wifi.py <board-ip>        # interactive console
python3 tools/board_run.py payload.pmf --console-ip <board-ip>

board_run.py is one complete run: it asks the board where to stage, streams the container, proves it landed by comparing the board's own SHA-256 of its memory against the file, arms the deadman, boots it, waits for the return value, and brings back a screenshot.

Chapter 3 of the guide, Installing on a Raspberry Pi 4, is the long version of all of this, including the EL3 stub and how to keep a way back.

Target status

Target Boot model Current status
Raspberry Pi 4 / BCM2711 / Cortex-A72 Bare-metal AArch64 image (pi4); packaged build 212, live monitor build 242 Mature target. The package selects the required custom EL3 stub. Build 242 booted on hardware with the resident Vulkan/Neon console selected before USB and storage initialization; Wi-Fi, saved TrueType settings and the command prompt were verified after reboot. The bounded V3D Vulkan path passed a current-source 15-scene exact-pixel proof. The older package image below is not build 242.
Raspberry Pi 3 / BCM2837 / Cortex-A53 Bare-metal AArch64 image (pi3, build 42) Build 42 is the current compiled artifact. Hardware evidence through Build 35 covers EL3 boot, early TrueType, saved Wi-Fi/DHCP, transfer, and a VideoCore IV offscreen clear. The new HDMI connection lifecycle has emitted-code coverage and still needs a supervised hotplug run. USB host/Ethernet and Vulkan remain unimplemented. See RaspberryPi3/README.md.
Arduino UNO Q / QCM2290 / Cortex-A53 AArch64 UEFI application (unoq, build 83) Experimental; Build 83 compiles with the shared display policy inert and is not new display or boot proof. It requires an existing UEFI environment, and current application entry is EL1, below Anvil's mandatory EL3 runtime policy. See ArduinoQ/README.md.
ROCK Pi 4C / RK3399 / Cortex-A72 + A53 Direct-SD BL3X trust image (rockpi4c, packaged build 147) Experimental hardware target. Build 147 boots Anvil from SD at EL3 with exFAT and eMMC file commands, acknowledged serial transfers and 1920×1080 HDMI. RGA2 accelerates console publication, and guarded Mali fragment jobs have drawn bounded payload images; production Vulkan/Mali rendering and networking remain unavailable. See RockPi4C/README.md.
Raspberry Pi 5 / BCM2712 Shared Anvil monitor in RaspberryPi4/Board/board.pi4 under #PMF_CHIP = 2712, with RaspberryPi5/Board/armstub8-2712.asm Anvil booted at EL3 and reached pmf> on Pi 5 hardware from the $80000 image at commit f385c7b. HDMI console, UART, caches, clock, memory and fan were observed; PCIe/RP1 failed to adopt the inbound window on that boot, so USB, storage and Ethernet were unavailable. Later driver and V3D 7.1 work is not a production Pi 5 Vulkan backend. See RaspberryPi5/README.md.

The Pi 4 HDMI DDC combined fixture currently loses its preferred timing after EDID parsing; this host-gate failure is unresolved and does not establish a hardware display failure. See the DDC fixture issue.

Host builds and emitted-code tests are valuable gates, but they are not a substitute for hardware proof. Exact status and known boundaries are recorded in the architecture guide.

Current build artifacts

These are the compiled release candidates staged by the current build pass. The hashes identify files, not hardware acceptance; see the target table above for tested behavior and limits.

Board package Artifact Build Bytes SHA-256
Boards/RaspberryPi3/sdcard/ kernel8.img 36 1,522,428 aeda023f58000d8415fbe215e53a90a489461d544d4c64507ff9e923a9600eab
Boards/RaspberryPi3/sdcard/ armstub8.bin — 512 2a3bcc7e30c3ea80ecfcf168583272a24fa7907ab05678e5e88cdb84d8449909
Boards/RaspberryPi4/sdcard/ kernel8.img 212 4,200,128 d6d40968e176aba4d69501119d5a84c0f6d221763d7fbc3c4a285721c253294f
Boards/RaspberryPi4/sdcard/ armstub8.bin — 512 9f96324d137ebb4c1452ab00477ffe8c5bf77c53a3bb80ae7fb34234d693f2a2
Boards/ArduinoQ/uefi/ anvil.efi 81 693,760 989c12292a0345895394b90841b29fcc8d0667f792d28dd7a598f689b0279a84
Boards/RockPi4C/uboot/ Image 81 244,828 ea50e18081b082eb25af06980fbeae9315c92ba8e8e29fc78643b76cff0aaab7
Boards/RockPi4C/direct-sd/ anvil.bin 147 1,671,168 6cd269ee9d428e4335d6ade43432c753360f8d856c9694aef5e27b54bceba7ed
Boards/RockPi4C/direct-sd/ trust-anvil.img 147 4,194,304 36017c6cb8889c4a1fb754d7112040c5facbc773d4765f8731d756cb854ba60b

Each package includes its own SHA256SUMS and build manifest. Pi 3 and Pi 4 ship a custom EL3 stub with the monitor. The UNO Q application and the packaged ROCK Pi U-Boot Image remain legacy experimental artifacts. The Rock Pi direct-SD package is the current EL3 hardware-accepted path; its trust image updates the fixed Anvil range on a card with the tested DDR/miniloader layout.

The Pi 3 has a hardware-proven VideoCore IV identity and offscreen clear path; its monitor has no Vulkan backend. On Pi 4, the bounded Vulkan path records ordered draws, source-over blending and dynamic scissor, executes graphics on V3D, and presents through display DMA. The current-source 15-scene Neon run on build 242 matched all 245,760 reference pixel bytes, passed 124 widget checks, and returned safely with a screenshot and the deadman off. The resident Vulkan/Neon console was also verified on a normal build-242 boot, including saved TrueType settings and Wi-Fi. See the current Pi 4 proof. This is a bounded implementation, not Vulkan conformance.

The read-only Neon atlas contract now also reserves and publishes an opaque white texel so solid boxes and glyphs share one sampled+tinted pipeline. Its exact post-refactor diagnostic build is recorded in the compatibility status and still needs the same returning Pi run once the shared board slot is free.

What is in the tree

Anvil/
  Core/                 portable monitor, boot, transfer and network policy
  Hal/                  hardware contract and payload/module ABIs
  Graphics/Vulkan/      experimental Vulkan-compatible foundation
RaspberryPi4/
  Board/                BCM2711 composition and board policy
  Lib/                  Pi drivers, display, V3D/Neon and networking
  Monitor/              source-native banner fonts and artwork
  Tests/                focused source and emitted-code probes
ArduinoQ/
  Board/                QCM2290 UEFI composition
  Lib/                  current native UNO Q drivers
RaspberryPi3/
  Board/, Boot/, Lib/   BCM2837 cold entry, serial updater, pinned boot files
RockPi4C/
  Board/, Lib/          RK3399 composition, MiniDP display and UART recovery
Boards/                  external-compiler target profile
Firmware/CYW43455/       Pi radio firmware (separately licensed)
licenses/                retained third-party license texts
docs/                    architecture, provenance, notices and formats
tools/                   build, verification and development gates

Shared code uses .pbi, Raspberry Pi 4 hardware code uses .pi4, UNO Q hardware code uses .unoq, and the Pi 3 and ROCK Pi 4C board files use .pi3 and .rockpi4c. Target-specific names do not leak into the portable HAL contract.

Build

The PureMetal application (PureMetalForge.exe, or PureMetalForge.linux on Linux) is an external dependency and is not included; it is free to download from the PureMetal Forge website. The same download also includes the ONNX compiler, ready to run in PureMetalForge\tools\onnx\; building Anvil does not need it. The editor and the compiler are one program: --compile builds from the command line with no window, and there is no separate console compiler. Python 3 is used by the repository wrapper and host checks; those scripts use only the standard library.

Put PureMetalForge on PATH, set the PMF_COMPILER environment variable, or pass it directly:

python3 tools/build.py all --compiler /path/to/PureMetalForge.exe
python3 tools/build.py pi3
python3 tools/build.py pi4
python3 tools/build.py unoq
python3 tools/build.py rockpi4c

On PowerShell, use python if that is how Python is installed:

$env:PMF_COMPILER = "C:\PureMetal\PureMetalForge.exe"
python tools/build.py all

Outputs are written under the ignored build/ directory. The wrapper pins PMF_ROOT to this checkout and stages the external compiler with this repository's board profile in a temporary directory. Missing includes therefore fail instead of being borrowed from another installation.

Target entries are RaspberryPi3/Board/board.pi3, RaspberryPi4/Board/board.pi4 and ArduinoQ/Board/board.unoq, plus RockPi4C/Board/board.rockpi4c. The normal pi3 target builds both its monitor and firmware stub; loader and updater targets are explicitly diagnostic/recovery artifacts.

Required EL3 firmware stub

The Pi 4 stub has a separate, explicit build using a compiler with --armstub support:

python3 tools/build.py armstub --compiler /path/to/PureMetalForge.exe
python3 tools/a64/a64_el3_check.py --compiler /path/to/PureMetalForge.exe
python3 tools/a64/el3_runtime_emitted_check.py --compiler /path/to/PureMetalForge.exe

This produces build/pi4/armstub8.bin. It is selected by the released Pi 4 card configuration and required because stock-stub EL2 is refused. It is not part of all. Build 98 and the checked stub passed a witnessed physical power cycle on Pi 4: EL3 entry, the secure timer, controlled fault, USB/storage and DMA/V3D display all passed. The final cleanup build 99 then passed EL3, one 16-round run on all three secondary cores, stop acknowledgements and the same peripheral checks after deployment. Build 99 then passed its exact physical cold-power-cycle run, including cold leases, touch and Wi-Fi. Exact historical artifacts and hardware boundaries are recorded in docs/EL3_BOOT_ACCEPTANCE.md. The stub retains its upstream BSD-3-Clause notice.

Live time and returning applications

The common wall clock supports UTC, named U.S. Central time with daylight-saving rules, and fixed offsets. On a network-capable board, synchronization runs as bounded background work; an unreachable time server does not hold the prompt. An unset clock or saved time floor is visibly unsynchronized, never presented as a running battery-backed RTC.

time
time sync
time zone America/Chicago
settings save

time sync is available only with a network backend. UNO Q currently supports the common manual clock and zone commands, not network synchronization. See wall-clock commands and trust boundaries.

The panel/touch boot trace explains touch trace, which reads retained failure evidence without initiating another hardware probe.

Returning applications have an explicit hardware ownership and Ethernet recovery contract. The monitor stops active Ethernet DMA before entry and rebuilds the previously active controller after return without erasing another interface or an unexpired lease. These new service paths have desk gates; their remaining silicon checks are documented separately from a completion claim.

Boot and runtime assets

  • The Pi build produces build/pi4/anvil.img, a raw bare-metal image. Vendor boot firmware, a complete boot partition, and board-specific display configuration are intentionally not bundled.

  • The UNO Q build produces build/unoq/anvil.img. Wrap it as an AArch64 UEFI executable when needed:

    python3 tools/unoq_efi_wrap.py build/unoq/anvil.img build/unoq/anvil.efi --load-addr 0x70000000
  • Pi 4 Wi-Fi requires the two CYW43455 binaries under Firmware/CYW43455/ plus a board-appropriate NVRAM file that is deliberately not bundled. See the licensing and asset guide for boot-media names and redistribution conditions.

Verification

Before staging a release candidate, verify the complete non-ignored working tree:

python3 tools/verify_export.py --working-tree

After selecting files with Git, verify the exact tracked public set:

python3 tools/verify_export.py

The verifier checks repository boundaries, required notices, source include closures, and whether every dependency of both board entries is part of the selected public tree. Git is the content-addressed manifest for the current tree; PROVENANCE.json separately preserves the original migration mapping.

Focused development gates live under tools/, RaspberryPi4/Tests/, and Anvil/Graphics/Vulkan/Tests/. Emitted AArch64 gates require the external compiler and an interpreter supplied through PMF_A64_INTERP or the documented repository-local path. The module gate, for example, is:

python3 tools/module_engine_check.py

The interpreter's lazy floating-point dependency has its own isolated host gate, so a private installation cannot hide a missing exported helper:

python3 tools/a64/interpreter_dependency_check.py

The matching differential diagnostic sources are under RaspberryPi4/Examples/Diagnostics/. They are not installed or run by a normal build. Follow their hardware-state and recovery prerequisites before any on-board use.

Deliberately incomplete work

  • Driver modules: PMFMOD v1 validation, relocation, and transactional arena records exist and have executable tests. Neither board activates the engine yet; discovery, loading, service binding, and safe reload are not present.
  • Vulkan compatibility: the tree contains a pinned core-1.0 vocabulary slice and a bounded Pi 4 V3D physical device used by the resident console. The Pi 3, ROCK Pi 4C, UNO Q and Pi 5 monitor paths have no production Vulkan hardware backend, although Pi 5 V3D 7.1 TFU/CSD components have desk gates. Complete Vulkan 1.0 behavior, general SPIR-V, WSI, fault recovery and CTS remain on the roadmap.
  • Current Pi integration: lossless high-volume console modeling, rotated capture, banner activity, touch, and ongoing network changes must pass an integrated hardware run before they are described as released behavior.

See the module format, Vulkan coverage, and the Vulkan roadmap for exact boundaries. The compatibility inventory maps the implemented layers, missing prerequisites, and next resource-backed transfer slice without claiming a production Vulkan device.

Safety and support

Anvil can read and write physical memory and can replace a running monitor. Treat images and addresses as build-specific. The Pi image measures its live extent, guards monitor-owned memory, and reports the next staging window at runtime; host tools should refuse an update when that report cannot be validated unless an operator supplies an independently checked override.

Use the GitHub issue tracker for reproducible defects and the PureMetal forum for design and hardware discussion. Include the target, source revision, build command, and a redacted transcript. Never post credentials, NVRAM calibration, private keys, or machine-specific paths.

License

Original Anvil source and documentation are available under the MIT License. Third-party material is not relicensed. This includes CYW43455 firmware (redistributed under its own terms), vocabulary taken from the Khronos Vulkan Registry, and glyph tables generated from DejaVu faces. The cryptography is original code; BearSSL was read for its constant-time designs and its licence text is kept as an acknowledgment. See the licensing guide and third-party map.

About

Bare-metal mini-kernel, bootloader and recovery monitor in PureMetal. Raspberry Pi 3/4 support, with experimental UNO Q and ROCK Pi 4C ports.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages