« Back to “GPRS Boat”

Libraries for microcontroller software

I originally intended to have the boat in water by June.. well, didn't happen. The software has been taking a lot more time than I estimated, mostly because of NIH-syndrome.

For the purpose of learning things, I want to implement everything on the STM32. I could have bought a beagleboard or a gumstix, throw the software together in Python, and be done with it. I might even end up doing that anyway.

In the meanwhile, I have been spending my time hacking up a few libraries that I need to get the software done.


I still can't believe that there is no defacto small device libc, with only minimal functions and dependencies. There is Newlib, which has a lot of features, compiling to over 200 kB on the STM32, if you include everything. Even the very basic stuff such as printf ends up taking > 10 kB. There are many libraries for embedded linux systems, such as dietlibc, but those are on a whole different scale from my 256 kB ROM limit. SDCC even includes some libc functions for microcontrollers, but I'm using GCC.

I took the core functions from klibc (don't confuse with kLIBC) and stripped out any syscall stuff except for _fread and _fwrite, which the user must provide. I also added a simple Makefile for compiling and an option for using the excellent tinyprintf module.

The license is GPL, as inherited from klibc and tinyprintf. Get it on GitHub.


I originally started implementing an ASCII-based protocol, similar to FTP. However, it would have been inefficient (I pay per each megabyte in GPRS transfer) and bug-prone. Instead, Google's Protocol Buffers seemed a lot better alternative.

There was but a small problem: the smallest implementation, protobuf-c, weighs in at 20 kB. It would have fit, but what's the fun in that? Instead, I implemented my own (more limited) library in just 2 kB.

I hope that this protocol buffers implementation will be useful for also other microcontroller developers. The code is released under the liberal zlib license. You can download the source code and documentation on nanopb's project page.

– Petteri Aimonen on 31.8.2011

Comment on this page (no comments so far)