Natively, the first fetch in tools' distfiles chroot builds pkg, whose GitHub patches no longer match distinfo, and tools' fetch loop records a failure in a path outside the chroot, which under sh -e ended the loop with no port named. patches/tools/0001 records failures inside the chroot (as tools' ports step does); build.sh applies patches/tools to every series. pkg's distfiles go into the set before the step, via fetch-patch.sh; repairs are appended to the set instead of rewriting a set of many gigabytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| config | ||
| dist | ||
| drivers | ||
| fastpath | ||
| keys | ||
| LICENSES | ||
| mirror | ||
| patches | ||
| pkg | ||
| plugins/hwmon/src/opnsense | ||
| rc.d | ||
| release | ||
| tools | ||
| .gitignore | ||
| ARCHITECTURE.md | ||
| CMM.md | ||
| LICENSING.md | ||
| Makefile | ||
| mk-image.sh | ||
| README.md | ||
| RELEASE.md | ||
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)
├── patches/tools/ # opnsense/tools fixes, every series
├── 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 (14.3 for 26.1,
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.1 OPS_VERSION=26.1.11
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
git log --oneline origin/stable/26.1..HEAD
# 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.