Skip to content

BPI-R4 OpenWrt Router

The edge router is a Banana Pi BPI-R4 running a custom fork of OpenWrt 25.12 targeting the MT7988a SoC. The build is fully automated via GitLab CI.

Build Pipeline

flowchart LR
    push["git push\nopenwrt-25.12-tillo branch"]
    ci["GitLab CI\nproject ID 33"]
    build["OpenWrt build system\ncross-compile MT7988a"]
    artifact["sysupgrade.itb\n(firmware artifact)"]
    flash["SSH to bpi-r4\ncat > /tmp/sysupgrade.itb\nsysupgrade -v"]

    push --> ci --> build --> artifact --> flash

CI is triggered on every push. The firmware artifact is stored in the GitLab generic packages registry, keyed by pipeline IID.

Kernel Customizations

Custom patches live in target/linux/mediatek/patches-6.12/, applied in lexicographic order via the quilt workflow. Key patches:

  • 197-dts-mt7988a-add-ramoops.patch — reserves 64 KiB at 0x42ff0000 for ramoops/pstore, enabling kernel crash dumps to survive reboots
  • Lockup detectorsSOFTLOCKUP_DETECTOR, HARDLOCKUP_DETECTOR, DETECT_HUNG_TASK, and watchdog pretimeout panic enabled for crash diagnostics

Kernel config layering

Changes must go into target/linux/mediatek/filogic/Config-kernel.innot directly into config-6.12. Config-kernel.in is processed last and overrides config-6.12. Edits to config-6.12 alone are silently reverted on the next build.

Flash Procedure

Dropbear (the SSH server in OpenWrt) has no sftp-server. File transfers must use stdin/stdout:

# Upload firmware
ssh root@bpi-r4 'cat > /tmp/sysupgrade.itb' < /path/to/sysupgrade.itb

# Flash and reboot (~2-3 min)
ssh root@bpi-r4 'sysupgrade -v /tmp/sysupgrade.itb'

# Verify after reboot
ssh root@bpi-r4 'uptime; uname -r'

scp will fail silently or with a protocol error — never use it.

MT7988a Reserved Memory

Address Size Purpose
0x42ff0000 64 KiB ramoops / pstore (kernel crash dumps)
0x43000000 320 KiB ATF / secmon

Post-Crash Diagnosis

After a kernel crash and reboot, pstore holds the previous kernel's dmesg:

mount -t pstore pstore /sys/fs/pstore
cat /sys/fs/pstore/dmesg-ramoops-0

This is configured in /etc/rc.local to mount automatically on boot.

Known Issue: sfp-lan Zero Traffic

If the SFP LAN port (GMAC1) shows link-up but zero hardware TX/RX bytes, the RSS/LRO patches (999-eth-08*, 999-eth-09*) have corrupted the GMAC1 GDMA data path. Removing those patch files resolves it.