0

i have an original module in debian 10 on a beaglebone black and now i am running it on debian 9.5 with a different kernel. So when i try to insert the module i get this error:

insmod: ERROR: could not insert module gpio_test.ko: Invalid module format

My current kernel version is:

uname -r 4.4.155-ti-rt-r155

I have tried to follow the solution posted here but with no luck: insmod error: inserting './hello.ko': -1 Invalid module format"

my current Makefile contents are:

obj-m+=gpio_test.o

all:
        make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean

when i run this make file i get this error:

make -C /lib/modules/4.4.155-ti-rt-r155/build/ M=/home/machinekit/BeagleBoneBlack-Program-Files/LKM_Interrupt_Practice/LED_Button_IRQ modules
make[1]: *** /lib/modules/4.4.155-ti-rt-r155/build/: No such file or directory.  Stop.
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 2

Any help will be appreciated, thank you.

programmer25
  • 375
  • 1
  • 2
  • 14
  • 1
    A module built for one kernel cannot be inserted into another kernel. You need to build the module against the kernel you want to load it. Building a module requires **kernel sources** to be available. And `-C` parameter should point to the sources tree of the kernel. – Tsyvarev Aug 24 '20 at 21:42
  • @Tsyvarev isnt `make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules` already pointing to the source tree? – programmer25 Aug 24 '20 at 22:33
  • It’s pointing to non-existing folder. – 0andriy Aug 25 '20 at 06:40
  • Is there a `linux-headers-4.4.155-ti-rt-r155` package you can install? – Ian Abbott Aug 25 '20 at 14:43
  • @IanAbbott hello, my current struggle is finding one. Even the command `apt search linux-headers-$(uname -r)` does not find any – programmer25 Aug 25 '20 at 16:07
  • How do you obtain that kernel (`4.4.155-ti-rt-r155`)? The way of obtaining its sources depends on that. – Tsyvarev Aug 25 '20 at 19:20
  • @Tsyvarev I got the kernel with this command `./update_kernel.sh --ti-rt-channel --lts-4_4` and i followed the tutorial from this link: [link](https://machinekoder.com/machinekit-debian-stretch-beaglebone-black) check under "Install the RT Kernel" section – programmer25 Aug 25 '20 at 19:52
  • Hm, as far as I understand that tutorial tells only about obtaining of the **kernel image**. But says nothing about obtaining sources (build tree) for that image. – Tsyvarev Aug 25 '20 at 20:09
  • @programmer25 The page you linked to contains a [link](https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#BBW.2FBBB_.28All_Revs.29_Machinekit) to a ready made MachineKit system image based on the 4.19.106-bone-rt-r49 kernel. Does that image contain the kernel headers needed to build external kernel modules? – Ian Abbott Aug 26 '20 at 14:13
  • @IanAbbott Hi, i have tried that as well but i don't think it has it either since i still had the same issue with it. I am now currently trying to build a kernel which already has the PREEMPT RT patch. I was told that if i built the kernel than the linux headers would be there. But i ran into some compiler issues: [link](https://stackoverflow.com/questions/63600175/cross-compiler-error-for-arm-beaglebone-black) – programmer25 Aug 26 '20 at 14:49

0 Answers0