Can not install in-tree kernel module

Hello,

I’m trying to install the https://github.com/torvalds/linux/tree/v5.2/drivers/net/can/peak_canfd kernel module on a Intel NUC microservices app.

I based myself on https://github.com/balena-io-playground/kernel-module-build

I copied the soource files and Makefile from the Linux source tree. And hardcoded the config in the Makefile to build as a module. So far so good, I have peak_pciefd.ko module file.

When the container starts up on balena run.sh it tells me:

insmod: ERROR: could not insert module peak_canfd_intel-nuc_2.47.1+rev1.prod/peak_pciefd.ko: Operation not permitted

I have also tried manually copying the .ko file to the Host OS and installing it there manually. But that gives me:

insmod: ERROR: could not insert module /peak_pciefd.ko: Unknown symbol in module

Now I don’t know what else to try to get our canbus card going. Help is very much appreciated.

Cheers,
Erik

Hi Erik, thanks for contacting support. I would first make sure that the module can be inserted from the hostOS as in your second comment above.
The “Unknown symbol in module” usually indicates that the kernel source you have compiled against does not match the running kernel in the device.
Please check that you have modified the VERSION argument in the Dockerfile from kernel-module-build to match the BalenaOS release the target device is running.

ENV VERSION '2.29.0+rev1.prod'

2.29.0+rev1.prod should match the release on your device.
Once you have rebuilt the module, see if the insmod in the hostOS works, and retry the insmod from the container, although the latter might be a different problem altogether.

Hi Alex,

I have solved the operation not permitted issue, I needed to make the container privileged. :roll_eyes: Now I have the same Unknown symbol error in the container. It’s progress.

The version is the same between my Dockerfile and the running Host OS. In fact I managed to get a different out of tree driver for a different canbus card installed with the same Dockerfile. The Unknown symbol must be casued by something else, is there a way I can get it to tell me which symbol is unknown? That would make searching quite a lot easier.

Cheers,
Erik

If you have the .ko file in the modules directory inside your container, can you use depmod(8) with the verbose flag? I think that should tell you more…

Ah I found the missing symbols in dmesg

[70534.022053] peak_pciefd: Unknown symbol can_put_echo_skb (err -2)
[70534.022080] peak_pciefd: Unknown symbol can_get_echo_skb (err -2)
[70534.022098] peak_pciefd: Unknown symbol can_len2dlc (err -2)
[70534.022115] peak_pciefd: Unknown symbol alloc_canfd_skb (err -2)
[70534.022142] peak_pciefd: Unknown symbol open_candev (err -2)
[70534.022169] peak_pciefd: Unknown symbol alloc_can_skb (err -2)
[70534.022186] peak_pciefd: Unknown symbol unregister_candev (err -2)
[70534.022205] peak_pciefd: Unknown symbol can_change_state (err -2)
[70534.022222] peak_pciefd: Unknown symbol can_change_mtu (err -2)
[70534.022242] peak_pciefd: Unknown symbol free_candev (err -2)
[70534.022259] peak_pciefd: Unknown symbol alloc_candev_mqs (err -2)
[70534.022281] peak_pciefd: Unknown symbol close_candev (err -2)
[70534.022302] peak_pciefd: Unknown symbol can_bus_off (err -2)
[70534.022322] peak_pciefd: Unknown symbol can_dlc2len (err -2)
[70534.022338] peak_pciefd: Unknown symbol alloc_can_err_skb (err -2)
[70534.022356] peak_pciefd: Unknown symbol register_candev (err -2)

Could it be that drivers/net/can/dev.c is not part of the kernel on Balena OS? I’m on balenaOS 2.47.1+rev1 Intel NUC.

hdid you make sure to load the generic can modules before?

Ah yeah that’s it.

So my run.sh now has:

modprobe can can-dev
insmod peak_pciefd.ko

Thanks for the help!