Writing Open Source Firmware

Eric Evenchick
2 min readJun 25, 2013

Methods for writing and publishing open source software are well established. Developers use open source tools to ensure anyone can build, modify, debug, and run the code. Sharing through a service like Github makes it easy for anyone to work on the project, and contribute their changes back.

Firmware isn't as easy. Many microcontrollers rely on proprietary tools. Often these tools are prohibitively costly. Also, many of them are not good at handling shared projects.

So how do you write firmware that can be distributed easily and freely?

Choose Chips with Open Source Support

Not all microcontrollers are supported equally, and some have amazing open source support. An open source toolchain will let you build, flash, and debug code from the command line.

The Arduino toolchain is probably the most common example. It targets the Atmel AVR family, which is supported by AVR-GCC for compilation and avrdude for flashing. The Texas Instruments MSP430 devices have GCC support, and mspdebug provides support for flashing and debugging. Finally, many ARM devices are supported by GCC, can be flashed with OpenOCD, and can be debugged using GDB.

Don’t Rely on an IDE

It’s fine to use an IDE to develop code, but relying on it for project management can cause problems. Most IDEs for embedded development are provided by the device vendors, and automatically generate the build environment, Makefiles, and dependencies. This is convenient, but inhibits users that cannot use that IDE.

Provide a README and a Makefile

Building a project should be as straightforward as possible. Providing a README explaining how to build the code and flash it to the target device can be very helpful. Since compilation can require specific options and flags, using make is one option for simplifying the build process. This ensures that the code gets built consistently.

Firmware Templates

After getting a variety of toolchains up and running, I decided to start collecting them under a project called uCtools. The idea behind the project is to provide starting points for firmware project that do not rely on proprietary tools. It provides Makefiles and documentation to get you started.

By choosing chips that have support, writing firmware that doesn't rely on a specific IDE, and including good documentation, you can ensure that others can build, modify, and debug your code using fully open source tools. This makes it easy to share and contribute; an ideal environment for open source hardware.

--

--

Eric Evenchick

Electrical Team Lead for @UWAFT,Studying Electrical Engineering at the University of Waterloo