Custom ResinOS (https://github.com/resin-os/resin-intel) with additional kernel parameters is created. This is compiled, config injected and installed on one-to-many devices.
The goal is to include support for CAN bus which requires CONFIG_CAN in the kernel and can-utils. If the CAN support comes from kernel or from a loaded kernel modules does not matter.
From what I can read, the https://github.com/resin-io-playground/kernel-module-build build system will allow me to build a kernel module. This then needs to be included in a docker images and ensure that the docker image is run’ed --privileged.
You could clone that, copy over the source for the CAN bus module, install the developer tools to have all compiler & make and so on, apt-get install can-utils, build the module from your Dockerfile.template, and finally modprobe the module from the bash script that starts your app – and you should be good to go!
That is pretty clever. I managed to compile kernel modules this morning, but I will for sure adapt this dockerfile to automate kernel module building into the application container.
I found that I was missing can.ko and can-raw.ko from net/can. I already got slcan from drivers/net/can
When adding these to the application image then the network is stopped by a kernel bug/panic. This kernel bug is reported for net/netlink/af_netlink.c:1315. The modules are still being compiled and runned on 2.13.1+rev1.dev resinOS image
Note: Target is unaccesable after kernel bug/panic. A re-installation is needed
From my understanding then CAN supported can only be available if can.ko (CONFIG_CAN) raw and can-raw.ko (CONFIG_CAN_RAW) are provided by the kernel and not being loaded by via kernel modules. Then it is up to resin users to compile what ever CAN driver they need. I my case slcan.
Just a quick update to let you know that CAN drivers are included in the latest resinOS 2.13.6 intel NUC release. Let us know if you have a chance to try the image out.
Initial tests show that these modules works as expected. The initial test uses can.ko, can-raw.ko and slcan.ko which is to be used in the final docker container. I will need to create a docker container which load and use these modules in order to be sure all works as expected.
One question:
Will the CAN resinOS provided kernel modules be available and persist in all future resinOS releases?
The provided CAN kernel modules by resinOS is working as expected. Has been tested on a CAN network with 15+ CAN nodes.
To other users. Generally do not use custom ResinOS if possible if you want a resin upgradable and managed device from the Dashboard, supervisor api or python SDK.
Kernel builder docker file is still valid for custom kernel modules. For my use case the ch341 usb serial driver was needed. Custom build into the container and insmod used to load it from container.