ros-realtime / ros-realtime-rpi4-image

An image for the Raspberry Pi 4 with ROS 2 and Linux RT preinstalled
Apache License 2.0
202 stars 37 forks source link

/bin/sh: 1: scripts/basic/fixdep: Exec format error #77

Open alejomancinelli opened 1 month ago

alejomancinelli commented 1 month ago

Hello. I have a Raspberry Pi 4. I install the latest image and everything works wonderfully. However, I've been trying to install the EtherCAT IgH Master to control some motors with ROS2, and when I follow the installations steps I get the following error:

@pi:~/ethercat$ make modules
[...]
make -C "/usr/src/linux-headers-5.15.98-rt62-raspi/" M="/home/ubuntu/ethercat" INSTALL_MOD_DIR="ethercat" modules
make[1]: Entering directory '/usr/src/linux-headers-5.15.98-rt62-raspi'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: aarch64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
  You are using:           gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  CC [M]  /home/ubuntu/ethercat/examples/mini/mini.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
make[4]: *** [scripts/Makefile.build:297: /home/ubuntu/ethercat/examples/mini/mini.o] Error 126
make[4]: *** Deleting file '/home/ubuntu/ethercat/examples/mini/mini.o'
make[3]: *** [scripts/Makefile.build:560: /home/ubuntu/ethercat/examples/mini] Error 2
make[2]: *** [scripts/Makefile.build:560: /home/ubuntu/ethercat/examples] Error 2
make[1]: *** [Makefile:1907: /home/ubuntu/ethercat] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.98-rt62-raspi'
make: *** [Makefile:948: modules] Error 2

I read that it has something to do with how the kernel was cross-compile, where some files got the incorrect architecture. Have you seen something like this before?

PS: I also tried to cross-compile the IgH module, with a similar kernel source I was doing some tests on, but I got a permission denied error at some point. Maybe it could be resolved using the exact kernel version of the RPi, but I don't really know.

aatb-ch commented 4 weeks ago

hit the exact same issue when trying to install ethercat master, tried the alternative approach to install it via apt and hits same problem again. Seems to be related to the cross-compiled kernel yes, digging into this.. did you find a solution?

alejomancinelli commented 4 weeks ago

No, I'm sorry but I didn´t manage to find a solution. For the time being I was asked to "leave it for later", since I was wasting a lot of time without results. I also asked in the RPi forum and in the Ubuntu forum but got no answers as well.

If you manage to find a solution please let me know.

aatb-ch commented 4 weeks ago

going down the trail, per https://github.com/raspberrypi/linux/issues/4125, issue seems to be that there's some x86-64 binary linked during cross-compilation that wants to now run on arm64 hence the issue, I tried installing the rt kernel from the provided deb and this is included:

aatb@pi:/usr/src/linux-headers-5.15.98-rt62-raspi/scripts/basic$ file fixdep
fixdep: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=d2e54e65ed8cda9daaa1785e21e36845d6fc825e, for GNU/Linux 3.2.0, not stripped

figuring out the steps mentionned here https://stackoverflow.com/questions/73698666/kernel-module-on-cross-compile-kernel-bin-sh-1-scripts-basic-fixdep-exec-fo