Skip navigation

SEGGER RunTime Library

The SEGGER RunTime Library is specifically designed and optimized for GCC and embedded systems.

  • Significant code size reduction (typically around 5 kB)
  • No viral licensing, no attribution clause
  • High performance, with time-critical routines written in assembly language
  • Minimum RAM usage
  • No heap requirements

GCC has become a competitive compiler choice for embedded systems. Most toolchains using GCC also use either newlib, newlib-nano or glibc. Unfortunately, these libraries have significant disadvantages over professional runtime libraries for embedded systems.

This is where the SEGGER RunTime Library comes in.

The SEGGER RunTime Library is the replacement from SEGGER for newlib, newlib-nano, and glibc that converts any GCC-based toolchain into a professional development choice. The SEGGER RunTime Labrary is used in SEGGER's Embedded Studio IDE and has proven its value for years. 

  • Significant code size reduction (typically around 5 kB)
  • No viral licensing, no attribution clause
  • High performance, with time-critical routines written in assembly language
  • Minimum RAM usage
  • No heap requirements
  • Written from the ground up for embedded devices
  • Source code is provided, making it possible to step through library functions
  • Highly optimized functions that, when used, don't cause the inclusion of many additional support functions (e.g. printf)
  • Many function are tuned with different implementations for size-optimized code and speed-optimized code
  • Formatted input and output functions are customizable from basic I/O to fully featured I/O, enabling reduction of final code footprint
  • Full support for localization, UTF-8, code pages, and locale codecs is linked only if used

Being a simple replacement for newlib or newlib-nano, the SEGGER RunTime Library shrinks and accelerates GCC-based embedded applications. Whether the main concern with newlib is flash size, performance, or the attribution clause of the viral licensing, the SEGGER RunTime Library is the solution.

The SEGGER RunTime Library can be licensed to individual companies as well as providers of GCC-based tools.

In many cases, the ROM-savings of the SEGGER RunTime Library enable the use of a smaller microcontroller with less on-chip memory. This can result in significant cost savings, especially for devices built in large quantities for the mass market.

If you are interested, please contact us for more information. The SEGGER RunTime Library is available for Cortex-M based microcontrollers. Ports for other CPUs can be made available on request.

Size Comparison: SEGGER RunTime Library - newlib - newlib-nano - redlib

The SEGGER RunTime Library offers significant savings in flash memory. This is due to some functionality being written in assembly language, but primarily due to a structure that minimizes library internal dependencies. Things like file I/O is not linked in with printf() or scanf().

The SEGGER RunTime Library also uses less static RAM due to a structure designed from the ground up for embedded systems.

SEGGER did some benchmarking on the SEGGER RunTime Library using NXP’s MCUXpresso as a representative IDE that might benefit from using the SEGGER RunTime Library. The benchmark consists of a simple "sprintf()", which removes any need for an I/O system. We compared the results for the SEGGER RunTime Library with the results for three other C libraries (Newlib, Newlib-nano, and Redlib). In each case, sprintf() was configured for the smallest possible size (size-optimized libraries, no floating point...).

Benchmark code:

int main(void)
{
    char aText[256];
    //
    sprintf(aText, "hello world.\r\n");
}

We then also tested our own Embedded Studio IDE with the same code using the SEGGER RunTime Library, in one case using the GNU Linker, in another case using the SEGGER Linker.

The results are captured in the table below.

Test Environment Test project: Simple "main" project with "sprintf()"
ROM Usage RAM Usage
MCUXpresso using Newlib 24984 bytes 2600 bytes
100 100 100 !CALCULATE_BAR_1! !CALCULATE_BAR_2!
MCUXpresso using Redlib 11528 bytes 528 bytes
100 46 20 !CALCULATE_BAR_1! !CALCULATE_BAR_2!
MCUXpresso using Newlib-nano 6744 bytes 152 bytes
100 27 6 !CALCULATE_BAR_1! !CALCULATE_BAR_2!
MCUXpresso using the SEGGER RunTime Library 2760 bytes 32 bytes
100 11 2 !CALCULATE_BAR_1! !CALCULATE_BAR_2!
Embedded Studio using the SEGGER RunTime Library and GNU Linker 3196 bytes 4 bytes
100 13 1 !CALCULATE_BAR_1! !CALCULATE_BAR_2!
Embedded Studio using the SEGGER RunTime Library and SEGGER Linker 2254 bytes 4 bytes
100 9 1 !CALCULATE_BAR_1! !CALCULATE_BAR_2!

How to use the SEGGER Runtime Library

The SEGGER Runtime Library can be used with any GCC-based IDE/toolchain for Arm CPUs by replacing the runtime library delivered with that toolchain (usually newlib, newlib-nano, or some other variant) with the SEGGER Runtime Library.

Examples include:

  • AC6 System Workbench for STM32 (SW4STM32)
  • Atmel Studio 7
  • Atollic TrueStudio for STM32
  • NXP MCUXpresso
  • Renesas e2 studio (for Synergy or RZ targets)
  • SiLabs Simplicity Studio

In SEGGER Embedded Studio and Rowley CrossWorks, the SEGGER Runtime Library is already included as the default C library.

The SEGGER Runtime Library is provided in source code and contains everything needed. The following table shows the content of the package:

DirectoriesDescription
DocSEGGER Runtime Library documentation
LIBSEGGER Runtime Library source code

We recommend keeping the SEGGER Runtime Library  separate from your application files. It is good practice to keep all the associated program files (including the header files) together in the LIB subdirectory of your project’s root directory. This practice has the advantage of being very easy to update to newer versions of the SEGGER Runtime Library by simply replacing the LIB directory. Your application files can be stored anywhere.

Please make sure that the list of include paths in your project contains the LIB directory and that any other runtime libraries are removed from the project.

Include "__libc.h" in any application source files that make calls to the SEGGER Runtime Library.

You will also need to implement functions like __assert(), __putchar(), and __getchar() in your project according to your needs before the project will build correctly. 

The SEGGER Runtime Library is exposed to the user by a set of header files that provide an interface to the library. The actual implementation is done in a small number of C source and Assembly files that must be added to your project before building.

The configuration of the SEGGER Runtime Library is defined by the content of __libc_conf.h, which is included by all C and assembly language source files.

Please see the SEGGER Runtime Library User Guide for details.