Mono Gateway OPNsense board support + aarch64 release/mirror tooling (fork of we-are-mono/opnsense-deps)
Find a file
Jeremy Karst f34695776d gwmirror: verify pkg 2.8 catalogues and the major upgrade's set
- pkg 2.8 (26.7) writes a package's catalogue checksum as "2$" and its
  BLAKE2b-512 in pkg's base32; accept it next to pkg 2.3's SHA-256 hex
  and check each against its own digest, read once for both. Latest/
  signatures stay over the SHA-256: a BLAKE2b catalogue checks them when
  deep, and only their key when shallow, as for the sets.
- TarSource members share the set's file object, which every read
  seeks, and verify_repo reads them from eight threads: the 26.7.9
  upgrade set failed at random packages. Reads now take turns.
- Report the upgrade set's results under its path, not ".".
- Clean up the trust objects' temporary directories.

Tests: the root and URL verify tests run again with BLAKE2b catalogues,
a pkg 2.8.4 checksum pins the encoding, and the upgrade set gets its
own tests (parallel reads of large packages, a tampered package in a
signed set, a bad .abi_hint).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-27 16:33:59 -05:00
config Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel 2026-11-23 19:26:41 -05:00
dist Hello world. 2026-02-25 15:13:46 +01:00
drivers Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel 2026-11-23 19:26:41 -05:00
fastpath Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel 2026-11-23 19:26:41 -05:00
keys core patches: sign and serve from opnsense.karsttech.com 2026-11-17 18:56:54 -05:00
LICENSES add LICENSING.md and LICENSES/ for mixed-license clarity 2026-03-29 17:16:26 +02:00
mirror gwmirror: verify pkg 2.8 catalogues and the major upgrade's set 2026-11-27 16:33:59 -05:00
patches/26.7 Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel 2026-11-23 19:26:41 -05:00
pkg board package: build per series, harden kernel install for U-Boot 2026-11-17 18:56:54 -05:00
plugins/hwmon/src/opnsense Add hwmon dashboard widget and fix EMC2302 fan stall detection 2026-03-03 02:02:49 +01:00
rc.d Turn hardware flow offload off; drop the Mono copyright line 2026-11-22 21:12:19 -05:00
release build.sh: fail early on a kernel set without kernel.bin 2026-11-27 15:20:05 -05:00
tools build: use minimal 4-entry GPT to reserve firmware region on eMMC 2026-03-27 23:06:02 +01:00
.gitignore Untrack the mwifiex build symlinks 2026-11-22 19:45:45 -05:00
ARCHITECTURE.md pf_notify/cmm: remove polling fallback, fix one-shot ordering bug 2026-03-24 16:34:41 +01:00
CMM.md CDX: fix MC4/MC6 reset commands, build and doc improvements 2026-03-14 00:39:52 +01:00
LICENSING.md add LICENSING.md and LICENSES/ for mixed-license clarity 2026-03-29 17:16:26 +02:00
Makefile Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel 2026-11-23 19:26:41 -05:00
mk-image.sh Drop the cross-build leftovers, pilot and migrate-device.sh 2026-11-22 20:41:11 -05:00
README.md Build 26.7 for FreeBSD 15 only; port caam and cdx to its kernel 2026-11-23 19:26:41 -05:00
RELEASE.md gwmirror: verify pkg 2.8 catalogues and the major upgrade's set 2026-11-27 16:33:59 -05:00

Mono Gateway custom components for OPNsense

This is the Karst Tech fork of we-are-mono/opnsense-deps. The vendor no longer maintains OPNsense for the gateway and its update mirror opnsense.mono.si is gone. This fork builds, signs and publishes the complete aarch64 OPNsense release (base, kernel, packages, image) at https://opnsense.karsttech.com. How that works, and how to build, publish and migrate a gateway, is in RELEASE.md.

Out-of-tree kernel modules, userspace daemons, and build tooling for the Mono Gateway OPNsense image. Contains the DPAA1 fast-path stack (CDX flow offload, FCI, CMM connection manager, PF notifier, auto-bridge), board-support drivers (LP5812 LED, EMC2302 fan, INA2xx power, SFP LED, PCF2131 RTC, TMP431 thermal, CAAM crypto), WiFi support (NXP 88W9098 PCIe driver + DPAA OH port bridge), FMan toolchain (fmlib, fmc, dpa_app), and helper scripts for kernel image creation and deployment.

Repository layout

opnsense-deps/
├── drivers/              # out-of-tree kernel modules
│   ├── caam/             # NXP CAAM crypto accelerator (JR + QI)
│   ├── dpaa_wifi/        # WiFi ↔ FMan OH port data plane bridge
│   ├── emc2302/          # SMSC EMC2302 fan controller
│   ├── fand/             # Fan control daemon (userspace)
│   ├── ina2xx/           # TI INA2xx power monitor
│   ├── lp5812/           # TI LP5812 LED controller
│   ├── mwifiex/          # NXP 88W9098 PCIe WiFi driver + firmware
│   ├── pcf2131/          # NXP PCF2131 RTC
│   ├── sfp-led/          # SFP+ link status LED
│   └── tmp431/           # TI TMP431 thermal sensor
├── fastpath/             # DPAA1 fast-path modules + userspace
│   ├── cdx/              # CDX flow offload kernel module
│   ├── fci/              # Fast-path Control Interface module
│   ├── auto_bridge/      # Auto-bridge kernel module
│   ├── pf_notify/        # PF state change notifier module
│   ├── fmlib/            # FMan userspace library
│   ├── fmc/              # FMan Configuration tool
│   ├── dpa_app/          # DPAA application (PCD setup)
│   ├── cmm/              # Connection Manager daemon
│   └── cmmctl/           # CMM control utility
├── config/               # FMC/CDX XML configuration files, GATEWAY device config
├── rc.d/                 # rc.d service scripts and syshook scripts
├── pkg/                  # FreeBSD package metadata
├── patches/<series>/     # opnsense/core patches (mirror, signing key, CMM restart)
├── keys/                 # mirror public key and trusted/revoked fingerprints
├── release/              # build VM, release build, device migration (+ tests)
├── mirror/               # gwmirror.py stage/verify/publish, nginx container (+ tests)
├── mk-image.sh, tools/   # ZFS eMMC image builder used by the release build
├── _vendor/              # NXP vendor repos (cloned at build time, gitignored)
└── Makefile              # top-level build (modules + userspace + package)

Network interface mapping

The FMan MAC numbering in the device tree does not match the physical port order on the board. This is a cosmetic mismatch in the PCB routing — it has no effect on performance or functionality.

Physical position (left → right) Interface Speed
Port 1 dtsec1 1 GbE
Port 2 dtsec2 1 GbE
Port 3 dtsec0 1 GbE
Port 4 dtsec3 10 GbE SFP+
Port 5 dtsec4 10 GbE SFP+

Build instructions

The whole release, not just this package, has to be built for aarch64: upstream OPNsense publishes no aarch64 packages at all. release/build.sh drives opnsense/tools through base, kernel, ports, plugins and core, builds the mono-gateway package from this repository against the new kernel, signs everything and builds the eMMC image. It runs on an aarch64 FreeBSD host of the series' release (15.1 for 26.7): the emulated arm64 VM that release/vm.sh runs on a Linux build host, or a native aarch64 machine. See RELEASE.md.

To build only the board package on such a host after a release build:

sudo make -C /usr/deps -j$(sysctl -n hw.ncpu) package OPS_SETTINGS=26.7 OPS_VERSION=26.7.9

The first build clones the NXP vendor repositories (mwifiex driver source and imx-firmware, mirrored on code.karsttech.com) into _vendor/ at pinned commits. Subsequent builds reuse the cached clones; remove _vendor/ to force a fresh clone.

Development workflow

Kernel source

The kernel source (opnsense-src) is a fork of OPNsense/FreeBSD at claude/opnsense-src (forked from we-are-mono/opnsense-src). Each stable/<series> branch is the upstream release tag plus the Mono Gateway commits.

Making a change:

cd /usr/src

# See Mono Gateway commits on top of upstream (in a clone with the release tags)
git log --oneline 26.7.9..origin/stable/26.7

# 1. Edit the file
vim sys/contrib/device-tree/src/arm64/freescale/mono-gateway-dk.dts

# 2. Stage and commit
git add sys/contrib/device-tree/src/arm64/freescale/mono-gateway-dk.dts
git commit -m "dts: add PCIe WiFi reset GPIO"

# 3. Push
git push

To rebase on a newer upstream OPNsense release (here 26.7.9):

git remote add upstream https://github.com/opnsense/src.git
git fetch upstream tag 26.7.9
git rebase --onto 26.7.9 $(git merge-base HEAD upstream/stable/26.7) stable/26.7
git push --force-with-lease

Out-of-tree modules

Drivers in drivers/ build against kernel headers without modifying the kernel source. To iterate on one:

# Rebuild just caam
sudo make -C /usr/deps build-caam

# Or rebuild all modules
sudo make -C /usr/deps -j24 modules

Output .ko files land in the driver directory and are collected into dist/ by make all.

Local / Test Deployment

Flashing writes the image directly to the gateway's eMMC. The gateway must be booted into Recovery Linux (initramfs) so the eMMC is not in use.

Warning: This overwrites the entire eMMC, including any existing OPNsense installation and its configuration.

1. Boot into Recovery Linux

Power on the gateway and let U-Boot autoboot into Recovery Linux (or interrupt U-Boot and run run recovery).

2. Configure networking on the gateway

Recovery Linux has no DHCP client. Assign a static IP on the uplink port (adjust addresses to match your network):

ip link set eth3 up
ip addr add 10.0.0.69/24 dev eth3
ip route add default via 10.0.0.1 dev eth3

3. Serve the image from the build server

Signed images are published at https://opnsense.karsttech.com/releases// (check the .sha256 file). Recovery Linux is easiest served over plain HTTP from a machine on the same network, e.g. in the directory holding the downloaded image:

python3 -m http.server 8000

4. Flash the eMMC

On the gateway, stream the compressed image directly to the eMMC. This downloads, decompresses, and writes in a single pipeline — no local storage needed (works even on devices with limited RAM):

curl http://[build-server]:8000/OPNsense-*-GATEWAY.img.gz | gunzip | dd of=/dev/mmcblk0 bs=1M

For an uncompressed image (slower transfer, no gunzip needed):

curl http://[build-server]:8000/OPNsense-*-GATEWAY.img | dd of=/dev/mmcblk0 bs=1M

5. Reboot

reboot

U-Boot will load kernel.img and the device tree from the FAT partition and boot into OPNsense.

Booting into OPNsense

The board's default boot command loads OpenWRT. To boot OPNsense instead, interrupt U-Boot's autoboot (press any key during the countdown) and configure a persistent opnsense boot environment:

=> setenv opnsense "load mmc 0:1 ${kernel_addr_r} kernel.img; load mmc 0:1 ${fdt_addr_r} dtb/mono-gateway-dk.dtb; booti 0x82000000 - 0x88000000"
=> setenv bootcmd_bak ${bootcmd}
=> setenv bootcmd "run opnsense || run recovery"
=> saveenv
=> reset

This saves the original boot command as bootcmd_bak, then sets bootcmd to try OPNsense first and fall back to Recovery Linux if the kernel image is missing. After saveenv and reset, the board will automatically boot into OPNsense on every subsequent power-on.

Disclaimer

Many of the files in this repository, and in the kernel fork, were ported from Linux sources provided by NXP (originally targeting Linux kernel 5.4). Due to the sheer scope of the porting effort, Claude Opus 4.6 was used to assist with the adaptation of this code to FreeBSD. As such, this project should be considered highly experimental and is not fit for production use until thorough reviews and testing have been performed by the wider community.