I am planning to do some Rasperry Pi C/C++ kernel module development using BuildRoot 2015.08.1.

What works:

  • I can build a kernel and a rootfs and boot the Raspberry Pi.
  • I can build/rebuild a "hello world" using the BuildRoot toolchain either as a generic-package or an autotools-package.

What does not work:

  • I cannot include some kernel headers, for instance linux/module.h. The toolchain does not find this header file.

I had a look at output/staging/usr/include. I can find some linux headers, for instance linux/net.h. However others are not there, for instance linux/module.h.

The header I am looking for is present in the kernel source tree. However it does not appear to be installed to staging. I am not 100% sure that BuildRoot called "make headers_install", but it seems like a reasonable assumption. Would anyone have any pointers to how "make headers_install" selects the headers to be installed? Or am I missing something else?

  • An userspace program doesn't need the kernel headers. They are reserved for kernel core/drivers. – Alexandre Belloni Nov 24 '15 at 9:34
  • @AlexandreBelloni: Fair comment. I am actually trying to develop a kernel module. I edited the question to mention this. – marcv81 Nov 24 '15 at 12:49
  • @AlexandreBelloni actually that's not true, kernel utilities (e.g. dmraid) requires some aspects of the kernel headers (e.g. scsi/sg.h), as a matter of fact glibc does parse a host of kernel headers and deploys them as they provide the user-space kernel-space interconnect. – Ahmed Masud May 3 '18 at 16:07
  • And they are shipped by the libc, as you state so they are part of the toolchain provided by buildroot. – Alexandre Belloni May 4 '18 at 14:15

I cannot include some kernel headers, for instance linux/module.h. The toolchain does not find this header file.

Kernel module : The 'make' command has "internals" to do that. Works (only) if you are using a special »Kernel module Makefile« → →


  • you should give a little more details, your answer is berdering a link-only answer. – Archemar Nov 24 '15 at 14:05
  • It does solve my problem, thanks. Information about the internals would satisfy my curiosity and be very much appreciated. – marcv81 Nov 24 '15 at 14:18
  • It may work but this is probably using the headers from your host, not your target. – Alexandre Belloni Nov 25 '15 at 10:16

Here is a fully automated out-of-tree setup for kernel modules: https://github.com/cirosantilli/linux-kernel-module-cheat/blob/b89ba9b799480e4eb1975f0a704409efb7d667d1/kernel_module/external.mk

I've described a minimal version of that at: https://stackoverflow.com/questions/40307328/how-to-add-a-linux-kernel-driver-module-as-a-buildroot-package/43874273#43874273

The package type $(eval $(kernel-module)) basically sets up everything for us.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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