y52 Posted Friday at 05:18 PM Posted Friday at 05:18 PM (edited) Hello everybody, I tried building an in-kernel module for USB Dongle Bus 001 Device 003: ID 2357:0120 TP-Link Archer T2U PLUS [RTL8821AU] on my OrangePi Plus. Armbian supplied module from aircrack-ng/rtl8812au has become aging and raises exception errors on modprobe -r. It was deactivated : root@orangepiplus:/etc/modprobe.d# vi blacklist-88XXau.conf #blacklist 88XXau I made a fresh install of Armbian minimal image, then switched to : root@orangepiplus:~# uname -a Linux orangepiplus 6.15.4-edge-sunxi #1 SMP Fri Jun 27 10:13:43 UTC 2025 armv7l GNU/Linux root@orangepiplus:/usr/src# cat /proc/version Linux version 6.15.4-edge-sunxi (build@armbian) (arm-linux-gnueabihf-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, GNU ld (GNU Binutils for Ubuntu) 2.42) #1 SMP Fri Jun 27 10:13:43 UTC 2025 root@orangepiplus:/usr/src# zcat /proc/config.gz | grep CC_VERSION CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0" CONFIG_GCC_VERSION=130300 root@orangepiplus:/usr/src# zcat /proc/config.gz | grep STACKPROTECTOR CONFIG_CC_HAVE_STACKPROTECTOR_TLS=y CONFIG_STACKPROTECTOR_PER_TASK=y CONFIG_HAVE_STACKPROTECTOR=y CONFIG_STACKPROTECTOR=y CONFIG_STACKPROTECTOR_STRONG=y Headers were downloaded with armbian-config : root@orangepiplus:/mnt/sda2/src/linux-6.15.4# drwxr-xr-x 25 root root 4096 Aug 21 21:40 linux-headers-6.15.4-edge-sunxi Then performed usual build process: root@orangepiplus:/usr/src# sudo git clone --depth 1 --branch linux-6.15.y https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git root@orangepiplus:/usr/src# sudo ln -s /usr/src/linux /lib/modules/$(uname -r)/build root@orangepiplus:/usr/src# ls -al /lib/modules/$(uname -r)/build lrwxrwxrwx 1 root root 14 Aug 21 22:45 /lib/modules/6.15.4-edge-sunxi/build -> /usr/src/linux cp /boot/config-$(uname -r) /usr/src/linux/.config sudo make olddefconfig sudo make menuconfig Module activated in the following tree : │ Symbol: RTW88 [=m] │ │ Type : tristate │ │ Defined at drivers/net/wireless/realtek/rtw88/Kconfig:2 │ │ Prompt: Realtek 802.11ac wireless chips support │ │ Depends on: NETDEVICES [=y] && WLAN [=y] && WLAN_VENDOR_REALTEK [=y] && MAC80211 [=m] │ │ Location: │ │ -> Device Drivers │ │ -> Network device support (NETDEVICES [=y]) │ │ -> Wireless LAN (WLAN [=y]) │ │ -> Realtek devices (WLAN_VENDOR_REALTEK [=y]) │ │ (1) -> Realtek 802.11ac wireless chips support (RTW88 [=m]) root@orangepiplus:/usr/src/linux# grep -E 'CONFIG_RTW88_CORE|CONFIG_RTLWIFI|CONFIG_RTW88_8821AU' .config CONFIG_RTLWIFI=m CONFIG_RTLWIFI_USB=m # CONFIG_RTLWIFI_DEBUG is not set CONFIG_RTW88_CORE=m CONFIG_RTW88_8821AU=m cp /usr/src/linux-headers-6.15.4-edge-sunxi/Module.symvers /usr/src/linux/ Then compiled with: root@orangepiplus:/usr/src/linux# sudo make -j$(nproc) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- M=drivers/net/wireless/realtek/rtw88 make[1]: Entering directory '/usr/src/linux/drivers/net/wireless/realtek/rtw88' MODPOST Module.symvers CC [M] rtw88_core.mod.o CC [M] .module-common.o CC [M] rtw88_8822b.mod.o CC [M] rtw88_8822bs.mod.o CC [M] rtw88_8822bu.mod.o CC [M] rtw88_8822c.mod.o CC [M] rtw88_8822cs.mod.o ... LD [M] rtw88_core.ko LD [M] rtw88_8822b.ko LD [M] rtw88_8822bs.ko LD [M] rtw88_8822bu.ko LD [M] rtw88_8822c.ko LD [M] rtw88_8822cs.ko LD [M] rtw88_8822cu.ko LD [M] rtw88_8723x.ko LD [M] rtw88_8723d.ko LD [M] rtw88_8723ds.ko LD [M] rtw88_8723du.ko LD [M] rtw88_8821c.ko LD [M] rtw88_8821cs.ko LD [M] rtw88_8821cu.ko LD [M] rtw88_88xxa.ko LD [M] rtw88_8821a.ko LD [M] rtw88_8821au.ko LD [M] rtw88_sdio.ko LD [M] rtw88_usb.ko make[1]: Leaving directory '/usr/src/linux/drivers/net/wireless/realtek/rtw88' root@orangepiplus:/usr/src/linux# modinfo /usr/src/linux/drivers/net/wireless/realtek/rtw88/rtw88_8821au.ko filename: /usr/src/linux/drivers/net/wireless/realtek/rtw88/rtw88_8821au.ko license: Dual BSD/GPL description: Realtek 802.11ac wireless 8821au/8811au driver author: Bitterblue Smith <rtl8821cerfe2@gmail.com> ... alias: usb:v0BDAp0811d*dc*dsc*dp*icFFiscFFipFFin* depends: rtw88_usb,rtw88_8821a name: rtw88_8821au vermagic: 6.15.11 SMP mod_unload ARMv7 thumb2 p2v8 sudo make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- doesn't work. Needs fixing. So I just copied modules to system location : root@orangepiplus:/usr/src/linux# sudo cp /usr/src/linux/drivers/net/wireless/realtek/rtw88/*.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw88/ root@orangepiplus:/usr/src/linux# sudo depmod -a But loading failed as follows : root@orangepiplus:/usr/src/linux# sudo modprobe rtw88_8821au modprobe: ERROR: could not insert 'rtw88_8821au': Exec format error Aug 22 16:31:52 orangepiplus kernel: module rtw88_88xxa: .gnu.linkonce.this_module section size must match the kernel's built struct module size at run time It appears to be a structural issue, as I also tried building out-of-kernel module from lwfinger/rtw88 I also tried building on Nanopi-r5s. Each time Exec format error was observed despite the module was successfully built. Different analysis point to GCC version mismatch between kernel and build host, ABI incompatibility and subtle build failures, thus causing non-alignment with the kernel buid. Several other build flags were tried to align with the kernel, but in vain. The root cause was not found. I am running out of options now. Could community or development team point to correct approach building an in-kernel module on a running system in native environment ? PS : complementary information : when armbian headers were downloaded with armbian-config, the following build output was observed : /usr/lib/gcc/arm-linux-gnueabihf/12/cc1 -quiet -I ./scripts/include -I ./scripts/dtc/libfdt -imultilib . -imultiarch arm-linux-gnueabihf -D _LARGEFILE_SOURCE -D _FILE_OFFSET_BITS=64 -D NO_YAML -MMD scripts/dtc/.dtc.o.d scripts/dtc/dtc.c -quiet -dumpdir scripts/dtc/ -dumpbase dtc.c -dumpbase-ext .c -mfloat-abi=hard -mtls-dialect=gnu -mthumb -mlibarch=armv7-a+fp -march=armv7-a+fp -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -std=gnu11 -fomit-frame-pointer -o /tmp/ccY6Z3QK.s It may give some clues on the flags used. Edited Friday at 05:23 PM by y52 0 Quote
Werner Posted yesterday at 04:44 AM Posted yesterday at 04:44 AM If you build the module in question on the target machine, why do you use stuff like "ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-"? Doesn't make sense when building natively. 0 Quote
y52 Posted yesterday at 01:37 PM Author Posted yesterday at 01:37 PM (edited) I do agree, that it doesn't. But it looks like Armbian kernel is built with arm-linux-gnueabihf-gcc Taken unalignment problem the same flag was used with which the kernel and headers were built. It doesn't help either. Edited yesterday at 01:45 PM by y52 0 Quote
c0rnelius Posted yesterday at 02:10 PM Posted yesterday at 02:10 PM Why not do a PR and add the needed modules to the EDGE config? 0 Quote
y52 Posted 21 hours ago Author Posted 21 hours ago (edited) What a PR is ? Could you be more specific about your suggestion ? In fact, could this module be included into the next 6.15 EDGE build ? CONFIG_RTW88_8821AU=m I don't know if this module is indeed functional (I want to test it). As it is concurrent with Armbian supplied 88XXau for the same hardware, one of them needs to be disabled in /etc/modprobe.d/ either: # cat blacklist-88XXau.conf blacklist 88XXau or # cat blacklist-RTW88_8821AU.conf blacklist rtw88_8821au Edited 18 hours ago by y52 0 Quote
laibsch Posted 17 hours ago Posted 17 hours ago PR in this context is a "pull request" on github, you are telling us to pull some updates from your github code base 0 Quote
y52 Posted 16 hours ago Author Posted 16 hours ago Could your team make such a "pull request" ? Could you also drop the github link at the same time ? I shall try making it myself. 0 Quote
y52 Posted 3 hours ago Author Posted 3 hours ago In the meantime and in order digging further I've switched to gcc-13 to build module with the same version as the kernel : root@orangepiplus:/mnt/sda2/src/linux-6.15.4# gcc --version gcc (Debian 13.4.0-1) 13.4.0 Then I've downloaded headers with armbian-config to : /usr/src/linux-headers-6.15.4-edge-sunxi and proceeded with rebuild Using Official Headers cd /mnt/sda2/src/linux-6.15.4 make clean cp /usr/src/linux-headers-6.15.4-edge-sunxi/.config .config sed -i 's/^EXTRAVERSION =.*/EXTRAVERSION = -edge-sunxi/' Makefile make olddefconfig 787 make menuconfig 788 grep -E 'CONFIG_RTW88_CORE|CONFIG_RTLWIFI|CONFIG_RTW88_8821AU' .config make modules_prepare cp /usr/src/linux-headers-6.15.4-edge-sunxi/Module.symvers . make M=drivers/net/wireless/realtek/rtw88 modules -j$(nproc) sudo cp /boot/System.map-$(uname -r) /mnt/sda2/src/linux-6.15.4/System.map root@orangepiplus:/mnt/sda2/src/linux-6.15.4# sudo make M=drivers/net/wireless/realtek/rtw88 modules_install make[1]: Entering directory '/mnt/sda2/src/linux-6.15.4/drivers/net/wireless/realtek/rtw88' INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_core.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8822b.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8822bs.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8822bu.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8822c.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8822cs.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8822cu.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8723x.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8723d.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8723ds.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8723du.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8821c.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8821cs.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8821cu.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_88xxa.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8821a.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_8821au.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_sdio.ko INSTALL /lib/modules/6.15.4-edge-sunxi/updates/rtw88_usb.ko DEPMOD /lib/modules/6.15.4-edge-sunxi make[1]: Leaving directory '/mnt/sda2/src/linux-6.15.4/drivers/net/wireless/realtek/rtw88' sudo depmod -a But the resulting module failed loading again : root@orangepiplus:/mnt/sda2/src/linux-6.15.4# sudo modprobe rtw88_8821au modprobe: ERROR: could not insert 'rtw88_8821au': Exec format error Aug 24 12:08:53 orangepiplus kernel: module rtw88_core: .gnu.linkonce.this_module section size must match the kernel's built struct module size at run time It proves a structural mismatch again. Armbian built the 6.15.4-edge-sunxi kernel using Ubuntu's GCC 13 likely with plugins. GCC plugins randomize or instrument the layout of kernel structures — including struct module. It means, that you cannot reproduce the exact struct module layout unless you use the exact same GCC plugin configuration — which is not available to end users! Could it be fixed and what is the right approach to adding missing in-kernel modules from kernel sources or headers ? 0 Quote
c0rnelius Posted 2 hours ago Posted 2 hours ago Try the devel repo: https://github.com/lwfinger/rtw88 0 Quote
y52 Posted 1 hour ago Author Posted 1 hour ago It has been tried several times with similar results : On stable 6.12.35 The lwfinger/rtl8821au driver causes kernel exceptions (oops/panics) It doesn't survive simple lsmod. On kernel 6.15.4 : It fails inserting : root@orangepiplus:~# sudo cp /var/lib/dkms/rtw88/0.6/build/*.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw88/ root@orangepiplus:~# ls -al /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw88 total 23744 drwxr-xr-x 2 root root 4096 Aug 24 15:13 . drwxr-xr-x 6 root root 4096 Aug 21 21:02 .. -rw-r--r-- 1 root root 961676 Aug 24 15:13 rtw_8703b.ko -rw-r--r-- 1 root root 415924 Aug 24 15:13 rtw_8723cs.ko -rw-r--r-- 1 root root 991580 Aug 24 15:13 rtw_8723d.ko -rw-r--r-- 1 root root 416088 Aug 24 15:13 rtw_8723ds.ko -rw-r--r-- 1 root root 419968 Aug 24 15:13 rtw_8723du.ko -rw-r--r-- 1 root root 492256 Aug 24 15:13 rtw_8723x.ko -rw-r--r-- 1 root root 929420 Aug 24 15:13 rtw_8812a.ko -rw-r--r-- 1 root root 424112 Aug 24 15:13 rtw_8812au.ko -rw-r--r-- 1 root root 1271964 Aug 24 15:13 rtw_8814a.ko -rw-r--r-- 1 root root 420676 Aug 24 15:13 rtw_8814au.ko -rw-r--r-- 1 root root 900128 Aug 24 15:13 rtw_8821a.ko -rw-r--r-- 1 root root 422752 Aug 24 15:13 rtw_8821au.ko -rw-r--r-- 1 root root 1025348 Aug 24 15:13 rtw_8821c.ko -rw-r--r-- 1 root root 415504 Aug 24 15:13 rtw_8821cs.ko -rw-r--r-- 1 root root 421624 Aug 24 15:13 rtw_8821cu.ko -rw-r--r-- 1 root root 1217480 Aug 24 15:13 rtw_8822b.ko -rw-r--r-- 1 root root 415504 Aug 24 15:13 rtw_8822bs.ko -rw-r--r-- 1 root root 425156 Aug 24 15:13 rtw_8822bu.ko -rw-r--r-- 1 root root 1734256 Aug 24 15:13 rtw_8822c.ko -rw-r--r-- 1 root root 415504 Aug 24 15:13 rtw_8822cs.ko -rw-r--r-- 1 root root 420196 Aug 24 15:13 rtw_8822cu.ko -rw-r--r-- 1 root root 666896 Aug 24 15:13 rtw_88xxa.ko -rw-r--r-- 1 root root 7900876 Aug 24 15:13 rtw_core.ko -rw-r--r-- 1 root root 575660 Aug 24 15:13 rtw_sdio.ko -rw-r--r-- 1 root root 560804 Aug 24 15:13 rtw_usb.ko root@orangepiplus:~# sudo depmod -a $(uname -r) root@orangepiplus:~# sudo modprobe rtw_8821au modprobe: ERROR: could not insert 'rtw_8821au': Exec format error Aug 24 15:14:25 orangepiplus kernel: module rtw_core: .gnu.linkonce.this_module section size must match the kernel's built struct module size at run time 0 Quote
c0rnelius Posted 49 minutes ago Posted 49 minutes ago Before loading the module `sudo modprobe cfg80211` 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.