out of tree kernel module compilation on Olimage/bullseye fails - solved.

Started by winfried, January 08, 2024, 12:54:02 AM

Previous topic - Next topic

winfried

Trying to compile my kernel_driver gpioASR [1] on Olimage/bullseye for driving gpios the compilation failed, which worked with previous Armbian/stretch .
Tried with a minimal source (see below) and also failed with:

./include/linux/compiler.h:248:10: fatal error: asm/rwonce.h: No such file or directory

also at the beginning it noted:

ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

This is because there is no "asm/..." in the `linux-headers-olimex` like expected und running the above hint dropped the same errors.

So I followed Olimage Documentation to cross-compile the kernel and Build own headers package [3], which made the above errors go away, so the "asm/rwonce.h" was installed, but dropped now:

  CC [M]  /home/algo/lkm_test/lkm_test.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[2]: *** [scripts/Makefile.build:286: /home/algo/lkm_test/lkm_test.o] Error 126

The problem the program `fixdep`  is an "amd64" exec not "armhf" exec, so the script building the olimex headers did not cross-compile the helper binaries, which should also be fixed.

Anyway the question, is there anywhere a working linux-headers-5.10.180-olimex.deb or the like ?
If this is an issue, where can I file this issue to be fixed ?

minimal kernel module:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("w. ritsch");
MODULE_DESCRIPTION("Test kernel module for toolchain test");
MODULE_VERSION("0.1");
static int __init lkm_test_init(void) {
 printk(KERN_INFO "Test Kernel Modul loaded\n");
 return 0;
}
static void __exit lkm_test_exit(void) {
    printk(KERN_INFO "Test kernelmodul unloaded\n");
}
module_init(lkm_test_init);
module_exit(lkm_test_exit);
Makefile
obj-m += lkm_test.o
all:
        make ARCH=arm -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

[1] https://git.iem.at/ritsch/gpioASR

[2] https://docs.kernel.org/kbuild/modules.html#creating-a-kbuild-file-for-an-external-module

[3] https://github.com/OLIMEX/OLINUXINO/blob/master/DOCUMENTS/OLIMAGE/Olimage-guide.pdf

mfg winfried
---- Atelier Algorythmics --- [url="http://algo.mur.at/"]http://algo.mur.at/[/url] ----

winfried

Quote from: winfried on January 08, 2024, 12:54:02 AMThe problem the program `fixdep`  is an "amd64" exec not "armhf" exec, so the script building the olimex headers did not cross-compile the helper binaries, which should also be fixed.

After compiling the kernel on the A20 without CROSS_COMPILE, took about 8h, on an SD card:
EXTRA_VER=$(date +%Y%m%d-%H%M%S)
sudo make ARCH=arm -j2 bindeb-pkg LOCALVERSION=-olimex KDEB_PKGVERSION=$(make kernelversion)-$EXTRA_VER DTC_FLAGS=-@

the Debian packages for the header has been generated:

  • linux-headers-5.10.180-olimex_5.10.180-20240110-150051_armhf.deb 
  • linux-headers-olimex_5.10.180-20240110-150051_armhf.deb

and installed them and the kernel module, minimal and my own, compiled cleanly.

So now I have the kernel module, even if reported `tainted` on load, working without change.

The question remains, why the Olimex Debian repository does host broken kernel-headers, since their scripts generate working ones, is there another reason I do not know of ?

Anyhow, I change the state of this thread to "solved".

mfg winfried
---- Atelier Algorythmics --- [url="http://algo.mur.at/"]http://algo.mur.at/[/url] ----