Problems compiling/loading out of tree kernel modules

Hi there,

I am trying to compile Realtek RTL8822bu and ath10k kernel modules of various wireless cards for RaspberryPi Computing Module 3+. I had done it last year and it worked, but it fails with recent kernels (with rebuilds of course). We use various mini PCIe cards if that matters (such as WPEQ-257ACN - QCA9882 2T2R AP-Mode Module | SparkLAN and WPET-236ACN(BT) - RTL8822BU 2T2R USB Module | SparkLAN which use Realtek and ath10k respectively). FWIW at least ath10k is already in the mainline kernel which is surprisingly missing from balena OS.

I am aware of GitHub - balena-os/kernel-module-build: Example project for building an OOT kernel module in balena. Initially I used that to compile GitHub - jeremyb31/rtl8822bu: RTL8822BU Wireless Driver for Linux. I have tried rebuilding for kernels 2.75.0+rev1 and 2.72.0+rev both production and development images. They build fine but produce segfaults upon insmoding in a container ( I try modprobing the dependencies such as cfg80211 first). Please see the attached text file for kernel ring logs upon insmod.
segfault.txt (76.7 KB)

I have tried compiling with the example project mentioned above and also with the make instructions from the wireguard example which is much simpler and straightforward (GitHub - klutchell/balena-wireguard: wireguard stack for balenacloud). I also tried cross-compiling the kernel module locally using the kernel-headers from the balena S3 (such as in the wireguard example, or by looking at the file and figuring it out). No matter what, I get the segfault on the same device which used to work.

Here are our two big pain points:

1- How to get rid of segfaults and make this work?
2- How to compile other drivers which support AP mode.

For AP mode I need to compile another driver such as GitHub - morrownr/88x2bu: Linux Driver for USB WiFi Adapters that are based on the RTL8812BU and RTL8822BU Chipsets or GitHub - cilynx/rtl88x2bu: rtl88x2bu driver updated for current kernels.. They don’t even compile with balena. The second one uses dkms and works perfectly fine on a debian, but I was unable to use dkms with balena example project.

I’d appreciate your support for solving these problems which could benefit anyone trying to get wireless support.

It would be also very helpful to provide customers with a template that allows easy compilation of in-kernel modules which are missing from balenaOS versions (such as ath10k). That will make working with balena more productive and increases adaption.

Hi, we are aware that building in-tree and out-of-tree kernel modules is one of the pain points of the platform and we are working towards a much smoother process.

If you require a specific in-tree networking driver we can include it as part of the standard BalenaOS release.

For the out-of-tree kernel modules, do you have the drivers building and working with a different distribution that also runs a 5.4 based kernel? You mention they work fine on Debian, what kernel version is this Debian version running?