Skip to content

A Comparison Of Embedded Platforms And HALs

Published On:
May 11, 2021
Last Updated:
Oct 26, 2024

This is a opinioned review of the many different “platforms” available for use when you want to develop firmware to run on your microcontroller.

Who wants to be trying to find the missing register information in a 1000 page technical reference manual when someone has already done the work for you and provided a HAL (hardware abstraction layer).

Shall be rated under the following categories:

  • HAL
  • RTOS Support
  • Dependency Management
  • Library Support
  • IDE Support
  • Community Support: This one is a bit of a popularity contest. How many and how active are the forums on this platform? Are there lots of StackOverflow questions and responses?

Arduino

Category Rating
HAL 7/10
RTOS Support 4/10
Dependency Management 6/10
Library Support 9/10
IDE Support 8/10
Build System 8/10
Community Support 10/10

The documentation for the Arduino API is o.k. Not bad, not great, but generally acceptable. Community support for Arduino is excellent, given it’s huge popularity. You might feel Arduino lacks a bit when it comes to powerful features that you expect of modern higher-ended MCUs/SoCs.

Arduino has no built-in or bundled RTOS. FreeRTOS is a popular pairing with Arduino if you need an RTOS. Arduino also has yield() based co-routines.

Global, constant definitions/peripherals can hinder the flexibility and architecture for larger projects. Also, many Arduino libraries make assumptions about what SPI/I2C peripheral you are using. For example, most just assume (and use) the SPI interface), which is a global variable to your first SPI interface.

Digital and analogue pins are read from/written to using global functions like digitalRead(). Whilst this is simple and easy to use, it does impose some limitations when trying to perform unit testing and create mock hardware. Without any Pin objects, you cannot really utilize dependency injection to replace real hardware pins with mocked test pins (although you could pass in the digitalRead() function, and then mock that?).

PlatformIO

Category Rating
HAL n/a
RTOS Support n/a
Dependency Management 9/10
Library Support 5/10
IDE Support 8/10
Build System 8/10
Community Support 6/10

PlatformIO is a package manager and build system. Being a build system and package manager PlatformIO does not provide any RTOS. It can be used together with many of the platforms mentioned here that do provide a HAL, such as Arduino, mbed or Zephyr.

Unsure of the amount of support for libraries of libraries (dependencies of dependencies).

mbed

Category Rating
HAL 7/10
RTOS Support 8/10
Dependency Management 6/10
Library Support 5/10
IDE Support 4/10
Build System 7/10
Community Support 3/10

Mbed provides the Mbed Studio IDE for firmware development and debugging. Only polling support for SPI.

The mbed HAL comes packaged with an RTOS. When not using multiple threads, a compile time switch disables the scheduler code and you are left with just the one thread.

Zephyr

Category Rating
HAL 7/10
RTOS Support 9/10
Dependency Management 6/10
Library Support 9/10
IDE Support 6/10
Build System 8/10
Community Support 7/10

Zephyr is a popular RTOS, peripheral API and build system for microcontrollers. Zephyr has a large and powerful HAL/peripheral API. It’s got all the standard things you would expect plus stuff like SD card controllers, a Bluetooth stack, a powerful console/shell utility and more.

On the downside, I’m not a huge fan of its use of device trees to configure hardware. It never feels intuitive to setup and you inevitable ended up trudging through cryptic compiler errors as you try and expose handles to your device tree setup in your C/C++ code. Also, I find the 10 pages of compiler error garbage when you make a single typo in a LOG_DBG() macro a bit much.

Nordic backed Zephyr with their choice to use it for their nRF 52, 53 and 91 SoCs.

cmsis

cmsis provides a RTOS API (but not the actual RTOS itself) which can act as a standardized wrapper over many different RTOSes including FreeRTOS and Zephyr.