LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 04-09-2013, 05:09 AM   #1
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 442

Rep: Reputation: 17
compiling hello world C program for arm ARM926EJ-S rev 5 (v5l) with arm-linux-gnueabi


I would like to compile a simple hello world example for my arm board I have its toolchain which works great but I want to compile my hello world with general arm-linux-gnueabi-gcc package of ubuntu but I had no success on it I have this error on my board:
Quote:
-sh: ./hello: cannot execute binary file
these are my informations which may help you to help me:
Quote:
cat /proc/cpuinfo
Processor : ARM926EJ-S rev 5 (v5l)
BogoMIPS : 197.83
Features : swp half fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 5
compiling with general arm-linux-gnueabi-gcc of ubuntu:

Quote:
$ arm-linux-gnueabi-gcc -Q -v -mfloat-abi=soft -mcpu=arm926ej-s hello.c -o hello
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabi/4.6/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.6.3 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-float=softfp --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include --with-headers=/usr/arm-linux-gnueabi/include --with-libs=/usr/arm-linux-gnueabi/lib
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
COLLECT_GCC_OPTIONS='-Q' '-v' '-mfloat-abi=soft' '-mcpu=arm926ej-s' '-o' 'hello' '-mfpu=vfpv3-d16' '-mthumb'
/usr/lib/gcc/arm-linux-gnueabi/4.6/cc1 -v -imultilib . -imultiarch arm-linux-gnueabi hello.c -dumpbase hello.c -mfloat-abi=soft -mcpu=arm926ej-s -mfpu=vfpv3-d16 -mthumb -auxbase hello -version -fstack-protector -o /tmp/ccU56dCs.s
GNU C (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (arm-linux-gnueabi)
compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/include"
ignoring nonexistent directory "/usr/include/arm-linux-gnueabi"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/arm-linux-gnueabi/4.6/include
/usr/lib/gcc/arm-linux-gnueabi/4.6/include-fixed
/usr/arm-linux-gnueabi/include
/usr/include
End of search list.
GNU C (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (arm-linux-gnueabi)
compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
options passed: -v -imultilib . -imultiarch arm-linux-gnueabi hello.c
-mfloat-abi=soft -mcpu=arm926ej-s -mfpu=vfpv3-d16 -mthumb
-fstack-protector
options enabled: -fauto-inc-dec -fbranch-count-reg -fcommon
-fdelete-null-pointer-checks -fdwarf2-cfi-asm -fearly-inlining
-feliminate-unused-debug-types -ffunction-cse -fgcse-lm -fident
-finline-functions-called-once -fira-share-save-slots
-fira-share-spill-slots -fivopts -fkeep-static-consts -fleading-underscore
-fmath-errno -fmerge-debug-strings -fmove-loop-invariants -fpeephole
-fprefetch-loop-arrays -freg-struct-return -fsched-critical-path-heuristic
-fsched-dep-count-heuristic -fsched-group-heuristic -fsched-interblock
-fsched-last-insn-heuristic -fsched-rank-heuristic -fsched-spec
-fsched-spec-insn-heuristic -fsched-stalled-insns-dep -fshow-column
-fsigned-zeros -fsplit-ivs-in-unroller -fstack-protector
-fstrict-volatile-bitfields -ftrapping-math -ftree-cselim -ftree-forwprop
-ftree-loop-if-convert -ftree-loop-im -ftree-loop-ivcanon
-ftree-loop-optimize -ftree-parallelize-loops= -ftree-phiprop -ftree-pta
-ftree-reassoc -ftree-scev-cprop -ftree-slp-vectorize
-ftree-vect-loop-version -funit-at-a-time -fvar-tracking
-fvar-tracking-assignments -fzero-initialized-in-bss -mglibc
-mlittle-endian -msched-prolog -mthumb -mvectorize-with-neon-quad
Compiler executable checksum: c2a3eee802c1f4bc82a4d015bd8c8d6f
main
Analyzing compilation unit
Performing interprocedural optimizations
<*free_lang_data> <visibility> <early_local_cleanups> <whole-program> <inline>Assembling functions:
main
Execution times (seconds)
parser : 0.01 (100%) usr 0.00 ( 0%) sys 0.01 (50%) wall 282 kB (21%) ggc
TOTAL : 0.01 0.00 0.02 1313 kB
COLLECT_GCC_OPTIONS='-Q' '-v' '-mfloat-abi=soft' '-mcpu=arm926ej-s' '-o' 'hello' '-mfpu=vfpv3-d16' '-mthumb'
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/as -mcpu=arm926ej-s -mfloat-abi=soft -mfpu=vfpv3-d16 -meabi=5 -o /tmp/ccY0ERq5.o /tmp/ccU56dCs.s
COMPILER_PATH=/usr/lib/gcc/arm-linux-gnueabi/4.6/:/usr/lib/gcc/arm-linux-gnueabi/4.6/:/usr/lib/gcc/arm-linux-gnueabi/:/usr/lib/gcc/arm-linux-gnueabi/4.6/:/usr/lib/gcc/arm-linux-gnueabi/:/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/
LIBRARY_PATH=/usr/lib/gcc/arm-linux-gnueabi/4.6/:/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/:/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/
COLLECT_GCC_OPTIONS='-Q' '-v' '-mfloat-abi=soft' '-mcpu=arm926ej-s' '-o' 'hello' '-mfpu=vfpv3-d16' '-mthumb'
/usr/lib/gcc/arm-linux-gnueabi/4.6/collect2 --build-id --no-add-needed --as-needed --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X --hash-style=gnu -m armelf_linux_eabi -z relro -o hello /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/crt1.o /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/crti.o /usr/lib/gcc/arm-linux-gnueabi/4.6/crtbegin.o -L/usr/lib/gcc/arm-linux-gnueabi/4.6 -L/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib -L/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib -L/lib/arm-linux-gnueabi -L/usr/lib/arm-linux-gnueabi -L/usr/lib -L/lib /tmp/ccY0ERq5.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/arm-linux-gnueabi/4.6/crtend.o /usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/lib/../lib/crtn.o





$ readelf -A hello
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3-D16
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_CPU_unaligned_access: v6
Tag_DIV_use: Not allowed


then scp hello binary file to arm board:
Quote:
# ./hello
-sh: ./hello: cannot execute binary file
compiling with arm-linux-gnueabi-gcc which is my arm board toolchain:
Quote:

/home/al/art/usr/local/arm-linux-gnueabi-gcc hello.c -o hello -Q -v
Using built-in specs.
Target: arm-linux-gnueabi
Configured with: /home/ace.yang/toolchain/cross/targets/src/gcc-4.3.3/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabi --prefix=/usr/local/ --with-sysroot=/usr/local//arm-linux-gnueabi//sys-root --enable-languages=c,c++,fortran,java --disable-multilib --with-float=soft --with-pkgversion=Artila-crosstool --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --with-gmp=/home/ace.yang/toolchain/cross/targets/arm-linux-gnueabi/build/static --with-mpfr=/home/ace.yang/toolchain/cross/targets/arm-linux-gnueabi/build/static --enable-threads=posix --enable-target-optspace --with-local-prefix=/usr/local//arm-linux-gnueabi//sys-root --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.3.3 (Artila-crosstool)
COLLECT_GCC_OPTIONS='-o' 'hello' '-Q' '-v' '-mfloat-abi=soft'
/home/ali/artila/usr/local/bin/../libexec/gcc/arm-linux-gnueabi/4.3.3/cc1 -v -iprefix /home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/ -isysroot /home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root hello.c -dumpbase hello.c -mfloat-abi=soft -auxbase hello -version -o /tmp/ccBxAq8b.s
ignoring nonexistent directory "/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/local//arm-linux-gnueabi//sys-root/include"
ignoring duplicate directory "/home/ali/artila/usr/local/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabi/4.3.3/include"
ignoring duplicate directory "/home/ali/artila/usr/local/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabi/4.3.3/include-fixed"
ignoring duplicate directory "/home/ali/artila/usr/local/bin/../lib/gcc/../../lib/gcc/arm-linux-gnueabi/4.3.3/../../../../arm-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/include
/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/include-fixed
/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/../../../../arm-linux-gnueabi/include
/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/include
End of search list.
GNU C (Artila-crosstool) version 4.3.3 (arm-linux-gnueabi)
compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-48), GMP version 4.3.2, MPFR version 3.0.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
options passed: -v -iprefix
/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/
-isysroot /home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root
hello.c -mfloat-abi=soft
options enabled: -falign-loops -fargument-alias -fauto-inc-dec
-fbranch-count-reg -fcommon -fearly-inlining
-feliminate-unused-debug-types -ffunction-cse -fgcse-lm -fident -fivopts
-fkeep-static-consts -fleading-underscore -fmath-errno
-fmerge-debug-strings -fmove-loop-invariants -fpeephole
-freg-struct-return -fsched-interblock -fsched-spec
-fsched-stalled-insns-dep -fsigned-zeros -fsplit-ivs-in-unroller
-ftoplevel-reorder -ftrapping-math -ftree-cselim -ftree-loop-im
-ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops=
-ftree-reassoc -ftree-scev-cprop -ftree-vect-loop-version -fvar-tracking
-fzero-initialized-in-bss -mglibc -mlittle-endian -msched-prolog
-mthumb-interwork
Compiler executable checksum: c3bbbe8141d41807857b09ceff9e7a7e
main
Execution times (seconds)
preprocessing : 0.01 (100%) usr 0.00 ( 0%) sys 0.00 ( 0%) wall 74 kB (11%) ggc
parser : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.02 (100%) wall 138 kB (20%) ggc
TOTAL : 0.01 0.00 0.02 681 kB
COLLECT_GCC_OPTIONS='-o' 'hello' '-Q' '-v' '-mfloat-abi=soft'
/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/../../../../arm-linux-gnueabi/bin/as -mfloat-abi=soft -meabi=4 -o /tmp/cc2ocnTf.o /tmp/ccBxAq8b.s
COMPILER_PATH=/home/ali/artila/usr/local/bin/../libexec/gcc/arm-linux-gnueabi/4.3.3/:/home/ali/artila/usr/local/bin/../libexec/gcc/:/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/../../../../arm-linux-gnueabi/bin/
LIBRARY_PATH=/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/:/home/ali/artila/usr/local/bin/../lib/gcc/:/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/lib/:/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/lib/
COLLECT_GCC_OPTIONS='-o' 'hello' '-Q' '-v' '-mfloat-abi=soft'
/home/ali/artila/usr/local/bin/../libexec/gcc/arm-linux-gnueabi/4.3.3/collect2 --sysroot=/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root --eh-frame-hdr -dynamic-linker /lib/ld-linux.so.3 -X -m armelf_linux_eabi -o hello /home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/lib/crt1.o /home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/lib/crti.o /home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/crtbegin.o -L/home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3 -L/home/ali/artila/usr/local/bin/../lib/gcc -L/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/lib -L/home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/lib /tmp/cc2ocnTf.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/ali/artila/usr/local/bin/../lib/gcc/arm-linux-gnueabi/4.3.3/crtend.o /home/ali/artila/usr/local/bin/../arm-linux-gnueabi//sys-root/usr/lib/crtn.o





readelf -A hello
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "ARM9TDMI"
Tag_CPU_arch: v4T
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_enum_size: int
then scp hello binary file to arm board:
Quote:

# ./hello
hello !!!
I have to say I have tested all of arm9 parameter for mcpu and armv4 parameters for march but none of them worked.
I can see so many differences but I don't know how can I solve it

thanks for any help
 
Old 04-10-2013, 02:14 PM   #2
vbsaltydog
Member
 
Registered: Nov 2005
Distribution: CentOS
Posts: 141

Rep: Reputation: 15
Try:

add-apt-repository ppa:germia/archive3
apt-get update
apt-get install gcc-arm-none-eabi binutils-arm-none-eabi newlib-arm-none-eabi gdb-arm-none-eabi

Then compile with CROSS_COMPILE=arm-none-eabi-
 
Old 04-23-2013, 10:30 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
There are so many variants of ARM CPUs and other elements: CPU version, ABI, Floating point support, endianness, etc, that not all toolchains for ARM are anything like equal. Your case is evidence of this. Since you evidently do have one working cross toolchain, I don't really see what the problem is.

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
arm-none-linux-gnueabi-gcc???? mosol2005 Ubuntu 1 12-23-2012 07:18 PM
difference b/w arm-iwmmxt-linux-gnueabi-gcc & arm-linux-gcc ravi_shanker Linux - Software 1 09-12-2011 10:30 AM
Compiling debian arm for NSLU2 - arm-linux-gnueabi-objdump not found ergosteur Linux - Kernel 3 10-30-2010 11:24 AM
arm-none-linux-gnueabi/bin/ld: cannot find -lbluetooth feiyinziiu Linux - Embedded & Single-board computer 4 10-18-2009 01:30 AM
arm-none-linux-gnueabi/bin/ld: cannot find -lbluetooth feiyinziiu Programming 1 10-17-2009 11:03 PM


All times are GMT -5. The time now is 12:52 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration