Page 1 of 1

compiling examples from software pack

Posted: Sat Nov 09, 2013 12:23 am
by hasanijaz
Hi, I have a sam9g25ek board. I have downloaded the softpack from at91 website: http://www.atmel.com/tools/SAM9G25SOFTWAREPACKAGE.aspx

I was trying to compile it. By default the makefiles contain
CROSS_COMPILE=arm-none-eabi
The example gets compiled but when I try to run the elf file it gives Segmentation fault.

Motivated from this post:
forum/viewtopic.php/t,20616/
I also tried to set
CROSS_COMPILE=arm-none-linux-gnueabi-

Now it does not compile and gives the following error:
/opt/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: error: no memory region specified for loadable section `.plt'
collect2: ld returned 1 exit status
make: *** [ddram] Error 1


what am I missing?

Re: compiling examples from software pack

Posted: Sat Nov 09, 2013 1:21 am
by blue_z
hasanijaz wrote:The example gets compiled but when I try to run the elf file it gives Segmentation fault.
If you're getting a "Segmentation fault", then you're probably running with virtual memory, i.e. a Linux environment.
As I already responded to you in that other thread:

> Those are bare-metal (i.e. standalone, does not use an operating system) programs.
> Look at the code you are trying to compile. Are there direct accesses to peripheral registers/locations?
> You cannot do that from userland in Linux, so that would not be a Linux app.
hasanijaz wrote: Now it does not compile and gives the following error:
/opt/arm-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/../../../../arm-none-linux-gnueabi/bin/ld: error: no memory region specified for loadable section `.plt'
collect2: ld returned 1 exit status
make: *** [ddram] Error 1
You cannot use the makefile of a standalone program with a compiler that links with Linux libraries.
hasanijaz wrote:what am I missing?
A standalone program simply cannot be compiled for execution under an OS.
The standalone program would have to be rewritten (aka ported) for that OS.
You need to compile and execute these standalone programs from the softpack as intended and no other way (unless you know what you are doing).

Regards

Re: compiling examples from software pack

Posted: Sat Nov 09, 2013 4:34 pm
by CptTitanic
As bluez indicates, bare-metal targeted code isn't a good place to start for Linux apps.

Try experimenting with a simple "Hello World" app, you should be able to compile and link that, and test it under Linux.

Consider if gcc would be better than ld for linking in makefile examples.

For hardware level code, start by examining the board/chip level code within the kernel, and drivers.

Re: compiling examples from software pack

Posted: Wed Nov 13, 2013 12:10 pm
by hasanijaz
Thanks! I dint know what bare metal meant so now I just compiled a simple hello world and it worked.