cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
wooki
Newbie
Newbie
229 Views
Registered: ‎07-28-2021

petalinux

Hello, I'm trying to execute binary file but I found the following error

"cannot execute binary file : Exec format error"

I read one solution that My ubuntu is 64-bit and Linux on the Zedboard is 32-bit.

so When compiled I used following option

"gcc -o filename filename.c -m32 "

but the same problem occur.
What should I do?

Thanks.

 

(Oh and that is the output of running uname -a in linux(zedboard)

" SMP PREEMPT Wed Jun 2 13:06:31 UTC 2021 armv7l armv7l armv7l GNU/Linux"

)

0 Kudos
1 Reply
rfs613
Scholar
Scholar
158 Views
Registered: ‎05-28-2013

Your ubuntu is almost certainly running on an Intel or AMD processor (and yes, it is 64-bits).
The Zedboard uses a different processor, ARM, which has a completely different binary instruction format.
So it is not only the 32 versus 64 bit, but the CPU architecture (ARM versus X86) that is different.
Binaries compiled for one CPU will not run on the other, and vice-versa.

You cannot use the "gcc" on your host to generate binaries for ARM. Instead, you must use a cross-compiler. And for various reasons, you should use the same cross-compiler that was used to build all the other code on your ZedBoard. Otherwise you will likely have issues due to different C library, different ABI, different floating point options, etc.

Please have a look at Petalinux UG1144 as a starting point. If you don't want to use the whole petalinux-build process, then you can still make use of the eSDK that it provides, which will give you a cross-compiler for building ARM binaries on your X86 host. See "Installing a Preferred eSDK as part of the PetaLinux Tool" in the same UG1144 document. You will want the "arm" variant (this is 32-bit ARM), not "aarch64" (which is 64-bit ARM).

[edit: grammar fixes]