Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile problems with native raspberry pi

The problem

We are trying to compile the spi_slave code on a raspberry pi. We used the native gcc compiler and the compile runs without any errors.

The problem is when I try to run the output:

/home/pi/spi_slave# ./build/output.elf Segmentation fault

/home/pi/spi_slave# ./build/kernel.img bash: ./build/kernel.img: cannot execute binary file

Tried to download the arm-none-eabi compiler from cambridge but it wont run: /home/pi/spi_slave# ../arm-2008q3/bin/arm-none-eabi-gcc bash: ../arm-2008q3/bin/arm-none-eabi-gcc: cannot execute binary file

Sourcecode

The code we are trying to compile is: http://tylernichols.me/wp-content/uploads/2012/11/raspberry_pi_bare_metal_spi_slave.zip

The only change we did was in the makefile, added a # in front of the ARMGNU var

#ARMGNU = arm-none-eabi

Environement

# uname -a
Linux raspberrypi 3.6.11+ #371 PREEMPT Thu Feb 7 16:31:35 GMT 2013 armv6l GNU/Linux

What am I doing wrong?

We have tried to find answers on google and stackoverflow for hours now without success. :/

like image 538
stamp Avatar asked Mar 21 '26 03:03

stamp


1 Answers

arm-none-eabi is a non-linux compiler. It is for bare-metal applications. The difference is in the C library. However, gcc is intimately linked to the C library for normal compiles.

Then there is the code. It is not written for Linux. It is written for a bare-metal application. You need to load and run the code from the Raspberry-Pi boot loader (berryboot?) without Linux.

You can use the ARM Linux compiler to create code for a bare-metal application. However, it is probably easier for you to find a newlib compiler that is targeted for the Raspberry Pi. You can search for one on the web or try to build one yourself.

See: How to build gcc for Raspberry Pi and Bare-metal gcc.

like image 117
artless noise Avatar answered Mar 24 '26 21:03

artless noise