-
Notifications
You must be signed in to change notification settings - Fork 1
Software Compilation
See software design for more details on the actual software
This is just some background methods on getting arm-eabi-gcc
, new lib
etc. installed.
See Wim's gist for compiling arm-eabi-gcc
.
Wim's gist might also work here. Else we can always fall back to gcc4.0.2 binaries found on GNU ARM
You'll likely need to use --with-system-zlib
when configuring gcc.
Note: The version in apt called
arm-linux-eabi-gcc
is not what we want. Thelinux-eabi
part specifies that it createseabi
format files to run on a Linux kernel. We aren't running an OS on our boards so we wantarm-none-eabi-gcc
(usually shortened to justarm-eabi-gcc
) to createeabi
files to run on a bare metal ARM micro.
In the Software directory run make
. This produces a multitude of elf files in the build directory, one for each folder in Software/src
that contains a main.c
file.
For both programming and debugging we are using a combination of OpenOCD and arm-eabi-gdb.
The first step is to connect OpenOCD to the MCU, simply connect the USB-JTAG adaptor to your USB port and the JTAG header on the board, then open a new terminal in the Software
directory and run make ocd
. This will start up OpenOCD with the correct default settings.
Based on information from the SparkFun forums
The easiest way to install OpenOCD is if you're using Homebrew. Simply brew install openocd
. It's likely included in MacPorts and Fink as well. Alternatively you can just install libftdi, libusb and OpenOCD from source.
You'll probably want to be using USART on your programmer as well, assuming it's an FTDI2232 based programmer just install the FTDI Virtual COM Port Driver. Unfortunately this steals the JTAG part of the programmer and makes it appear as a serial port as well stopping OpenOCD from using it.
To fix this you simply need to edit the list of interfaces that it will auto-mount in /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist
and remove the A section of the programmer that you're using. The Universities programmers are listed as FT2232C so delete the FT2232C_A section, lines 1791-1807 as of version 2.2.16 of the driver. If you're using a different programmer then convert the VID and PID to a decimal number and find the section with the corresponding idVendor and idProduct and delete that A section.
To check if this has worked either reload the driver:
sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext
or just unplug and replug the programmer, then check which virtual COM ports have appeared with ls /dev/tty.usb*
To just program the MCU run
make program-<BINARY_NAME>
where <BINARY_NAME>
is the basename of the binary you want to program, e.g.
make program-sensor
to program board with the source code in the Software/src/sensor
folder.
To debug the program in GDB run
make debug-<BINARY_NAME>
where <BINARY_NAME>
is the same as above. This will connect GDB to OpenOCD, reset the MCU, program the binary then drop you into a GDB shell with the MCU halted at the resetHandler
.
The
[]
are not parts of these commands, they indicate optional parts of the command, e.g.info registers
is writteni[nfo] r[egisters]
, this means the commandi r
will do the same thing.
The simplest command required is
c[ontinue]
this simply resumes the MCU from the current program counter and runs it until you hit ^C
.
To step through the program you can use
step
to step a function at a time or
stepi
to step an instruction at a time.