Compiling a main tree kernel module using the kernel module build example

I’m trying to get the WiFi adapter module for the Dell Edge Gateway 3001 to work with Balena… I’m currently using the Intel NUC image, and it works great with the built-in ethernet adapter. Unfortunately for me, the WiFi adapter’s module is not included in the NUC build. It is, however, available in the Linux kernel code: https://github.com/torvalds/linux/tree/master/drivers/net/wireless/rsi

Instead of adding my own custom support in the kernel build script and having to maintain my own fork of the recipe, I was wondering if I could use the kernel-module-build container to somehow build and load the modules that exist in the kernel code.

Does that seem feasible somehow?

I went ahead and tried to bring in the rsi/ directory from the 4.18.14 kernel into the kernel-module-build example. Everything builds cool, but unfortunately I’m getting this now:

22.06.19 16:55:09 (-0600)  kernel-module-rsi  OS Version is 2.36.0+rev2
22.06.19 16:55:09 (-0600)  kernel-module-rsi  insmod: ERROR: could not insert module rsi_intel-nuc_2.36.0+rev2.prod/rsi_91x.ko: Unknown symbol in module
22.06.19 16:55:09 (-0600)  kernel-module-rsi  insmod: ERROR: could not insert module rsi_intel-nuc_2.36.0+rev2.prod/rsi_sdio.ko: Unknown symbol in module

Woot! It works! Had to manually insmod the mac80211 module in the host container before doing the RSI ones. However, I’m not sure how to get this to happen automatically.

FYI for anyone searching for info on the Dell Edge Gateway… I’ve decided to give up. I want to use the GPIO and it’s going to take a lot of effort to get the ad5593r module running. This device would be so great on Balena, but shoo… without a better way to bring in kernel modules, I’m out of time for it.

Hi @eliotlandrum ,

Many of the existing kernel drivers can’t be built using https://github.com/balena-io-projects/kernel-module-build, because often some dependencies in the kernel are not present.

Usually this project is used for user written modules. Depending on the complexity of the user written modules it could still happen that some kernel dependencies are not met.

If you want to add support for the Dell Edge Gateway 3001 board you could create a PR in here https://github.com/balena-os/balena-intel.

Regards!

Hi. What are the in tree kernel modules that you would need to have included in the OS?

Thanks, I will add it in there! It seems like it’d be a really stellar unit for Balena to support!

Well, for my uses, I was just looking at the GPIO (ad5592r ad5593r) which is in the Industrial I/O section of the kernel: https://github.com/torvalds/linux/tree/master/drivers/iio/dac. You can see the list of modules that the pre-installed Ubuntu Core 16 has (it’s not entirely clear to me that it needs ALL of these though):

admin@4H6QB02:~$ lsmod
Module                  Size  Used by
rfcomm                 69632  14
bnep                   20480  2
iTCO_wdt               16384  1
iTCO_vendor_support    16384  1 iTCO_wdt
dell_wmi               16384  0
sparse_keymap          16384  1 dell_wmi
arc4                   16384  2
dcdbas                 16384  0
intel_soc_dts_iosf     16384  0
intel_powerclamp       16384  0
coretemp               16384  0
kvm_intel             172032  0
ven_rsi_sdio           28672  0
kvm                   544768  1 kvm_intel
ven_rsi_91x            98304  1 ven_rsi_sdio
bluetooth             520192  36 bnep,ven_rsi_91x,rfcomm
irqbypass              16384  1 kvm
punit_atom_debug       16384  0
crct10dif_pclmul       16384  0
crc32_pclmul           16384  0
ghash_clmulni_intel    16384  0
mac80211              737280  1 ven_rsi_91x
cfg80211              565248  2 mac80211,ven_rsi_91x
aesni_intel           167936  0
aes_x86_64             20480  1 aesni_intel
lrw                    16384  1 aesni_intel
gf128mul               16384  1 lrw
input_leds             16384  0
glue_helper            16384  1 aesni_intel
ablk_helper            16384  1 aesni_intel
psmouse               131072  0
r8169                  81920  0
xr_usb_serial_common    45056  0
cryptd                 20480  3 ghash_clmulni_intel,aesni_intel,ablk_helper
cdc_acm                36864  0
mii                    16384  1 r8169
serio_raw              16384  0
lpc_ich                24576  0
snd_soc_rt5660         61440  0
snd_intel_sst_acpi     16384  0
snd_intel_sst_core     73728  1 snd_intel_sst_acpi
snd_soc_rl6231         16384  1 snd_soc_rt5660
snd_soc_sst_mfld_platform    90112  1 snd_intel_sst_core
st_accel_i2c           16384  0
st_pressure_i2c        16384  0
hts221_i2c             16384  0
st_accel               20480  1 st_accel_i2c
ad5593r                16384  0
i2c_hid                20480  0
st_pressure            16384  1 st_pressure_i2c
snd_soc_core          212992  2 snd_soc_rt5660,snd_soc_sst_mfld_platform
hts221                 16384  1 hts221_i2c
hid                   118784  1 i2c_hid
st_sensors_i2c         16384  2 st_pressure_i2c,st_accel_i2c
st_sensors             24576  2 st_pressure,st_accel
ad5592r_base           20480  1 ad5593r
industrialio_triggered_buffer    16384  3 st_pressure,hts221,st_accel
kfifo_buf              16384  1 industrialio_triggered_buffer
industrialio           61440  10 st_pressure_i2c,st_accel_i2c,st_sensors,industrialio_triggered_buffer,hts221_i2c,st_pressure,hts221,st_accel,kfifo_buf,ad5592r_base
snd_compress           20480  1 snd_soc_core
ac97_bus               16384  1 snd_soc_core
snd_pcm_dmaengine      16384  1 snd_soc_core
8250_fintek            16384  0
snd_pcm               106496  4 snd_soc_rt5660,snd_soc_core,snd_soc_sst_mfld_platform,snd_pcm_dmaengine
fjes                   28672  0
mei_txe                20480  0
snd_timer              32768  1 snd_pcm
tpm_crb                16384  0
mei                    98304  1 mei_txe
snd                    81920  5 snd_soc_core,snd_timer,snd_pcm,snd_soc_sst_mfld_platform,snd_compress
dw_dmac                16384  2
dw_dmac_core           24576  1 dw_dmac
i2c_designware_platform    16384  0
soundcore              16384  1 snd
mac_hid                16384  0
i2c_designware_core    20480  1 i2c_designware_platform
snd_soc_sst_acpi       16384  0
rfkill_gpio            16384  0
shpchp                 36864  0
spi_pxa2xx_platform    24576  0
8250_dw                16384  0
pwm_lpss_platform      16384  0
pwm_lpss               16384  1 pwm_lpss_platform
iptable_filter         16384  0
ip_tables              24576  1 iptable_filter
ip6table_filter        16384  0
ip6_tables             28672  1 ip6table_filter
x_tables               36864  4 ip6table_filter,ip_tables,iptable_filter,ip6_tables
autofs4                40960  2
sdhci_pci              28672  0
virtio_scsi            20480  0
usb_storage            69632  0
ahci                   36864  0
libahci                32768  1 ahci
mmc_block              36864  4
wmi                    20480  1 dell_wmi
video                  40960  1 dell_wmi
sdhci_acpi             16384  0
sdhci                  45056  2 sdhci_acpi,sdhci_pci
admin@4H6QB02:~$

ad5592r

@shaunmulligan this basically boils down on having the ad5592r module enabled in the kernel. What’s your thoughts on enabling this in the genericx86-64 image?

But that one also requires at least industrialio and ad5592r_base (reading through the lsmod dependencies there).

Correct there, apologies… it’s ad5593r and the ad5592r_base (swapped in the 2 on my post earlier – fixed it in an edit).

Yeah, if we decide to enable the ad5592r directly in the hostOS, it will have all the required dependencies added also.

1 Like

Created https://github.com/balena-os/balena-intel/issues/225 for this. Please track it for updates

@eliotlandrum

Can you please post the Makefile you used?

When adapting
https://github.com/torvalds/linux/tree/master/drivers/net/wireless/rsi

to be used with

Thanks

Hi @rlev -

I found the Makefile in some random corner of the web… it does show that I can redistribute it as long as I keep the copyright info, so I feel OK about sharing it. I can’t remember where I found it though.

I would post the complete bundle up on my GitHub, but I am unsure of the legality of redistributing the firmware files. You can get them from here - https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rsi

If you’re interested in what the whole thing looked like, here’s what I believe is the final working code. I was not able to use Balena in the end of this project because of the kernel needing GPIO, (which has been included now!). I was only working on this for a short term contract project between jobs.

  1. Taking the kernel-module-build example, add these directories: rsi/, mac80211/, firmware/.
  2. Copy the contents of the RSI kernel source into rsi/, replacing the Makefile with this one Makefile.log (4.4 KB) (renamed with a .log to get around the forum file filter).
  3. Copy the compiled mac80211.ko file from the existing kernel into a directory inside the container so that I could initialize it from this run script. There is probably a better way.
  4. Copy the RPS files to firmware/.
  5. Use the following Docker template and run script.

Dockerfile.template:

FROM balenalib/%%RESIN_MACHINE_NAME%%-debian

RUN apt-get update && apt-get install -y curl wget build-essential libelf-dev awscli bc flex libssl-dev python bison
COPY . /usr/src/app
WORKDIR /usr/src/app

ENV VERSION '2.36.0+rev2.prod'
RUN ./build.sh %%RESIN_MACHINE_NAME%% $VERSION rsi

CMD ./run.sh

run.sh:

#!/bin/bash
OS_VERSION=$(echo $RESIN_HOST_OS_VERSION | cut -d " " -f 2)
echo "OS Version is $OS_VERSION"

mkdir -p /lib/firmware/rsi
cp firmware/* /lib/firmware/rsi/

insmod mac80211/mac80211.ko

mod_dir="rsi_${RESIN_DEVICE_TYPE}_${OS_VERSION}*"
insmod $mod_dir/rsi_91x.ko
insmod $mod_dir/rsi_sdio.ko
lsmod | grep rsi

while true; do
  sleep 60
done

Hope this is of value to you!

Thank you @eliotlandrum

I will give it a try.