This website is out of date
PLEASE VISIT
THE NEW WEBSITE
critter board

Compiling a Program, Linux users

The quickest way to get started is to download the pre-built toolchain from www.gunarm.com. Follow the link at the top of the screen labled files, and scroll down to the binaries section. We've been using the GCC-3.4 toolchain and it seems solid. But if you have a 64 bit machine you might have to use the GCC-4.0 version, which should work fine too.

Open up a terminal and unpack the downloaded file in a directory of your choosing:


$ tar xvjf bu-2.15_gcc-3.4.3-c-c++-java_nl-1.12.0_gi-6.1.tar.bz2

A directory called gnuarm-3.4.3 is created. In this directory is another directory called bin. The bin directory contains the actual tools used to compile a program. This directory must be added to the path so that we can use these tools. For a bash shell we use the 'export' command:


$ export PATH=/home/[your user name]/gnuarm-3.4.3/bin:${PATH}

Now try the command arm-elf-gcc:


$ arm-elf-gcc
arm-elf-gcc: no input files

If it says no input files, then everything is working, and your ready to compile programs.

To try out the toolchain, download the example program to a directory of your choosing. Open a terminal, unpack the archive. A directory HelloSineWave is created. Move to the directory, and run make:


$ tar xvf HelloSineWave.tar
$ cd HelloSineWave
$ make

If you get an error 'arm-elf-gcc: command not found' open the file called 'makefile' and change the third line from 'CC = arm-elf-gcc' to 'CC = arm-elf-gcc-4.0.0', and try it again.

If everything goes smootly, there should now be a file 'main.hex' in the directory, and you're ready to move to the upload step.

a little background on the build process...

The program make looks for a Makefile script which contains all the details of the compilation process. It then invokes the necessary commands (from the GNU toolchain that we just downloaded) to build the final .hex file from the source files.

Basically it breaks down like this: the individual .c files are compiled to create .o files. Then these .o files are linked together to create a single binary file. This file is then converted to the .hex format. Take a look at the Makefile to see more details.

Once you have successfully compiled the example program type: make clean. This command removes all the compiled .o files. It is a convinient way to compile everything from scratch. (make uses the modified time of files to determine what source files need to be compiled. If those times get mixed up, things can get screwy. So it's always a good idea to run make clean to bring everything up to date.)