For embedded test-driven development in C, you need to use a unit test framework to make testing easier. This can take some work to set up. I've created a reproducible environment with Vagrant that you can start using in just a few simple steps.
At some point, though, you'll need to download to some real hardware. That's why this environment supports the TI Tiva C Series Launchpad board (EK-TM4C123GXL). You can build and load to the target from this environment.
This build environment requires that Vagrant and Virtualbox are installed. Virtualbox 5.0 is supposed to add support for USB 3.0, but I've only been able to get this environment program to the Launchpad board when it's connected to a USB 2.0 port.
It's Go Time
- Get the source. Either clone with git (https://github.com/ElectronVector/tiva-launchpad-tdd.git) or download.
- Start the environment with
- Log in to the environment with
vagrant sshand switch to the example project folder with
- Run the unit tests with
- Load the program onto the Launchpad over USB with
The LED on the Launchpad should flash between red, green and blue.
How it Works
This is a Linux environment hosted by Virtualbox and configured with Vagrant. When you first create the environment, Vagrant installs and configures everything we're going to need, including:
- The GCC ARM Embedded Cortex-M4 compiler from ARM.
- The Ceedling unit test framework.
- The lm4flash flashing utility.
Ceedling is used for unit tests. It compiles the tests with the native GCC compiler and runs them in the Linux host environment for speed.
Ceedling is also used to build the target binaries. It has been configured to use the GCC ARM Embedded compiler for this.
A custom Rake task (
load) has also been added to do the flashing of the Launchpad board with lm4flash.
For more details, check out the repository on GitHub.