Install linux headers for kernel module development


#1

I’m trying to compile v4l2loopback, a kernel module to allow for virtual video devices. ResinOS seems to be missing the build dir inside the kernel directory. Is there a way to install the headers on Resin? Could I add them to the SD card?


#3

Hi @CWright017,

Our current recommended approach is to use this project template. If you want to test it, the steps are:


#4

@lekkas thank you that’s amazing. Upon building the module, it has a Makefile with an install location of /lib/modules/build… but when I tired building the module in a separate docker file and copying it over to my resin container - that location was either missing or read only. Will this approach solve that?


#5

hi @CWright017 ,

The module build and install process will take place on our builders and the resulting module should end up under /lib/modules/$(shell uname -r)/build in the generated container image. So yes, adapting the template project and the respective example template Makefile to your own kernel module should work.


#6

@lekkas thanks for the update! Module build worked fine, I copied the build.sh script to my own project - although there is no /lib/modules/$(shell uname -r)/build dir only a /lib/modules/$(shell uname -r) dir, so using modprobe won’t work, but insmod seems to work fine.

I was just wondering, is the lack of build dir a raspian base image thing? Or have I missed a step?