Develop for Cortex-M4

In order to develop for ARM Cortex-M4 microcontroller using free and open-source tools, please follow these instructions.

Toolchain
RuuviTracker is developed with Summon-arm-toolchain. It is a script to download and build Open Source toolchain for ARM microcontrollers. There is also other possibilities but we like to stick with this one, since it's multi platform. It is bash-script so it requires Unix machine, OS X or Linux preferred.


 * See README from Summon-arm-toolchain

Building of Summon-arm-toolchain requires hour or two. Go get some coffee while doing it.

Build on OS X (using Macports)
$ port install git $ port install gmp mpfr libmpc wget libftdi git-core py27-yaml python_select $ git clone https://github.com/esden/summon-arm-toolchain.git $ cd summon-arm-toolchain $ ./summon-arm-toolchain SUDO=sudo PREFIX=/usr/local OOCD_EN=0 LIBOPENCM3_EN=0 DARWIN_OPT_PATH=/opt/local/
 * Install Xcode + command line tools
 * Install MacPorts
 * Open terminal:
 * Ready

Build on OS X (using Homebrew)
$ brew install gmp mpfr libmpc wget libftdi $ git clone https://github.com/esden/summon-arm-toolchain.git $ cd summon-arm-toolchain $ ./summon-arm-toolchain PREFIX=/usr/local OOCD_EN=0 LIBOPENCM3_EN=0
 * Install Xcode + command line tools
 * Install Homebrew
 * Open terminal:
 * Ready

Build on Linux (Debian compatible)
$ sudo apt-get install git $ sudo apt-get build-dep gcc-4.5 git zlib1g-dev python-yaml $ sudo apt-get install flex bison libgmp3-dev libmpfr-dev libncurses5-dev \ libmpc-dev autoconf texinfo build-essential libftdi-dev zlib1g-dev \ git zlib1g-dev python-yaml $ git clone https://github.com/esden/summon-arm-toolchain.git $ cd summon-arm-toolchain $ ./summon-arm-toolchain SUDO=sudo PREFIX=/usr/local OOCD_EN=0 LIBOPENCM3_EN=0
 * Open shell:
 * (It seems that zlib1g-dev and python-yaml packages are not needed for the build-dep step.)
 * Ready

IDE
None is preferred. Use what you like. Build scripts are used for building.

Flashing
Easiest way to flash RuuviTracker's MCU is to do it through DFU. DFU flahing doesn't require extra wiring, just standard Micro-USB cable. In addition to JTAG / SWD connectors, there is also STM's USART1 bus available.

Instructions to flash the device using DFU method.

Debugging
For example Olimex's ARM-USB-OCD-H dongle + OpenOCD is proven to work like a charm.

CodeBench (Mac OS X, Windows, Linux)
Mentor offers free GCC toolchain called Sourcery CodeBench Lite Edition for ARM EABI. There is installation files available for both, Windows and Linux. Download and install it.

We prefer version 2011.03-42 since there is some problems with the newer ones. Download link: https://sourcery.mentor.com/sgpp/lite/arm/portal/release1802

If you are running 64-bit operating system (Ubuntu for example), you might need to install 32-bit libraries in order to install the toolchain. This is done for example running command "apt-get install ia32-libs". More information: https://sourcery.mentor.com/GNUToolchain/kbentry62

Yagarto (Mac OS X and Windows)
Yagarto is pre-build toolchain for ARM. Very much similar to summon-arm-toolchain but currently it is not supporting harware floating points.
 * Download http://www.yagarto.de/

Compiling of eLua has been tested on following environment:
 * Mac Os X 10.8.2
 * Yagarto 16.06.2012
 * Binutils-2.22
 * GCC-4.7.1

Some extra links
Toolchain, debugging, flashing etc...

Some good links: http://www.triplespark.net/elec/pdev/arm/stm32.html