Cross-compiled Executable doesn't work on BB xm - Ubuntu 12.04

Hi guys,

I’m trying to get spi working on my bb xm.

I have Ubuntu 12.04 on it up and running.

On my host machine (ubuntu 12.04 32 bit), I gave the following command to obtain the spi test program: arm-linux-gnueabi-gcc Documentation/spi/spidev_test.c -o spitest

Then I moved spitest on the rootfs.

Once there, I have:

ubuntu@omap:/$ ls -lh spitest
-rwxr-xr-x 1 root root 13K Jul 29 04:57 spitest

But if I try to run it via ./spitest -D /dev/spidev3.0, I have the following response:

ubuntu@omap:/$ ./spitest -D /dev/spidev3.0
-bash: ./spitest: No such file or directory

If I use sudo, I obtained no answer, like this:

ubuntu@omap:/$ sudo ./spitest -D /dev/spidev3.0
[sudo] password for ubuntu:
ubuntu@omap:/$

On the bb xm I have:

ubuntu@omap:/$ uname -a
Linux omap 3.2.23-x14 #1 SMP Fri Jul 13 05:02:22 UTC 2012 armv7l armv7l armv7l GNU/Linux
ubuntu@omap:/$
ubuntu@omap:/$ file spitest
spitest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=0x61418d323abdbc761bbb22a963e3ca5bed

The weird detail is the output of the last command. It contains “for GNU/Linux 2.6.31” but the spitest executable was obtained against a more recent kernel:

daniele@sviluppo:~/bb/ubuntu/RobertCNelson/stable-kernel/KERNEL$ make kernelversion
3.2.23

As you can see, the kernel version on the host machine is the same on the bb xm.

So guys, do you know how can I fix this?

Thank you in advance,

Daniele

pastoreerrante <visaggio.daniele@gmail.com> writes:

Hi guys,

I'm trying to get spi working on my bb xm.

I have Ubuntu 12.04 on it up and running.

On my host machine (ubuntu 12.04 32 bit), I gave the following command to
obtain the spi test program: arm-linux-gnueabi-gcc
Documentation/spi/spidev_test.c -o spitest

Then I moved spitest on the rootfs.

Once there, I have:

ubuntu@omap:/$ ls -lh spitest
-rwxr-xr-x 1 root root 13K Jul 29 04:57 spitest

But if I try to run it via ./spitest -D /dev/spidev3.0, I have the
following response:

ubuntu@omap:/$ ./spitest -D /dev/spidev3.0
-bash: ./spitest: No such file or directory

This means the executable requested a dynamic linker (ELF interpreter)
you don't have. Find out what it's looking for with this command:

  readelf -l spitest | grep interpreter

On the bb xm I have:

ubuntu@omap:/$ uname -a
Linux omap 3.2.23-x14 #1 SMP Fri Jul 13 05:02:22 UTC 2012 armv7l armv7l
armv7l GNU/Linux
ubuntu@omap:/$
ubuntu@omap:/$ file spitest
spitest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.31,
BuildID[sha1]=0x61418d323abdbc761bbb22a963e3ca5bed

The weird detail is the output of the last command. It contains "for
GNU/Linux 2.6.31" but the spitest executable was obtained against a more
recent kernel:

daniele@sviluppo:~/bb/ubuntu/RobertCNelson/stable-kernel/KERNEL$ make
kernelversion
3.2.23

The "for 2.6.31" part means the executable might use system calls
available only in kernel 2.6.31 or later. Since your kernel is newer,
this is not a problem.

As you can see, the kernel version on the host machine is the same on the
bb xm.

So guys, do you know how can I fix this?

My guess is you have a hard/soft float ABI mixup.

Hi Mans,

thank you.

After installing elfutils on my bb xm, I ran your command:

ubuntu@omap:/$ eu-readelf -l spitest | grep interpreter
[Requesting program interpreter: /lib/ld-linux.so.3]

So my program was missing ld-linux.so.3. I search for it via apt-file:

ubuntu@omap:~$ apt-file search ld-linux.so.3
libc6: /lib/arm-linux-gnueabihf/ld-linux.so.3
libc6-armel: /lib/arm-linux-gnueabi/ld-linux.so.3
libc6-armel: /lib/ld-linux.so.3
libc6-armel-cross: /usr/arm-linux-gnueabi/lib/ld-linux.so.3

The obvious choice was to install libc6-armel, via apt-get.

This fixed my problem.

By the way with ubuntu 11.10 the exact same cross-compiling strategy (I did the same steps) worked. I wonder what changed between the two versions that led to this problem.

Best Regards,

Daniele

Hi Daniele,

After installing elfutils on my bb xm, I ran your command:

ubuntu@omap:/$ eu-readelf -l spitest | grep interpreter
        [Requesting program interpreter: /lib/ld-linux.so.3]

So my program was missing ld-linux.so.3. I search for it via apt-file:

ubuntu@omap:~$ apt-file search ld-linux.so.3
libc6: /lib/arm-linux-gnueabihf/ld-linux.so.3
libc6-armel: /lib/arm-linux-gnueabi/ld-linux.so.3
libc6-armel: /lib/ld-linux.so.3
libc6-armel-cross: /usr/arm-linux-gnueabi/lib/ld-linux.so.3

The obvious choice was to install libc6-armel, via apt-get.

This fixed my problem.

By the way with ubuntu 11.10 the exact same cross-compiling strategy (I did
the same steps) worked. I wonder what changed between the two versions that
led to this problem.

Well, 11.10 is armel, while the 12.04 image is armhf which use
ld-linux-armhf.so.3... So the real FIX is to use an armhf based cross
compiler... Not that the extra 'hardfloat' stuff would matter for
your spitest program... :wink:

Regards,

Hi Robert,

Thanks for the hint. So I will switch to gcc-arm-linux-gnueabihf

Best Regards

hello pastoreerrante

i switched to arm-linux-gnueabihf and immediately solved the problem, same as yours.earlier i was compiling on my own built gcc i.e. CLFS, which was soft .thanks