[BPI-R4] frank-w BPI-R4 kernel build & r8125 module build

I bought a realtek r8125 mini-PCIe 2.5Gb NIC for testing.

First of all, changes SW4 to OFF.
image

I tested the NIC by inserting it into two mini-PCIe slots and got the following results.

image

When I plug it into the upper slot and turn on the BPI-R4, the following error message appears in a loop until Kernel Crash.

When I plug it into the lower slot and turn on the BPI-R4, it looks OK.
Then after I loaded the r8125 module, the eth3 network interface appeared.

ethtool show:

Speed Test:

It looks OK, no watchdog timeout, no nic crash, network speed is also stable.

How to build r8125 module?
First, I build frank-w linux kernel and install it.
Second, I use those kernel source to set and build r8125 module.
The following is the compilation process.

  1. Install Debian 12

  2. Install packages:
    apt -y install git gcc g++ make libncurses5-dev build-essential sudo gcc-aarch64-linux-gnu flex bison ccache u-boot-tools bc libssl-dev libc6-dev
    apt -y install debhelper-compat libelf-dev:native libssl-dev rsync bzip2

  3. Download and decompress frank-w kernel source
    Now release: CI-BUILD-6.14-main-6.14.0-2025-04-24_2059, Download Source code (tar.gz)

  4. Modify build.conf in the kernel source directory
    Change board=bpi-r4
    螢幕截圖2025-04-30 21-31-22

  5. Import default config & custom config
    ./build.sh importconfig
    ./build.sh config

If we want to use the default values, we can just click “Exit” and “Save”.

For the steps here, we refer to the Usage section of BPI-Router-Linux

  1. Build Kernel
    ./build.sh

At the end of the compilation, we select 1 to generate compressed archives of the kernel image and kernel modules.

  1. Download and decompress r8125 kernel module source
    Download r8125 from Realtek PCIe 1G / 2.5G / 5G / 10G Ethernet Family Controller Software
    Here we choose 2.5G Ethernet LINUX driver r8125 for kernel up to 6.12 to download.

  2. Build it
    cd r8125-9.015.00/src make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j5 all

  3. Install kernel image & kernel modules & r8125.ko to BPI-R4

Decompress bpi-r4_6.14.0.tar.gz

image

Copy(or Move) BPI-BOOT/* /boot/
Copy(or Move) BPI-ROOT/lib/modules/6.14.0-bpi-r4 to /lib/modules/
Copy(or Move BPI-ROOT/etc/modprobe.d to /etc/
Copy(or Move BPI-ROOT/etc/modules-load.d to /etc/

Copy r8125.ko to /lib/modules/6.14.0-bpi-r4/kernel/drivers/net/

  1. Use new kernel to boot
    reboot
    uname -a

    Check Kernel version and Build Date & Time.

  2. insmod r8125.ko to testing

    Looks good.

  3. We add r8125.ko to modprobe
    Modify /lib/modules/6.14.0-bpi-r4/modules.dep
    Add “kernel/drivers/net/r8125.ko:” to the end.

Execute “depmod -a” image

  1. Use modprobe to load r8125
    modprobe r8125
    lsmod
    image

PS:
When we build r8125 module, if we got error message:

This is because when compiling r8125 module, the compiled file of the Kernel could not be found.
When we compile the kernel using frank-w kernel’s build.sh, it will create a build folder in the home directory (here is /home/ycfu/build).
All kernel compiled files are in this directory.
Therefore, when compiling r8125, make sure that the specified Kernel source is this directory.

Building out-of-tree modules

$ make -C <path_to_kernel_dir> M=$PWD

https://docs.kernel.org/kbuild/modules.html

If you compile full kernel you can checkout the main branch with git instead of downloading the source from release. Using source package imho makes only sense when compiling the module only for already installed kernel

I wonder why only 1 slot works for you here