bananapi_bpi r4pro 8x - bunnyamin/bunnix GitHub Wiki

BPI-R4 Pro (8X)

Hardware Implementation Comment
Chipset MediaTek MT7988A (Filogic 880)
CPU Quad-core Arm Cortex-A73, 1.8GHz
SD RAM 8GB DDR4
Internal storage 8GB eMMC Flash
Internal storage 256 MB SPI-NAND Flash
M.2 E-Key 2230 PCIe 3.0 1-lane, shared CN15 For NVME SSD
M.2 E-Key 2230 PCIe 3.0 1-lane, shared CN18 For NVME SSD
M.2 B-Key USB 3.2 only Intended for 4G/5G Cellular Module
M.2 B-Key USB 3.2 PCIe 3.0 1-lane, shared CN13 Intended for 4G/5G Cellular Module
M.2 B-Key USB 3.2 PCIe 3.0 1-lane, shared CN14 Intended for 4G/5G Cellular Module
USB USB 2.0 Type A
USB USB 3.2 Type A
Debug USB-UART Type C For on board debug console
GPIO 2x13 PIN Header For expanding application
PWM PH-3-PIN Headers For 5V PWM-controlled fan
PWM (2x) 2.54mm 4-PIN Headers For 12V PWM-controlled fan
RTC CR1220
Button WPS-key
Button RST-key Reset key
SD-card Micro SD
DC 5521, 12V/14V DC-power input

Network

Ethernet

Hardware and driver mapping

Group DTB Interface Name OS Renamed To Gbps Driver, Underlying Hardware
CPU Link eth0 eth0 10 mtk_soc_eth (Internal link to MT7530)
CPU Link eth1 lan 10 mtk_soc_eth (Direct link to WAN Mux)
CPU Link eth2 eth2 10 mtk_soc_eth (Internal link to MxL86252C)
1G LAN lan0@eth0 lan5@eth0 1G MediaTek MT7530 (Internal PHY)
1G LAN lan3@eth0 lan3@eth0 1G MediaTek MT7530 (Internal PHY)
2.5G LAN mxl_lan0@eth2 lan1@eth2 2.5 MaxLinear MxL86252C (Internal GPY PHY)
2.5G LAN mxl_lan1@eth2 lan2@eth2 2.5 MaxLinear MxL86252C (Internal GPY PHY)
2.5G LAN mxl_lan2@eth2 mxl_lan2@eth2 2.5 MaxLinear MxL86252C (Internal GPY PHY)
2.5G LAN mxl_lan3@eth2 lan4@eth2 2.5 MaxLinear MxL86252C (Internal GPY PHY)
10G WAN eth1 (Mux Ch0) lan 10 Aeonsemi AS21xxx (phy@28)
10G WAN eth1 (Mux Ch1) lan 10 SFP+ Module (sfp2 / sfp@5f)
10G LAN mxl_lan5@eth2 (Mux Ch1) mxl_lan5@eth2 10 Aeonsemi AS21xxx (phy@24)
10G LAN mxl_lan5@eth2 (Mux Ch0) mxl_lan5@eth2 10 SFP+ Module (sfp1 / sfp@57)

Port numbered from left (1) to right, where the last right port is next to DC12V connection.

Architecture and routing

8P8C Interface Name Logical Type Intermediary Switch / Mux Physical Endpoint
- eth0 CPU Master Port None (Direct to Switch) SoC Internal -> MT7530 Switch
7 eth1 (lan) 10G WAN Shared ethernet-mux@1 (GPIO 3) 8P8C: Aeonsemi PHYSFP+: SFP Cage 2
- eth2 CPU Master Port None (Direct to Switch) SoC Internal -> MxL86252C Switch
5 lan0@eth0 1G User Port MediaTek MT7530 MT7530 Port 0
- lan3@eth0 1G User Port MediaTek MT7530 MT7530 Port 3 (Probably the FPC Connector)
1 mxl_lan0@eth2 2.5G User Port MaxLinear MxL86252C MxL86252C Port 0
2 mxl_lan1@eth2 2.5G User Port MaxLinear MxL86252C MxL86252C Port 1
3 mxl_lan2@eth2 2.5G User Port MaxLinear MxL86252C MxL86252C Port 2
4 mxl_lan3@eth2 2.5G User Port MaxLinear MxL86252C MxL86252C Port 3
- mxl_lan4@eth2 Disabled in DTB MaxLinear MxL86252C MxL86252C Port 4 (Unused)
6 mxl_lan5@eth2 10G LAN Shared MxL86252C Port 6 -> ds-mux@0 (GPIO 54) 8P8C: Aeonsemi PHYSFP+: SFP Cage 1

Wi-fi

2x mini PCIe slots with PCIe 3.0 2-lane interface for Wi-Fi NIC.

Partition

  • Hardware
block Device Size Comment
mtdblock0 SPI NAND 256 MB Initial bootloader
mtdblock1 SPI NAND 256 MB Initial bootloader
mtdblock2 SPI NAND 256 MB Initial bootloader
mtdblock3 SPI NAND 256 MB Initial bootloader
mmcblk? eMMC 8 GB Requires to be set by DIP switch
ubiblock0_4 SPI NAND UBI 256 MB Initial bootloader
  • BPI-R4Pro-8X-BE14-MT76-OpenWRT24.10-DSA-sdcard-251229
# Sector Start Sector Stop Size Name Content
1 34 8191 4.0 MiB bl2 idbloader.img
2 8192 9215 512 KiB ubootenv U-Boot env (empty)
3 9216 13311 2.0 MiB factory Factory data (empty)
4 13312 21503 4.0 MiB fip fip-full.bin (BL31+U-Boot)
5 24576 286719 128 MiB recovery Recovery squashfs
6 286720 327679 20 MiB install SPINAND installer
7 327680 1245183 448 MiB production Root filesystem

Partition overview:

Dec      Hexa       Description
--------------------------------------------------------------
0        0x0       Device tree blob (DTB), version: 17, CPU ID: 0,
                   total size: 4096 bytes
4096     0x1000    gzip compressed data, operating system:
                   Unix, timestamp: 1970-01-01 00:00:00,
                   total size: 6744914 bytes
6750208  0x670000  Device tree blob (DTB), version: 17, CPU ID: 0,
                   total size: 55905 bytes
6807552  0x67E000  Device tree blob (DTB), version: 17, CPU ID: 0,
                   total size: 1550 bytes
6811648  0x67F000  Device tree blob (DTB), version: 17, CPU ID: 0,
                   total size: 289 bytes
6815744  0x680000  Device tree blob (DTB), version: 17, CPU ID: 0,
                   total size: 1478 bytes
6819840  0x681000  Device tree blob (DTB), version: 17, CPU ID: 0,
                   total size: 2293 bytes
6823936  0x682000  SquashFS file system, little endian, version: 4.0,
                   compression: xz, inode count: 3874,
                   block size: 262144,
                   image size: 105268801 bytes, created: 2025-06-17 03:09:13

Where the DTBs:

Name  Position      Description
      0x0.dtb       FIT image metadata (describes kernel image), not a hardware DTB – Can be ignored
main  0x670000.dtb  Main board DTB – contains most hardware (CPU, PCIe, Ethernet, I2C, etc.) but no MMC node.
emmc  0x67E000.dtb  Overlay that configures mmc0 for eMMC (8‑bit, HS400).
rtc   0x67F000.dtb  Overlay to enable the RTC (pcf8563).
sd    0x680000.dtb  Overlay that configures mmc0 for SD card (4‑bit, CD pin, etc.).
wifi  0x681000.dtb  Overlays for WiFi regulators and PCIe WiFi nodes

Extract

Partition 7

  1. Write the official SD-card system image dd if=BPI-R4Pro-8X-BE14-MT76-OpenWRT24.10-DSA-sdcard-251229.img of=/dev/sd? bs=1M count=20 conv=fsync
  2. Repair the partition, e.g.
    • gdisk /dev/sd?
    • Warning! Secondary header is placed too early on the disk! Do you want to correct this problem? (Y/N): n
  3. Extract partition 7 dd if=/BPI-R4Pro-8X-BE14-MT76-OpenWRT24.10-DSA-sdcard-251229.img of=prod.bin bs=512 skip=327680 count=$((546816 - 327680)) status=progress

Create partition on SD

  1. Make sure the storage device is unmounted lslbk -f
  2. Wipe the existing partition table sgdisk -Z /dev/sd?
  3. Ensure the beginning of the device is empty dd if=/dev/zero of=/dev/sd? bs=1M count=20

I could not recreate a working partition map and boot process. The approach taken:

  1. Write the official SD-card system image dd if=BPI-R4Pro-8X-BE14-MT76-OpenWRT24.10-DSA-sdcard-251229.img of=/dev/sd? bs=1M count=20 conv=fsync
  2. Delete partitions 5, 6, 7, e.g.
    • fdisk /dev/sdb? and d
  3. Create a new partition; it becomes the fifth, e.g.
    • fdisk /dev/sdb? and n
  4. Format the partition 5 to ext4 mkfs.ext4 -L root /dev/sd?5
  5. Make a note of the PARTUUID: blkid /dev/sd?5

Boot-loader

Copy from BPI-R4Pro-8X-BE14-MT76-OpenWRT (24.10-DSA-251229)

I tried many different methods to extract the boot loader from the image. They all failed. The successful solution was to boot the OS and copy:

  • /sys/firmware/fdt
  • Rename it to mt7988a-bananapi-bpi-r4-pro-8x-sd.dtb

Linux

Boot kernel - Probe and test

Boot up with the SD-card. The official boot menu should come up:

      ( ( ( OpenWrt ) ) )  [SD card]       U-Boot 2024.10-OpenWrt-unknown (Jun 17 2025 - 03:09:13 +00
    1. Run default boot command.
    2. Boot system via TFTP.
    3. Boot production system from SD card.
    4. Boot recovery system from SD card.
    5. Load production system via TFTP then write to SD card.
    6. Load recovery system via TFTP then write to SD card.
    7. Install bootloader, recovery and production to NAND.
    8. Reboot.
    9. Reset all settings to factory defaults.
    0. Exit


Press UP/DOWN to move, ENTER to select, ESC to quit
  1. Exit the menu (0)

Confirm root and boot:

  • ls mmc 0:5
  • ls mmc 0:5 /boot

Test kernel boot: setenv kernel_addr_r 0x50000000 setenv fdt_addr_r 0x60000000 setenv ramdisk_addr_r 0x62000000

  1. Load the Kernel (usually around 20-30MB) ext4load mmc 0:5 ${kernel_addr_r} /boot/Image

  2. Load the Device Tree Blob (the hardware map) ext4load mmc 0:5 ${fdt_addr_r} /boot/dtbs/mediatek/mt7988a-bananapi-bpi-r4-pro-8x-sd.dtb

  3. Set the Kernel command line setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p5 rw rootwait" setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p5 rw rootwait earlycon=uart8250,mmio32,0x11000000"

  4. Boot the ARM64 kernel image booti ${kernel_addr_r} - ${fdt_addr_r}

Configuration

The OpenWRT U-boot does not support "sysboot".

If using initrd:

  • setenv boot_arch 'setenv kernel_addr_r 0x50000000; setenv fdt_addr_r 0x60000000; setenv ramdisk_addr_r 0x62000000; ext4load mmc 0:5 ${kernel_addr_r} /boot/Image; ext4load mmc 0:5 ${fdt_addr_r} /boot/dtbs/mediatek/mt7988a-bananapi-bpi-r4-pro-8x-sd.dtb; ext4load mmc 0:5 ${ramdisk_addr_r} /boot/uInitrd; setenv bootargs "console=ttyS0,115200 pci=rescan root=/dev/mmcblk0p5 rw rootwait earlycon=uart8250,mmio32,0x11000000"; booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}'
  • The NVMe modules are however loaded before the PCI bridge. The kernel command line pci=rescan scans the bus after the modules loaded. However, it rescans for all modules. If required to only load specific modules, use initramfs "hooks".

Else:

  • setenv boot_arch 'setenv kernel_addr_r 0x50000000; setenv fdt_addr_r 0x60000000; ext4load mmc 0:5 ${kernel_addr_r} /boot/Image; ext4load mmc 0:5 ${fdt_addr_r} /boot/dtbs/mediatek/mt7988a-bananapi-bpi-r4-pro-8x-sd.dtb; setenv bootargs "console=ttyS0,115200 root=/dev/mmcblk0p5 rw rootwait earlycon=uart8250,mmio32,0x11000000"; booti ${kernel_addr_r} - ${fdt_addr_r}'

Test run:

  • run boot_arch # test that boot_arch works

Permanently store the settings:

setenv bootcmd "run boot_arch"
setenv bootdelay 2
saveenv

Arch Linux Arm

Official version (Linux kernel 6.18.3-1-aarch64-ARCH updated to 7.0.3)

As if writing (2026-06) the mainline support for the board is still in progress and is still not sufficient for the system to boot up. The working approach to achieve full support for DTB, SystemD, NVMe and Ethernet ports was to compile the official SINOVOIP BPI-R4Pro-8X-BE14-MT76-OpenWRT (24.10-DSA-251229) and use its DTB, firmware, Image, modules.

  1. Mount the root partition mount /dev/sd?5 /mnt
  2. Extract Arch Linux ARM distribution to mount point as root user and not as sudo in order to preserve the extended attributes and ACL:
  • tar -xvpf ArchLinuxARM-aarch64-latest.tar -C /mnt or
  • bsdtar -xpf ArchLinuxARM-aarch64-latest.tar -C /mnt and
  • sync
  1. arch-chroot /mnt
  • Setup the system and install necessary packages:
    • pacman-key --init
    • pacman-key --populate archlinuxarm
    • pacman --disable-sandbox -Syy
    • pacman --disable-sandbox -Sy archlinux-keyring
    • pacman --disable-sandbox -Syu
    • pacman --disable-sandbox -S linux-firmware-mediatek linux-firmware-other libgpiod
  • Optional packages:
    • pacman --disable-sandbox -S dtc ethtool i2c-tools libgpiod uboot-tools usbtools
  1. If pre-configuring the system:
    • Basic system configuration
    • Install necessary packages, for example to read manuals, compile, copy files, network.
    • Exit arch-chroot
  2. If intending to install on the eMMC (8GB) or SPI NAND (256MB) or SSD/NVMe.
    • Copy ArchLinuxARM-aarch64-latest.tar or ensure that rsync is installed
    • Boot with SD-Card then mount local eMMC or SPI NAND:
      • Partition the eMMC, for example mmcblk0
      • Extract Arch Linux Arm to mounted root (step 2 above) or
      • Copy OS from SD to local eMMC rsync -avxHAXhn --exclude='/mnt' / /mnt
  3. Build BPI-R4Pro-8X-BE14-MT76-OpenWRT (24.10-DSA-251229)
    • Copy the Image: build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/arch/arm64/boot/Image /mnt/boot/
    • Copy modules and "builtin" metadata:
      • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/modules.builtin /mnt/lib/modules/6.6.93/
      • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/modules.builtin.modinfo /mnt/lib/modules/6.6.93/
      • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/modules.order /mnt/lib/modules/6.6.93/
    • Copy firmware:
      • cp build_dir/target-aarch64_cortex-a53_musl/linux-firmware-20241110/mediatek /mnt/lib/firmware/
    • Copy Aeonsemi AS21xxx module and firmware
      • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/phy-as21xxx/ipkg-aarch64_cortex-a53/as21xxx-firmware/lib/firmware/as21x1x_fw.bin /mnt/lib/firmware/
        • May be necessary to create a symbolic link to it from /mnt/lib/firmware/
      • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/phy-as21xxx/aeon_as21xxx.ko /mnt/lib/modules/6.6.93/
    • Build module dependency map depmod -a 6.6.93
    • Load modules:
      • Test: modprobe <modulenmae without the KO extension>"
      • echo "pwm-fan" > /mnt/etc/modules-load.d/02-fan.conf
      • echo "i2c_mux_pca954x" > /mnt/etc/modprobe.d/05-rtc.conf
      • echo "rtc_pcf8563" >> /mnt/etc/modprobe.d/05-rtc.conf
      • echo "aeon_as21xxx" > /mnt/etc/modules-load.d/10-ethernet.conf
      • echo "xhci-mtk-hcd" > /mnt/etc/modules-load.d/15-usb.conf
      • echo "usb-storage" >> /mnt/etc/modules-load.d/15-usb.conf
      • echo "cdc-acm" >> /mnt/etc/modules-load.d/15-usb.conf for USB serial devices, e.g ttyACM0
      • echo "nvme" > /mnt/etc/modules-load.d/20-nvme.conf
      • echo "nfs" > /mnt/etc/modules-load.d/30-nfs.conf
    • arch-chroot /mnt
      • "Mask" EFI mounting:
        • systemctl mask efi.mount
        • systemctl mask efi.automount
      • If intending to mount root on NVMe then initramfs/initrd is necessary:
        • Add NVMe modules MODULES=(nvme nvme-core)
        • mkinitcpio -k 6.6.93 -g /boot/initramfs-linux.img
        • Verify lsinitcpio /boot/initramfs-linux.img | grep -i nvme
        • The OpenWRT U-boot does not support initramfs. Create initrd from initramfs:
        • mkimage -A arm64 -O linux -T ramdisk -C none -n "Arch Linux ARM initramfs" -d /boot/initramfs-linux.img /boot/uInitrd
    • Exit arch-chroot
  4. unmount /mnt
  5. The system should boot, with working NVMe and Ethernet.
    • User account and password: alarm
    • Root password: root
  6. Full system update to the latest Linux kernel but with risk that boot will fail or break NVMe or Ethernet.

Basic system configuration

A minimal configuration to expand depending on additional functional requirements:

  • Enable NTP system clock: systemctl enable --now systemd-timesyncd
  • Change root password
  • Remove user "alarm", add users
file package configure
/etc/adjtime (base) Adjust the hardware clock from the system clock with the assumption that the hardware clock is in UTC: hwclock --systohc --utc
/etc/hostname (base) Edit file in a text editor; add <hostname>. Alternatively, use SystemD hostnamectl set-hostname <hostname>
/etc/hosts (base) Edit file in a text editor: 127.0.0.1 <hostname>.localdomain <hostname>
/etc/localtime (base) A syslink from the Time Zone Database database to localtime: ln -sf /usr/share/zoneinfo/<region>/<city> /etc/localtime
/etc/locale.conf (base) Add locale, for example, LANG=en_US.UTF-8.
/etc/locale.gen (base) Uncomment locale in locale.gen and generate locale.conf and resources in /usr/lib/locale with locale-gen. Remember, any additional language later assigned requires to be uncommented in the locale.gen and locale-gen re-generated.
/etc/vconsole.conf (base) Add keyboard loadkeys keymap as KEYMAP=<keymap>.

BPI-R4Pro-8X-BE14-MT76-OpenWRT (24.10-DSA-251229)

Build

Overview:

  1. Do not follow the official documentation
    • ./scripts/feeds update -a can introduce errors
  2. Build toolchain
  3. Compile firmware
  4. Compile Image and kernel modules
  5. Compile OpenWRT IPT-packages of kernel modules
  6. Compile out-of-tree module and firmware
    • as21xxx

All modules must be replaced if compiling modules that requires re-compiling the kernel image.

  • May need to clean before rebuild to avoid conflicts moving modules to built-in or vice versa

On Arch Linux with GCC version 16.1.1 2026-04-30:

  • pacman -S --needed base-devel git bzip2 gawk gettext grep libunistring unzip which python perl wget subversion rsync time

When running code ensure as same user as owner of downloaded repository, for example

  • sudo -u nobody ... V=sc
  • sudo -u nobody sh -c '...' # Requires "user" sudo permission for "su"
  1. Configure kernel
  • Enable necessary for full SystemD support (kernel_menuconfig)
    General setup
      [*] Control Group support  --->
        [*]   Memory controller
        [*]   IO controller
        [*]   CPU controller  --->
        [*]   PIDs controller
        [*]   Device controller
      [*] Namespaces support  --->
        [*]   UTS namespace
        [*]   IPC namespace
        [*]   User namespace
        [*]   PID Namespaces
        [*]   Network namespace (NEW)
      [*] Configure standard kernel features (expert users)  --->
        [*]   open by fhandle syscalls
    Device Drivers  --->
      Generic Driver Options  --->
        [*] Maintain a devtmpfs filesystem to mount at /dev # DEVTMPFS
        [*]   Automount devtmpfs at /dev, after the kernel mounted the rootfs # DEVTMPFS_MOUNT
    File systems
      <M> Kernel automounter support (supports v3, v4 and v5)
      Pseudo filesystems  --->
      [*] Tmpfs virtual memory file system support (former shm fs)
      [*]   Tmpfs POSIX Access Control Lists
    
  • Enable Docker support (kernel_menuconfig):
    General setup
      [*] Namespaces support ---> # Same as SystemD
    [*] Networking support  --->
      Networking options  --->
        [*] Network packet filtering framework (Netfilter)  --->
          Core Netfilter Configuration  --->
            <*> Netfilter connection tracking support
            -*- Network Address Translation support
            <*> Netfilter nf_tables support
            [*]   Netfilter nf_tables netdev tables support
            < >   Netfilter nf_tables number generator module
            <*>   Netfilter nf_tables conntrack module
            <*>   Netfilter nf_tables hardware flow offload module
            <*>   Netfilter nf_tables log module
            < >   Netfilter nf_tables limit module
            <*>   Netfilter nf_tables masquerade support
            < >   Netfilter nf_tables redirect support
            <*>   Netfilter nf_tables nat module
            < >   Netfilter nf_tables tunnel module
            < >   Netfilter nf_tables quota module
            <M>   Netfilter nf_tables reject support
            <M>   Netfilter x_tables over nf_tables module
            < >   Netfilter nf_tables hash module
            < >   Netfilter nf_tables socket match support
            < >   Netfilter nf_tables tproxy support
            < >   Netfilter packet duplication support
            < >   Netfilter nf_tables netdev packet duplication support
            < >   Netfilter nf_tables netdev packet forwarding support
            <M> Netfilter Xtables support (required for ip_tables)
            <M>   MASQUERADE target support (NEW)
            <M>   "addrtype" address type match support
            < >   "conntrack" connection tracking match support
          IP: Netfilter Configuration  --->
            <M> IP tables support (required for filtering/masq/NAT)
            <M>   iptables NAT support (NEW)
        <*> 802.1d Ethernet Bridging
    Device Drivers
      [*] Network device support  --->
        <M>     Virtual ethernet pair device
    File systems
      <*> Overlay filesystem support
    
  • Enable KVM and hardware virtualization support:
    [*] Virtualization  --->
      [*]   Kernel-based Virtual Machine (KVM) support  --->
    Device Drivers  --->
      [*] Block devices  --->
        <M>   Virtio block driver
      [*] Network device support  --->
        <M>     MAC-VLAN support
        <M>       MAC-VLAN based tap driver
        <M>     Universal TUN/TAP device driver support
      [*] VHOST drivers  --->
        <M>   Host kernel accelerator for virtio net
    
  • Enable NF tables support:
    • If nf_conntrack then disable patch:
      • target/linux/mediatek/patches-6.6/613-netfilter-optional-tcp-window-check.patch
      • feeds/mtk_openwrt_feed/autobuild/unified/filogic/24.10/files/target/linux/mediatek/patches-6.6/613-netfilter-optional-tcp-window-check.patch
      • feeds/mtk_openwrt_feed/21.02/files/target/linux/mediatek/patches-5.4/999-2700-netfilter_optional_tcp_window_check.patch
      • Remove or rename, for example add suffix ".DISABLED"
      • Necessary to avoid kernel warning messages
    [*] Networking support  --->
      Networking options  --->
        [*] Network packet filtering framework (Netfilter)  --->
          Core Netfilter Configuration  --->
            <*> Netfilter connection tracking support
            <*> Netfilter nf_tables support                         # Built-in so available at boot
            [*]   Netfilter nf_tables netdev tables support         # For early packet dropping
            < >   Netfilter nf_tables number generator module (NEW)
            <*>   Netfilter nf_tables conntrack module (NEW)        # Statful rules, e.g. "established connections"
            <*>   Netfilter nf_tables hardware flow offload module  # Performance, uses MT PPE chip
            <*>   Netfilter nf_tables log module (NEW)              # Enables debugging rules
            < >   Netfilter nf_tables limit module (NEW)
            <*>   Netfilter nf_tables masquerade support (NEW)
            < >   Netfilter nf_tables redirect support (NEW)
            <*>   Netfilter nf_tables nat module
            < >   Netfilter nf_tables tunnel module
            < >   Netfilter nf_tables quota module (NEW)
            <M>   Netfilter nf_tables reject support (NEW)  # "Reject" otherwise only support for "drop"
            < >   Netfilter nf_tables hash module (NEW)
            < >   Netfilter nf_tables socket match support
            < >   Netfilter nf_tables tproxy support
            < >   Netfilter packet duplication support (NEW)
            < >   Netfilter nf_tables netdev packet duplication support (NEW)
            < >   Netfilter nf_tables netdev packet forwarding support (NEW)
            <*> Netfilter flow table module
    
  • Enable NFSv4 support (kernel_menuconfig):
    File systems
      Network File Systems
        <M>   NFS client support
        < >     NFS client support for NFS version 2
        <M>     NFS client support for NFS version 3
        [ ]       NFS client support for the NFSv3 ACL protocol extension
        <M>     NFS client support for NFS version 4
        [ ]     Provide swap over NFS support
        [*]   NFS client support for NFSv4.1
        [*]     NFS client support for NFSv4.2
        (kernel.org) NFSv4.1 Implementation ID Domain (NEW)
        [*]     NFSv4.1 client support for migration
        [ ]   Use the legacy NFS DNS resolver (NEW)
        [ ]   NFS: Disable NFS UDP protocol support
        [*]   NFS: Enable support for the NFSv4.2 READ_PLUS operation
        <M>   NFS server support
        [ ]     NFS server support for NFS version 2 (DEPRECATED)
        [ ]     NFS server support for the NFSv3 ACL protocol extension
        [*]     NFS server support for NFS version 4
        [*]   NFSv4.1 server support for pNFS block layouts
        [*]   NFSv4.1 server support for pNFS SCSI layouts
        [*]   NFSv4.1 server support for pNFS Flex File layouts
        [*]   NFSv4.2 inter server
    
  • Enable DM-mod (kernel_menuconfig):
    Cryptographic API
      Block ciphers
        # Select for Luks, at least AES
      Length-preserving ciphers and modes
        <M> XTS (XOR Encrypt XOR with ciphertext stealing)
      Hashes, digests, and MACs
        # Select for Luks, at least SHA-2 and -3
      Accelerated Cryptographic Algorithms for CPU (arm64)
        # Select accelerations for the chosen ciphers, hash functions
    Device Drivers
      [*] Multiple devices driver support (RAID and LVM)  --->
        <M>   Device mapper support
        <M>     Crypt target support` for Luks
    
  • Enable USB serial drivers and other USB peripherals:
    Device Drivers  --->
      [*] USB support  --->
      <M>   Support for Host-side USB
      <M>   USB Modem (CDC ACM) support
      <M>   USB Mass Storage support
      <M>     USB Attached SCSI
      <M>   USB Serial Converter support  --->
        <M>   USB Winchiphead CH341 Single Port Serial Driver
        <M>   USB CP210x family of UART Bridge Controllers
        <M>   USB FTDI Single Port Serial Driver
        <M>   USB Prolific 2303 Single Port Serial Driver
      <*> MMC/SD/SDIO card support  --->
    
  1. Update config: make defconfig
  2. Build toolchain
    • Patch cmake
    • If running gnu++20 (GCC version 16), either
      • patch GCC errors or
      • fix them when they occur
    • make toolchain/compile V=sc
  3. Build firmware: make package/firmware/linux-firmware/compile V=sc
  4. Build image and kernel modules: make target/linux/compile -j1 V=sc
  5. Build OpenWRT IPT-package of kernel modules: make package/kernel/linux/compile -j1 V=sc This could cause compile errors when customizing the kernel config
  6. Build out-of-tree firmware and modules: make package/kernel/as21xxx/compile -j1 V=sc

Module paths

The kernel modules can be found in different places, of which two are relevance:

  1. The raw original modules with debugging symbols and human-readable text strings describing kernel panics.
  • build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/drivers
  • build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/gpio-button-hotplug Methods to find and copy all modules:
  • find build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/ -type f -name '*.ko' -exec cp -t /mnt/lib/modules/6.6.93/ {} +
  • find build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/ -type f -name '*.ko' -print0 | xargs -0 cp -t /mnt/lib/modules/6.6.93/
  1. The modules stripped of symbols and metadata for OpenWRT packages:
  • build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/packages/ipkg-aarch64_cortex-a53/ Copy all modules:
  • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/packages/ipkg-aarch64_cortex-a53/*/lib/modules/6.6.93/* /mnt/lib/modules/6.6.93/

For non-OpenWRT-distros the original modules should be preferred.

Another location that should be noted; all modules prepared during build.

  • staging_dir/target-aarch64_cortex-a53_musl/root-mediatek/lib/modules/6.6.93

Patch CMake

Error:

FAILED: cmake
staging_dir/host/bin/g++ ...
/usr/bin/ld: cmake.o: in function `cmake::CreateGlobalGenerator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)':
cmake.cxx:(.text+0xcebd): undefined reference to `cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake*)'
/usr/bin/ld: cmake.o: in function `cmake::AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry, std::allocator<cmDocumentationEntry> >&)':
cmake.cxx:(.text+0xde76): undefined reference to `cmGlobalGhsMultiGenerator::GetDocumentation()'
/usr/bin/ld: cmake.o: in function `cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>::GetDocumentation() const':
cmake.cxx:(.text._ZNK30cmGlobalGeneratorSimpleFactoryI25cmGlobalGhsMultiGeneratorE16GetDocumentationEv[_ZNK30cmGlobalGeneratorSimpleFactoryI25cmGlobalGhsMultiGeneratorE16GetDocumentationEv]+0x17): undefined reference to `cmGlobalGhsMultiGenerator::GetDocumentation()'
/usr/bin/ld: cmake.o: in function `cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>::CreateGlobalGenerator(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, cmake*) const':
cmake.cxx:(.text._ZNK30cmGlobalGeneratorSimpleFactoryI25cmGlobalGhsMultiGeneratorE21CreateGlobalGeneratorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbP5cmake[_ZNK30cmGlobalGeneratorSimpleFactoryI25cmGlobalGhsMultiGeneratorE21CreateGlobalGeneratorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEbP5cmake]+0xd6): undefined reference to `cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake*)'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Remedy: tools/cmake/patches/170-kitware-disable-devirtualization.patch

--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -129,7 +129,7 @@
-#endif
 
 // NOTE: the __linux__ macro is predefined on Android host too, but
 // main CMakeLists.txt filters out this generator by host name.
-#if (defined(__linux__) && !defined(__ANDROID__)) || defined(_WIN32)
-#  include "cmGlobalGhsMultiGenerator.h"
-#endif
+#  if (defined(__linux__) && !defined(__ANDROID__)) || defined(_WIN32)
+#    include "cmGlobalGhsMultiGenerator.h"
+#  endif
+#endif

If access to the cmake.cxx source file, test that the patch works: patch --dry-run build_dir/host/cmake-3.30.5/Source/cmake.cxx -p1 < tools-cmake\ 170-kitware-disable-devirtualization.patch

Fix GCC error

To cumbersome to create patches; fix when they appear:

  • error: no matching function for call to 'S2C(const char8_t):

    • Remedy: sed -i 's/u8"/"/g' build_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/gcc-13.3.0/libcody/*.cc build_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/gcc-13.3.0/libcody/*.hh
  • "locale_facets.h" errors:

    • Remedy: sed -i '1i #ifdef __cplusplus\n#include <locale>\n#include <memory>\n#include <string>\n#endif' build_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/gcc-13.3.0/gcc/system.h

Clean kernel compilation

  1. Remove the kernel source tree and compiled objects
  • make target/linux/clean
  1. Remove the packaged .ipk kernel modules and their staging files
  • make package/kernel/linux/clean

The toolchain, host tools, and non‑kernel packages should remain.

Error

depmod -a 6.6.93
depmod: WARNING: could not open modules.order at /lib/modules/6.6.93: No such file or directory
depmod: WARNING: could not open modules.builtin at /lib/modules/6.6.93: No such file or directory
depmod: WARNING: could not open modules.builtin.modinfo at /lib/modules/6.6.93: No such file or directory

depmod: ERROR: Invalid modules.builtin line: 8250.ko

depmod: ERROR: Invalid modules.builtin line: 8250_base.ko

depmod: ERROR: Invalid modules.builtin line: 8250_fsl.ko

depmod: ERROR: Invalid modules.builtin line: 8250_mtk.ko

depmod: ERROR: Invalid modules.builtin line: 8250_of.ko

depmod: ERROR: Invalid modules.builtin line: 8021q.ko

Remedy:

  • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/modules.builtin /mnt/lib/modules/6.6.93/
  • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/modules.builtin.modinfo /mnt/lib/modules/6.6.93/
  • cp build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_filogic/linux-6.6.93/modules.order /mnt/lib/modules/6.6.93/

Network

8P8C Interface Name Description Property=OF_FULLNAME=
- eth0 Internal link to MT7530. /soc/ethernet@15100000/mac@0
- mxl_lan4@eth2 None Disabled in DTB
- eth2 Internal link to MxL86252C /soc/ethernet@15100000/mac@2
- lan3@eth0 Internal 1G SWITCH /soc/switch@15020000/ports/port@3
1 mxl_lan0@eth2 2.5G LAN /soc/ethernet@15100000/mdio-bus/switch@16/ports/port@0
2 mxl_lan1@eth2 2.5G LAN /soc/ethernet@15100000/mdio-bus/switch@16/ports/port@1
3 mxl_lan2@eth2 2.5G LAN /soc/ethernet@15100000/mdio-bus/switch@16/ports/port@2
4 mxl_lan3@eth2 2.5G LAN /soc/ethernet@15100000/mdio-bus/switch@16/ports/port@3
5 lan0@eth0 1G User /soc/switch@15020000/ports/port@0
6 mxl_lan5@eth2 10G LAN /soc/ethernet@15100000/mdio-bus/switch@16/ports/port@6
7 eth1 10G WAN soc/ethernet@15100000/mac@1

Query property name:

  • udevadm info -q property -p /sys/class/net/<interface>

Basic template:

# /etc/systemd/network/20-lanN.link
[Match]
Property=OF_FULLNAME=...

[Link]
Name=lanN
Description=...
MACAddressPolicy=random

Fan

Confirm fan is working:

  • cat /sys/class/thermal/cooling_device0/cur_state should return 1, 2 or 3

System update

[Todo]

UART

Terminal settings

  • Baud=115200
  • Data bits: 8bit
  • Parity: none
  • Stop: 1bit
  • Flow control: none

An ordinary USB-C cable should suffice:

Ensure consistent baud rate

If disconnecting from UART and then reconnecting the console may no longer work.

  1. Identify active console:
  • cat /sys/class/tty/console/active -> ttySX
  1. Create directory:
  1. Create file
    Service]
    ExecStart=
    ExecStart=-/sbin/agetty -L -o '-p -- \\u' 115200 %I $TERM
    
  2. Start service systemctl daemon-reload systemctl restart [email protected]
⚠️ **GitHub.com Fallback** ⚠️