Beckhoff / BBAPI

Beckhoff BIOS API Linux Kernel Driver
Other
25 stars 9 forks source link

Exec format error #4

Closed stefanpoeter closed 5 years ago

stefanpoeter commented 6 years ago

I got a 'exec format error' when i try to install the module.

Kernel: 4.9.0-6-rt-amd64

I would expect that to happen on a different processor architecture like arm but the module is compiled on the same machine.

pbruenn commented 6 years ago

Hmm, did you double check, that you build with the correct Kernel headers?

stefanpoeter commented 6 years ago

I compiled it on the target device. Didn't it use uname -r to include the header files?

pbruenn commented 6 years ago

I had a similar issue once. make clean solved it for me. Did you try that already?

stefanpoeter commented 6 years ago

Probably, but I'll try again.

stefanpoeter commented 6 years ago
make -C /lib/modules/4.9.0-6-rt-amd64/build M=/home/user/bbap modules
make[1]: Verzeichnis „/usr/src/linux-headers-4.9.0-6-rt-amd64“ wird betreten
  CC [M]  /home/user/bbap/api.o
  CC [M]  /home/user/bbap/simple_cdev.o
  LD [M]  /home/user/bbap/bbapi.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/user/bbap/bbapi.mod.o
  LD [M]  /home/user/bbap/bbapi.ko
make[1]: Verzeichnis „/usr/src/linux-headers-4.9.0-6-rt-amd64“ wird verlassen

looks fine to me

make install
rmmod bbapi_disp
rmmod: ERROR: Module bbapi_disp is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi_power
rmmod: ERROR: Module bbapi_power is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi_sups
rmmod: ERROR: Module bbapi_sups is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi_wdt
rmmod: ERROR: Module bbapi_wdt is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi
rmmod: ERROR: Module bbapi is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
mkdir -p /lib/modules/4.9.0-6-rt-amd64/extra/
cp ./bbapi.ko /lib/modules/4.9.0-6-rt-amd64/extra/
depmod -a
modprobe bbapi
modprobe: ERROR: could not insert 'bbapi': Exec format error
Makefile:12: die Regel für Ziel „install“ scheiterte
make: *** [install] Fehler 1
pbruenn commented 6 years ago

please try: make clean && make C=1 && make install

stefanpoeter commented 6 years ago
make C=1
make -C /lib/modules/4.9.0-6-rt-amd64/build M=/home/user/bbap modules
make[1]: Verzeichnis „/usr/src/linux-headers-4.9.0-6-rt-amd64“ wird betreten
  CHECK   /home/user/bbap/api.c
/bin/sh: 1: sparse: not found
/usr/src/linux-headers-4.9.0-6-common-rt/scripts/Makefile.build:298: die Regel für Ziel „/home/user/bbap/api.o“ scheiterte
make[4]: *** [/home/user/bbap/api.o] Fehler 127
/usr/src/linux-headers-4.9.0-6-common-rt/Makefile:1515: die Regel für Ziel „_module_/home/user/bbap“ scheiterte
make[3]: *** [_module_/home/user/bbap] Fehler 2
Makefile:150: die Regel für Ziel „sub-make“ scheiterte
make[2]: *** [sub-make] Fehler 2
Makefile:8: die Regel für Ziel „all“ scheiterte
make[1]: *** [all] Fehler 2
make[1]: Verzeichnis „/usr/src/linux-headers-4.9.0-6-rt-amd64“ wird verlassen
Makefile:9: die Regel für Ziel „all“ scheiterte
make: *** [all] Fehler 2
stefanpoeter commented 6 years ago

Installed sparse and now the original error again:

make install
rmmod bbapi_disp
rmmod: ERROR: Module bbapi_disp is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi_power
rmmod: ERROR: Module bbapi_power is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi_sups
rmmod: ERROR: Module bbapi_sups is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi_wdt
rmmod: ERROR: Module bbapi_wdt is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
rmmod bbapi
rmmod: ERROR: Module bbapi is not currently loaded
Makefile:12: die Regel für Ziel „install“ scheiterte
make: [install] Fehler 1 (ignoriert)
mkdir -p /lib/modules/4.9.0-6-rt-amd64/extra/
cp ./bbapi.ko /lib/modules/4.9.0-6-rt-amd64/extra/
depmod -a
modprobe bbapi
modprobe: ERROR: could not insert 'bbapi': Exec format error
Makefile:12: die Regel für Ziel „install“ scheiterte
make: *** [install] Fehler 1
stefanpoeter commented 6 years ago

This might help:

[ 661.251890] bbapi: disagrees about version of symbol module_layout [ 679.562827] bbapi: disagrees about version of symbol module_layout

pbruenn commented 6 years ago

Hmm, that sounds familiar and I thought a simple make clean or manually deleting Module.symvers within the bbapi repo did solve it for me. I am pretty sure it is related to a polluted build directory somehow. https://unix.stackexchange.com/questions/125624/unable-to-load-module-disagrees-about-version-of-symbol-module-layout https://stackoverflow.com/questions/2720177/module-layout-version-incompatibility

stefanpoeter commented 6 years ago

I read that too, but they are talking about a self compiled kernel. I just installed the RT Kernel from the Debian Repos so I don't have any kernel source lying around.

pbruenn commented 6 years ago

But you did a reboot already, didn't you? https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=857354

try modprobe -f bbapi.ko https://askubuntu.com/questions/14627/no-symbol-version-for-module-layout-when-trying-to-load-usbhid-ko

stefanpoeter commented 6 years ago

But you did a reboot already, didn't you? https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=857354

Several times.

try modprobe -f bbapi.ko https://askubuntu.com/questions/14627/no-symbol-version-for-module-layout-when-trying-to-load-usbhid-ko

Will try that next week.

Am I correct in my assumption, that during the build a wrong crc is created from scripts/mod/modpost -m? What could be the cause of this? I am just trying to understand what is going on here.

pbruenn commented 6 years ago

I think you have an old Module.symvers from a previous build in your bbapi directory. At least that's what I remember when I had similar issues.