Building External Kernel Modules on the BBB with .h Files Involved...

Hello There,

I am building external kernel modules now. I was using make and at times Kbuild also with my Makefile. Anyway, is there a way to make header files available in the external kernel module building within a Makefile or a Kbuild file?

For instance:

I have kernel_char.c and kernel_char_one.h that I want to build into an external kernel module.

My userspace module needs to know of the kernel_char_one.h file just like my external kernel module called kernel_char.c. Is there a way to make these files understand each other via a Makefile and a Kbuild file?

Seth

P.S. I started an idea, questioning, on unix.stackexchange.com already and I was thinking since listings or examples are not available for my use case, I could turn here and reference where I did look:

a. kernel docs.
b. External Kernel Modules on the docs.
c. random sites around the internet.

Also…

Looking through the logs:

taints kernel shows up for one of my external kernel modules. It runs and works but creates issues with the internal components in a way that is marking the kernel as tainted.

Is there a reason why my external kernel module(s) are tainting the kernel?

Seth

You wouldn’t by accident have forgotten this line at the bottom of your driver, would you?
image

1 Like

I will report after checking…

I checked…I have it recorded in the file(s).

Take a look here and run the suggested script to reveal more…

Tainted kernels — The Linux Kernel documentation

1 Like

Thank you…I am reviewing it.

Hey there…I think I got to the point where I can ask specifics:

  1. There is no Makefile in /lib/modules/$(shell uname -r)/build or /lib/modules/$(shell uname -r)/.
  2. I use this command to make the Makefile available: sudo touch Makefile.

I am trying to build external kernel modules in a directory and getting more errors with Bullseye compared to Buster now:

make -C /lib/modules/`uname -r`/
 M=/home/debian/Move_to_Bullseye_BBB/kernel_modules/Kernel_Modules_One
make[1]: Entering directory '/lib/modules/5.10.168-ti-r82'
make[1]: *** No targets.  Stop.
make[1]: Leaving directory '/lib/modules/5.10.168-ti-r82'
make: *** [Makefile:6: default] Error 2

I had to make the /build/ dir. in the /lib/modules/5.10.x/.

Any feedback is welcomed.

Update

sudo apt install linux-headers-$(uname -r)

Blah…sorry.

Another Update

Still nothing. I moved to Bookworm. I will test another day.

Start here instead of walking the desert…

1 Like

I used that one already for Buster and got it. I tried with Bullseye and did not get it. I now have Bookworm on the BBB and will test in the future.

Seth