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.