Programming RPi on Arch Linux

I got a new Raspberry Pi complete with the sunfounder sensor kit for my birthday this year. I’ve been wanting to delve into the world of embedded programming so this was a great gift for me. To start I’ve decided to go back and begin with bare metal programming.

I’m following the lead of the tutorial series here

The first thing I needed to do was unpack and install the ARM cross compiler from gcc. link

$ wget -O gcc-arm-none-eabi
$ tar -xzvf gcc-arm-none-eabi.tar.bz2

I wanted a root level directory to manage where I put system level cross compilers so I created /local and moved the folder there.

$ sudo mkdir /local
$ mv gcc-arm-none-eabi /local

Finally I needed to make sure that the binaries were in my PATH. I added this to the end of my .zshrc file. This would be .bashrc if you are not using ZSH or another alternative shell.

# Create variable for ARM path
# Add $ARM to PATH if it is a directory and it is not already in PATH
if [[ -d $ARM && -z %(echo $PATH | grep -o $ARM) ]]
	export PATH=${PATH}:$ARM

To test this working I simply type arm-none-eabi-gcc at the command line.

$ arm-none-eabi-gcc
arm-none-eabi-gcc: fatal error: no input files
compilation terminated

The recommended optimization flags for Rpi

# Recommended
-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
# Because -Ofast is known to cause issues we use O2 or O3
-O2 -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s

Published: September 27 2014

blog comments powered by Disqus