Bare metal programming environment for SAMA5D3/4

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

Nicholas.Campbell
Posts: 1
Joined: Mon Aug 01, 2016 1:00 am

Bare metal programming environment for SAMA5D3/4

Sun Aug 14, 2016 10:03 pm

Hi,
For a few weeks now I have been trying to setup an IDE in order to create my own c code that can run on an SAMA5D44 Xult board. I am running Eclipse mars and have installed GNU ARM eclipse from the eclipse marketplace. I have also installed the following items on my machine for the eclipse environment, GNU ARM build tools, gcc-arm-none-eabi and win avr. With all these items installed I am able to load the preexisting code getting-started example from the soft pack for the board and build it to generate a binary file that can then be loaded onto the board.

Currently, I'm trying to create my own code for the board to see if I can link the required libraries required for the embedded environment. I have been unsuccessful due to errors generated and I would like any help that can be offered in getting a binary file generated for the test code. Below I've included the c file that I'm trying to create a binary for and the generated errors.

Code: Select all

int main(){
	return 0;
}
  • 17:02:02 **** Incremental Build of configuration Debug for project test ****
    make all
    Building file: ../main.c
    Invoking: Cross ARM C Compiler
    arm-none-eabi-gcc -mcpu=cortex-a5 -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -std=gnu11 -MMD -MP -MF"main.d" -MT"main.o" -c -o "main.o" "../main.c"
    Finished building: ../main.c

    Building target: test.elf
    Invoking: Cross ARM C++ Linker
    arm-none-eabi-g++ -mcpu=cortex-a5 -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -Xlinker --gc-sections -Wl,-Map,"test.map" -o "test.elf" ./main.o
    c:/program files (x86)/gnu tools arm embedded/5.4 2016q2/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7-ar/thumb\libg.a(lib_a-exit.o): In function `exit':
    exit.c:(.text.exit+0x1c): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status
    makefile:56: recipe for target 'test.elf' failed
    make: *** [test.elf] Error 1

    17:02:03 Build Finished (took 1s.47ms)


Thanks,
tsvoipio
Posts: 53
Joined: Wed Aug 19, 2015 9:44 pm

Re: Bare metal programming environment for SAMA5D3/4

Mon Aug 15, 2016 12:13 pm

The library coming with the GNU toolset includes a default startup module calling main(). The external reference to _exit() in in the library startup module. It is not suitable for bare-metal startup, so you need to tailor your own for the hardware at hand. The startup module needs to populate the stack pointer and startup link locations in the exception vector and set up the initialized data in RAM from a copy in Flash. It is also advisable to clear the uninitialized data section (.bss), as many library functions rely on uninitialized variables being zero.

This implies also that you have to adjust the linker script to match your hardware.

In my experience, the most difficult task in starting up SAM4's was to command the clock setup correctly. If you kill the clock, you have to erase the whole chip to make even JTAG work. The hardware documentation in the data sheets was inaccurate.
blue_z
Location: USA
Posts: 1507
Joined: Thu Apr 19, 2007 10:15 pm

Re: Bare metal programming environment for SAMA5D3/4

Mon Aug 15, 2016 9:08 pm

Nicholas.Campbell wrote:Invoking: Cross ARM C++ Linker
arm-none-eabi-g++ -mcpu=cortex-a5 -mthumb -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -g3 -Xlinker --gc-sections -Wl,-Map,"test.map" -o "test.elf" ./main.o
What's in your Makefile that invokes arm-none-eabi-g++?

Regards

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 1 guest