# Linux Kernel Module Cheat

##### 38.15.2.1. kernel_modules buildroot package

Source: buildroot_packages/kernel_modules/

An example of how to use kernel modules in Buildroot.

Usage:

    ./build-buildroot \
      --build-linux \
      --config 'BR2_PACKAGE_KERNEL_MODULES=y' \
      --no-overlay \
      -- \
      kernel_modules-reconfigure \
    ;

Then test one of the modules with:

    ./run --buildroot-linux --eval-after 'modprobe buildroot_hello'

Source: buildroot_packages/kernel_modules/buildroot_hello.c

As you have just seen, this sets up everything so that modprobe can correctly find the module.

`./build-buildroot --build-linux` and `./run --buildroot-linux` are needed because the Buildroot kernel modules must use the Buildroot Linux kernel at build and run time, see also: Buildroot vanilla kernel.

The `--no-overlay` is required otherwise our `modules.order` generated by `./build-linux` and installed with `BR2_ROOTFS_OVERLAY` overwrites the Buildroot generated one.

Implementattion described at: https://stackoverflow.com/questions/40307328/how-to-add-a-linux-kernel-driver-module-as-a-buildroot-package/43874273#43874273