Native seL4/Microkit firmware for NanoPi R5S

A router that runson seL4, not Linux.

A standalone non-Linux router: DHCP-configured native WAN, two independently routed RTL8125 LANs (10.44.1.0/24, 10.44.2.0/24), endpoint-preserving NAPT, and fixed stateful forwarding.

~440 Mbps
Download
~385 Mbps
Upload
1024
Zero-copy DMA buffers, 2 KiB each
  • WAN uplink

    • One 1 GbE uplink
    • Address from upstream DHCP
    • Hardware TSO and checksums
  • Zero-copy pool

    • 1024 × 2 KiB packet buffers
    • 16-byte Refs, never payloads
    • Strict single-owner handoff
  • NAT workers

    Hot path
    • Endpoint-preserving NAPT
    • One flow pinned to one core
    • Frames prepared on that core
  • Dispatcher & control

    • DHCP, ARP, bridge learning
    • Copy fallback when a lane fills
  • LAN 1 + LAN 2

    • Two 2.5 GbE client ports
    • 10.44.1.x and 10.44.2.x
    • GRO at the edge

Download

Two images of the same firmware and the tool archive the flash steps use. Run production, diagnose with debug. Check the SHA-256 after downloading.

Production96 MiB

Quiet firmware, release SDK. The image to run.

r5s-rtl8125-lan-repair.img

734920599454fff1c447821ce594be0fbd3d14dc6de2312e67fb18ba45a65a1d
Download

Debug96 MiB

Firmware logging, status endpoint, LED fault codes. The image to diagnose with.

r5s-rtl8125-lan-repair-debug.img

93a9c30bb655b720a91d2b0b81fef1404fd7f2025c9c17c21bc245cafc9a28e5
Download

Tools412 KiB

Image verification and guarded flashing utilities. Needed for the flash steps.

tools.tar.gz

4877c1e93b561e51ea65d9b6f1ea3fe381a75a8b4b487c91072146adfacea280
Download

Verify what you downloaded

Keep the files in one folder together with the SHA256SUMS list from this page:

sha256sum -c --ignore-missing SHA256SUMS

Flash the SD card

The firmware runs from an SD card. Whatever Linux your R5S currently runs (usually on its eMMC) stays untouched and remains available as recovery. The steps below copy the image into the device’s Linux, verify it there, and write it to the SD card. Afterwards the board boots the firmware from the card.

01

Stage the downloads, then copy them to the R5S

Run on your own Linux machine, in the folder where you downloaded the image, tools.tar.gz and SHA256SUMS. Replace 10.0.1.81 with your R5S’s LAN address. For the debug image, set IMAGE to the debug filename.

IMAGE="r5s-rtl8125-lan-repair.img"
STAGE=/tmp/r5s-wan-fastpath

mkdir -p "$STAGE"

cp "$IMAGE" tools.tar.gz SHA256SUMS "$STAGE/"

ssh [email protected] \
  'mkdir -p /dev/shm/r5s-wan-fastpath'

scp "$STAGE/"* \
  [email protected]:/dev/shm/r5s-wan-fastpath/
02

On the R5S: check the copies and verify the image

Log into the device’s Linux and run the checks. Nothing is written to any disk in this step.

ssh [email protected]
cd /dev/shm/r5s-wan-fastpath

export TMPDIR="$PWD"

sha256sum -c --ignore-missing SHA256SUMS &&
tar -xzf tools.tar.gz &&
python3 scripts/verify-image r5s-rtl8125-lan-repair.img
03

Identify the SD card

Still on the R5S. Check which block device is the card you want to write, and read its identity. The name becomes SD_MODEL, the CID becomes SD_CID, and the size in bytes becomes SD_BYTES.

findmnt /

lsblk -b -o NAME,PATH,TYPE,SIZE,MODEL,MOUNTPOINTS

cat /sys/class/block/mmcblk0/device/type
cat /sys/class/block/mmcblk0/device/name
cat /sys/class/block/mmcblk0/device/cid

blockdev --getsize64 /dev/mmcblk0
04

Write the SD card

Set the SD_* guards to the values you just read. The ones below are one working example. The first command is a dry run; the second, with --execute, writes the card.

export SD_DEVICE=/dev/mmcblk0
export SD_MODEL=NCard
export SD_CID=8903034e43617264100d3aa313016c07
export SD_BYTES=62534975488

export IMAGE=r5s-rtl8125-lan-repair.img
python3 scripts/flash-sd \
  --profile r5s \
  --device "${SD_DEVICE:?}" \
  --image "${IMAGE:?}" \
  --expect-model "${SD_MODEL:?}" \
  --expect-serial "${SD_CID:?}" \
  --expect-bytes "${SD_BYTES:?}"

python3 scripts/flash-sd \
  --profile r5s \
  --device "${SD_DEVICE:?}" \
  --image "${IMAGE:?}" \
  --expect-model "${SD_MODEL:?}" \
  --expect-serial "${SD_CID:?}" \
  --expect-bytes "${SD_BYTES:?}" \
  --execute

If you flashed the debug image

It adds firmware logging, full LED fault codes, the port-5201 TSO test generator and a read-only status endpoint on port 48125. Ask it for a full JSON report:

python3 scripts/read-b51-udp <router-ip>

Measure throughput on the production image. The debug SDK and logging cost real cycles.

Architecture

A seL4/Microkit system of eleven protection domains on four Cortex-A55 cores. Payloads never move between them: a shared zero-copy DMA pool hands off 16-byte references. Budgets are microseconds per 1 ms.

PDCoreµs / 1 msRole
gmac1710GMAC0 rings, TSO, checksum offload
heartbeat1200supervisor, SYS LED
health190health monitor
logical_lan0330dispatcher, bridge, DHCP, fallback
wan0130DHCP client, ARP, echo
forward00260NAT worker
forward10220NAT worker
lan12650RTL8125 rings, GRO
forward22300NAT worker (LAN 1)
lan23650RTL8125 rings, GRO
forward33300NAT worker (LAN 2)
download   gmac RX → worker (NAT + frame prep) → lanX TX → client
upload     client → lanX RX → worker (NAT + frame prep) → gmac TX
control    wan app ⇄ logical_lan   (DHCP · ARP · bridge · copy fallback)

Performance

Board-tested h4 build, operator-measured on real hardware with manual iperf3 runs, not lab-certified. Both flavors carry the same datapath tuning.

~440
Mbps download
~385
Mbps upload
1024
2 KiB zero-copy DMA buffers
h4-productionquiet firmware, release SDK, no status endpoint, no test generator, no fault-code LED patterns
h4-debugdebug SDK, firmware logging, status JSON on port 48125, port-5201 test generator, LED fault codes