So, actually I am using Raspberry Pi with OS version Stretch and kernel version 4.14.98-v7+.

I need to add kernel module for Wi-Fi module I use from this repo: https://github.com/LairdCP/Sterling-60-Release-Packages/releases

While on it, I check that it is supporting 4.19 kernel. I am thinking to download the Linux source for 4.19 kernel from this : https://github.com/raspberrypi/linux

I have read that I can build my own kernel: https://www.raspberrypi.org/documentation/linux/kernel/building.md

Is there a way to compile the kernel source including the external module?


2 Answers 2


My advice is to use Buildroot (https://buildroot.org) to create your custom OS and/or cross compilation toolchain on your computer. You'll be able to choose which package to include in your OS with :

make menuconfig

When you have successfully built your first os image, you can then customize the kernel with

make linux-menuconfig

Device drivers can be disabled, loaded as modules or included in kernel. You may need to add "recipe" for telling Buildroot how to build your module and add it to the kernel. Learning Buildroot can be harsh at the beginning but your goal seems to need that step.

  • What I want is really simple actually. I have tried to copy my needed driver from the vendor repo to linux source directory and add the Kconfig and Makefile to existing configuration. I can see my needed driver if I use make menuconfig. The problem is that the driver is not build. The .ko file is not generated although overall linux kernel compilation is success and I have verfy it with uname -a. Currently I am still confused why the driver is not compiled although I have added it to Kconfig and Makefile.
    – Bharata
    Jun 26, 2020 at 21:31
  • @Bharata Did you try to compile just your module with make modules SUBDIRS=module_directory or make /path/to/module.ko? Jul 1, 2020 at 8:56

I don't think you need to build a custom kernel at all. You need to build custom modules and load them in the stock kernel you already have.

Install kernel header files with sudo apt install raspberrypi-kernel-headers, and follow the instructions in the release documents to build the modules you need. This can be done directly on the Pi.

  • 1
    yes, actually i tried this and it works. so i think i will just compile the modules separately although my original plan is to integrate it to raspbian kernell tree so that in the future for our product, we just need to compile and install the kernel + the needed module in one go. Kinda like create our own customized kernel version.
    – Bharata
    Jul 1, 2020 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.