A Look Into Different Embedded C/C++ Standard Libraries

December 16, 2019

EDIT (6/28/2020): A helpful reader has posted about some errors in this article. They have since been corrected. Thanks to Dave Nadler for the updates!

If you’ve used an IDE such as MCUXpresso for NXP controllers, you may have seen an option to choose your preferred C99/C++ embedded system library implementation. Some of the more popular choices for ARM based CPUs are Newlib, Redlib, and NewlibNano. Each implementation has all the basic functionality to allow for program startup and include files like <stdio.h> but will vary in subtler ways such as total code size, speed of execution, and additional features on top of the base api.

Here are some differences between the three listed above:

Newlib

This is a popular GNU C library for use in embedded systems. Helpful features of this library include maturity, wide support, and an active developer/user base. There’s a lot already written about this library so here’s a paper detailing its functionality along with a page that explores runtime startup with Newlib.

Newlib Details: https://www.cs.ccu.edu.tw/~pahsiung/courses/esd/resources/newlib.pdf

Newlib Startup: https://embeddedartistry.com/blog/2019/04/17/exploring-startup-implementations-newlib-arm/

PicoLibc (Was Newlib-Nano)

This library was actually updated just a few weeks before I originally wrote this post. According to the author Keith P., it was since renamed from “Newlib-Nano” to “Picolibc” as to be more distinct from other library packages available and has received numerous updates from the previous build. The biggest change listed seems to be another overhaul of its stdio implementation. More information can be found in Keith’s blog linked below.

Picolibc V1.0 Release Information: https://keithp.com/blogs/picolibc/

Redlib

Redlib is a non-GNU implementation by Code Red Tech who was acquired by NXP in 2013. Because of this, it is only available from NXP and seems to be the default library for C projects in NXP IDEs. Redlib differentiates for the most part by only implementing C90 libraries and is therefore only available for C based projects. According to NXP sources, the implementation produces code sizes much smaller than Newlib so if you don’t need the features of Newlib, Redlib is a good choice.

Also as some supplemental information, I found a page with detailed differences between 4 C standard libraries. These aren’t the ones discussed above, but I think it’s useful to see deeper differences between libraries and what to look for if you need to find more granular information about one.

http://www.etalabs.net/compare_libcs.html

2 Comments

Add Yours →

Corrections and clarifications:
1) CodeRed was acquired some years ago; current RedLib only available from NXP.
2) newlib nano is a variant build of newlib. Keith Packard accidentally reused the name. Keith’s library is now named picolibc.
3) Atollic was acquired by NXP before this article was written.

Leave a Reply