SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Microlib vs Standard Libraries for Resource-Constrained Cortex-M1 Applications
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Microlib vs Standard Libraries for Resource-Constrained Cortex-M1 Applications

Ryan Ryan
Last updated: October 5, 2023 9:55 am
Ryan Ryan
6 Min Read
Share
SHARE

When developing applications for resource-constrained microcontrollers like the Cortex-M1, choosing the right software libraries is critical. Standard libraries like the C standard library provide rich functionality but have high memory and CPU overhead. Microlibs are optimized libraries designed specifically for microcontrollers. This article compares microlibs and standard libraries for Cortex-M1 development.

Contents
  • The Constraints of Cortex-M1 Microcontrollers
  • The C Standard Library
  • Microlibraries
  • Microlib Comparison
    • STM32 Microlib
    • Arm Mbed
    • Microlib
  • Conclusion

The Constraints of Cortex-M1 Microcontrollers

The Cortex-M1 processor is designed for embedded applications requiring minimal silicon area and low power consumption. It has a 32-bit ARMv6-M architecture with a single-issue 3-stage pipeline. Key specifications include:

  • 32KB to 64KB of flash memory
  • 4KB to 16KB of SRAM
  • 2.12 CoreMark/MHz performance
  • 0.9 DMIPS/MHz performance
  • Up to 50MHz operating frequency

This leads to very tight constraints on code size, RAM usage, and CPU cycles. Applications must be highly optimized for the Cortex-M1. Standard libraries designed for desktop systems are often unsuitable.

The C Standard Library

The C standard library provides functions for string handling, file I/O, memory allocation, and more. It is part of the C standard and included with every C compiler. The library contains over 150 functions to support C programs. Example functions include:

  • printf() – formatted output to stdout
  • malloc() – dynamic memory allocation
  • memcpy() – copy memory block
  • strlen() – get string length

The C standard library provides rich functionality out of the box. But it has high overhead costs:

  • Large code size – benchmarks show ~30KB compiled size for full stdlib on Cortex-M
  • High RAM usage – stdlib depends on heap allocation which consumes RAM
  • Poor performance – not optimized for microcontrollers

This overhead is acceptable on desktops and servers, but too heavy for most microcontrollers. The full stdlib is impractical for use on Cortex-M1 chips.

Microlibraries

Microlibs, or embedded libraries, are designed for memory and performance constrained microcontroller applications. They provide C standard library functionality optimized for embedded use. Example microlibs include:

  • Arm Mbed – general purpose embeddded library
  • Microlib – STMicroelectronics Cortex-M microlib
  • NanoLib – TI microlib for MSP430 MCUs
  • Avr-Libc – Atmel AVR microlib

Microlibs optimize for code size, RAM usage, and performance. Key techniques include:

  • Static memory allocation – avoids heap usage
  • Inlining – reduces call overhead
  • Loop unrolling – improves instruction pipelining
  • Assembly optimizations – uses asm for critical paths

By sacrificing functionality and flexibility, microlibs can match the tight resource constraints of microcontrollers. The tradeoffs versus standard libraries include:

  • Smaller code size – 1KB to 5KB for microlib vs. 30KB+ for stdlib
  • Lower RAM usage – static allocation avoids heap fragmentation
  • Higher performance – optimized for microcontroller architecture
  • Less functionality – only essential subset of standard functions
  • Limited flexibility – configuration fixed at compile time

For the Cortex-M1, the benefits clearly outweigh the costs. Microlibs enable applications that are not possible with the standard library.

Microlib Comparison

There are many high-quality C microlibs available for the Cortex-M series. Here are some key differences between popular options:

STM32 Microlib

  • Provided by STMicroelectronics for STM32 devices
  • Minimal size – 1KB to 2KB
  • Limited functionality – barebones subset of stdlib
  • STM32 compiler integration

STM’s microlib is ultra compact to fit STM32 microcontrollers. It sacrifices functionality for a tiny footprint. Useful for simpler applications on smaller MCUs.

Arm Mbed

  • General purpose Cortex-M library
  • Moderate size – 4KB to 8KB
  • Expanded feature set – filesystem, networking, RTOS
  • Nice C++ support and modularity

The Arm Mbed library has more functionality for complex applications. It includes RTOS and stack features missing in smaller microlibs. The larger size requires more resources.

Microlib

  • Barebones microlib for Cortex-M
  • Tiny footprint – 1KB to 3KB
  • Minimal stdlib functions supported
  • Pure C implementation

Microlib is a small standards-compliant C library for Cortex-M microcontrollers. It provides the absolutely essential subset of the C standard library in a compact form. Well suited for simple applications on smaller MCUs like the Cortex-M1.

Conclusion

The C standard library provides full-featured out-of-the-box functionality for C programs. However, its large resource footprint makes it impractical for most microcontrollers. Microlibs are optimized embedded libraries designed specifically for memory and CPU constrained microcontroller applications.

For Cortex-M1 development, microlibs are clearly the best choice to manage the tight code size, RAM, and performance constraints. Arm Mbed offers more advanced functionality at the cost of more resources. STM’s microlib and Microlib provide ultra compact C standard libraries for simpler needs. In summary, microlibs enable smaller, faster, and more efficient Cortex-M1 applications.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Email Copy Link Print
Previous Article Software Development on Cortex-M1 Hardware Without an OS
Next Article File System Limitations on Cortex-M1 in FPGA Implementations
Leave a Comment Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2kFollowersLike
3kFollowersFollow
10.1kFollowersPin
- Sponsored-
Ad image

You Might Also Like

What is watchdog software used for?

Watchdog software refers to programs that monitor the status of…

8 Min Read

Cortex-M Exception Handling and Return Mechanism

The Cortex-M processor implements robust exception handling capabilities to respond…

6 Min Read

ARM Cross-Compilation Tips

Cross-compiling for ARM can seem daunting at first, but with…

9 Min Read

What is the MMU of the ARM processor?

The MMU (Memory Management Unit) is a key component of…

8 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?