Re: HelloWorld cross complied for pandaboard

1,274 views
Skip to first unread message

David Anders

unread,
Aug 2, 2012, 5:37:06 PM8/2/12
to panda...@googlegroups.com
becket,

you need to provide is with the commands you are trying to use to do the cross compile. based on your description, i suspect you are not cross compiling the code, but using the native compiler from your host pc.

Dave


On Thursday, August 2, 2012 3:11:38 PM UTC-5, beckett wrote:
Hi,
I am trying to get started with some development on a Pandaboard. I have a simple HellowWorld program and Ubuntu 12.04 Precise Pangolin desktop on the PandaBoard. I can compile and run the program fine on the pandaboard but I am having difficulty cross compiling on a Ubuntu 12.04 desktop on a PC. I have tried the following:
(1). Using  the tool chain from CodeSourcery; The resulting application will not run on the PandaBoard, it returns -bash: HelloWorld.elf no such file or directory. If I use rpath to set the path to the rootfs and subsequently copy the rootfs supplied with CodeSourcery to the PandaBoard then the resulting application runs okay.
(2). I can also do the same with the Linaro Toolchain and rootfs
What I would really like to do is develop an application to run on the Ubuntu distibution on the PandaBoard but I would like to compile on mu Ubuntu PC. I tried scratchbox2 with the a rootfs for arm downloaded from http://cdimage.ubuntu.com/ubuntu-core/releases/12.04/release/ but as I have to specify the compiler I ended up with the same issue: HelloWorld.elf no such file or directory.
I also tried suggestions at;
and

http://biffengineering.com/wiki/index.php?title=HowToSetupCrossCompileEnvironment

but I think many of the references are to deprectiated or non functional tools.

Is there a particular toolchain I can use to cross compile for PandaBoard on a Ubuntu 12.04 PC or is there a configuration I need to use. I'm pretty knew to linux development and would appreciate any insights.

 

Joshi, Vikas

unread,
Aug 2, 2012, 11:12:08 PM8/2/12
to panda...@googlegroups.com

What is the command you are using to compile?

 

It would help if you can also send the output of “which  <your-compile-command-name>” so that we make sure the location of your compiler.

I suspect although you have codeSourcery installed your path might be pulling up default compiler from /usr/bin.

 

Vikas

Gary Thomas

unread,
Aug 3, 2012, 7:38:17 AM8/3/12
to panda...@googlegroups.com


On Thursday, August 2, 2012 2:11:38 PM UTC-6, beckett wrote:
Hi,
I am trying to get started with some development on a Pandaboard. I have a simple HellowWorld program and Ubuntu 12.04 Precise Pangolin desktop on the PandaBoard. I can compile and run the program fine on the pandaboard but I am having difficulty cross compiling on a Ubuntu 12.04 desktop on a PC. I have tried the following:
(1). Using  the tool chain from CodeSourcery; The resulting application will not run on the PandaBoard, it returns -bash: HelloWorld.elf no such file or directory. If I use rpath to set the path to the rootfs and subsequently copy the rootfs supplied with CodeSourcery to the PandaBoard then the resulting application runs okay.
(2). I can also do the same with the Linaro Toolchain and rootfs
What I would really like to do is develop an application to run on the Ubuntu distibution on the PandaBoard but I would like to compile on mu Ubuntu PC. I tried scratchbox2 with the a rootfs for arm downloaded from http://cdimage.ubuntu.com/ubuntu-core/releases/12.04/release/ but as I have to specify the compiler I ended up with the same issue: HelloWorld.elf no such file or directory.

The most likely cause of this problem is a mismatch of runtime libraries.  By default, Linux programs use shared libraries, i.e. actual library code is only referenced, not linked into your program.  At runtime, the system provides those libraries as needed.
Probably your cross-compile tools are referencing a particular library, or even a particular version of a library, which is not available on the PandaBoard.

Try this:
  % ldd <your-hello-world-program>
which will list the names of the shared libraries that are used, including the absolute path to the library.  If the system can't find a library, this will be shown

Nicolas Dechesne

unread,
Aug 3, 2012, 11:15:29 AM8/3/12
to panda...@googlegroups.com
12.04 is using hard-float ABI. So I would bet you have cross compiled
using a soft-float ABI.

if you use ubuntu 12.04 on your PC, to cross compile hello world:

- apt-get install gcc-arm-linux-gnueabihf
- compile your .c file with arm-linux-gnueabihf-gcc

if you don't use Ubuntu, you can download a standalone linaro-gcc
release from http://www.linaro.org/downloads/.

beckett

unread,
Aug 3, 2012, 1:15:43 PM8/3/12
to panda...@googlegroups.com
Thanks to all who replied:
I was able to compile using ndec's recommended arm-linux-gnueabihf-gcc
So here is my makefile

CC_LINARO=~/Development/ArmDevelopment/Linaro/gcc-linaro-arm-linux-gnueabi-2012.04-20120426_linux/bin/arm-linux-gnueabi-gcc
CC_SOURCERY=~/CodeSourcery/CodeSourceryPro/bin/arm-none-linux-gnueabi-gcc
CC_GNUEABIHF=/usr/bin/arm-linux-gnueabihf-gcc
DEBUG = -g
ROOTFS_SOURCERY = /sourcery/libc
ROOTFS_LINARO = /linaro/libc
CFLAGS=-Wall $(DEBUG) -D_REENTRANT -mcpu=cortex-a9 -mthumb -O0
LFLAGS_SOURCERY = -Wall $(DEBUG) -Wl,-rpath=$(ROOTFS_SOURCERY)/lib:$(ROOTFS_SOURCERY)/usr/lib -Wl,--dynamic-linker=$(ROOTFS_SOURCERY)/lib/ld-linux.so.3
LFLAGS_LINARO = -Wall $(DEBUG) -Wl,-rpath=$(ROOTFS_LINARO)/lib/arm-linux-gnueabi:$(ROOTFS_LINARO)/usr/lib -Wl,--dynamic-linker=$(ROOTFS_LINARO)/lib/ld-linux.so.3
LFLAGS_GNUEABIHF = -Wall $(DEBUG)
all: linaro sourcery gnueabihf
linaro:HelloWorld.c
        $(CC_LINARO) $(CFLAGS) $(LFLAGS_LINARO) HelloWorld.c -o HelloWorldLinaro.elf 
sourcery:HelloWorld.c
        $(CC_SOURCERY) $(CFLAGS) $(LFLAGS_SOURCERY) HelloWorld.c -o HelloWorldSourcery.elf
gnueabihf:HelloWorld.c
        $(CC_GNUEABIHF) $(CFLAGS) $(LFLAGS_GNUEABIHF) HelloWorld.c -o HelloWorldGnueabihf.elf 
clean:
    rm -f *.elf

All of these work on a Pandaboard running Ubuntu 12.04 Precise Pangolin desktop, but linaro and sourcery only work if you copy the appropriate rootfs to the locations referenced in the rpath. The gnueabihf will work with the default rootfs on the Ubuntu 12.04 Precise Pangolin desktop image. This is what I was looking for.
Just for your interest running ldd on each executable gives the following

ldd HelloWorldGnueabihf.elf
    libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6dfd000)
    /lib/ld-linux-armhf.so.3 (0xb6ef1000)

ldd HelloWorldLinaro.elf
    not a dynamic executable

ldd HelloWorldSourcery.elf
    not a dynamic executable

Running file on each of the executables on the host or target gives

file HelloWorldLinaro.elf
HelloWorldLinaro.elf: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=0x588c..., not stripped

file HelloWorldGnueabihf.elf
HelloWorldGnueabihf.elf: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=0x5b09..., not stripped

file HelloWorldSourcery.elf
HelloWorldSourcery.elf: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped

I don't understand the significance of Hard Float ABI at this point but I will check into it a little more. Thanks for all your help.

On Friday, August 3, 2012 4:15:29 PM UTC+1, ndec wrote:

Nicolas Dechesne

unread,
Aug 3, 2012, 1:21:18 PM8/3/12
to panda...@googlegroups.com
On Fri, Aug 3, 2012 at 7:15 PM, beckett <johno...@gmail.com> wrote:
> Thanks to all who replied:
> I was able to compile using ndec's recommended arm-linux-gnueabihf-gcc

cool.

>
> I don't understand the significance of Hard Float ABI at this point but I
> will check into it a little more. Thanks for all your help.

check this out: http://wiki.debian.org/ArmHardFloatPort/
Reply all
Reply to author
Forward
0 new messages