Building drivers with kernel modules

Hello,

I am currently working on snapping my application and found some great help here thanks to @kyrofa on the app side of my application.

Now, i need to build drivers from source that uses kernel modules.
I am using pc-kernel which is the kernel 4.4 with core16.

Building a driver can be achieved easily on an Ubuntu 16.04 that has the kernel modules.
Now, i dont want to build my snaps on this system, i want all my team to be able to build snaps with snapcore/snapcraft docker image.
On a docker container, i dont have my kernel modules.

Here is my approach on this problem:

  • I think that i need to use a gadget snap in order to install my drivers and then be able to use interfaces to do some slots. I have done that and it works when i am snapcrafting on Ubuntu 16.04.
  • Using such a gadget snap on my docker container, i think that i need to dump the kernel modules on my stage dir and then make my driver use those in order to build the correct version.

Do you think this is the good approach ?

Here is an example:

parts:
  spxlib:
    plugin: nil
    source: ./src/dataset_collector/cambridge_pixel/drivers/SPxBSLib
    override-build: |
      cp -r ./Drivers/Linux /usr/src/PlxSdk
      cd /usr/src/PlxSdk/Linux/Driver
      ./builddriver 9056

Here, builddriver build with the current system kernel modules. I know that i can change builddriver to use the right version of the kernel and $SNAPCRAFT_STAGE.

If this is the good approach, where to find the modules ? Should i use plugin dump and stage the modules ?

Or maybe i’ll need to work on the kernel snap part (which i want to avoid).

Thanks by advance.

Hello,

Just to follow this thread we ended up installing the drivers in the kernel snap directly by using this repo: https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/xenial.

We had to modify the KConfig in serial drivers and adding the sources in drivers/tty/serial.

I dont know if this will help someone, i just wanted to say that this is fixed.

2 Likes