Written by Ivo Clarysse, CTO at Blue Clover Devices
This blog previously ran on the Blue Clover Devices website. You can view the website here.
IOT OS LANDSCAPE
These days there’s no lack of operating systems to choose from for embedded systems; Wikipedia counts about 100 of them. The Eclipse survey still shows Linux leading the pack, with Windows, FreeRTOS and Mbed OS being widely used as well.
For devices that have the necessary resources, full-blown operating systems like Linux (Android) or Windows dominate the field, but for more constrained devices, there’s a wide range of systems being used.
The Eclipse IoT Developer Survey 2019 shows more use of actual operating systems in IoT device firmware, as opposed to bare-metal programming or building on top of a minimal kernel.
Linux is widely used for IoT applications, but requires at least a Cortex-A MCU (or equivalent), and is not the preferred choice for more limited systems, such as Cortex-M.
FreeRTOS is quite popular in the embedded world and gets more support after the acquisition by Amazon in 2017. However, FreeRTOS is a bare operating system. Everything else such as drivers, file systems, crypto modules, network stacks, middleware, and a bootloader must be added from other sources.
ARM’s Mbed OS has the out-of-the-box integration with ARM’s Pelion Device Management going for it, making it a great choice to learn about IoT device provisioning, connection and management through LwM2M. Provided by ARM, it obviously does not support popular IoT platforms like ESP32 or RISC-V.
Mynewt has everything you could wish for in an operating system for resource constrained IoT devices, but the BSP support is fairly limited.
Zephyr originated from the Virtuoso DSP operating system which initially got rebranded as “Rocket” kernel, following its acquisition by Wind River Systems, but became Zephyr in 2016 when it became a Linux Foundation hosted Collaborative Project. Major sponsors and contributors of this open source collaborative effort include Intel, Nordic Semiconductor, NXP, SiFive, Synopsys and TI.
Like many other operating systems, Zephyr provides:
- Secure bootloader (MCU Boot)
- Network stacks
- File systems (NFFS, LittleFS, NVS)
- Middleware (including the MCUmgr OTA mechanism and LwM2M client functionality)
- Device drivers
Zephyr is mostly licensed under the Apache 2.0 license, but drivers from Nordic and NXP are licensed under the permissible BSD-Clause-3 version, although some of the build tooling is GPLv2.
An example Zephyr firmware project can be found on https://github.com/bdevices/ly10-zephyr-fw
This project is a demonstration firmware for our nRF52-based “LY10” demo board, which we ship with our Production Line Tool.
Use the following Terminal command to obtain a local copy of this example project.
git clone https://github.com/bcdevices/ly10-zephyr-fw.git
To simplify building the firmware, we’ve setup this project with Docker-based build scripts, avoiding the need to install anything else than Docker itself.
The resulting ly10-zephyr-fw-VERSION.hex file can be programmed through the west tool (if you’ve installed the Zephyr tooling locally), or use target-specific Vendor tools (nRF Connect Programmer).
The demo firmware source code is very simple, contained in the src/app folder:
- main.c: Main controller
- app_ble.c: BLE adapter
- app_buzzer.c: Control PWM-driven piezo buzzer
- app_ledstrip.c: Control APA102 LED strip
- app_sensor.c: Read out SHT3XD sensor
Building for one of the target boards directly supported by zephyr is a matter of specifying the correct board name.
Since the LY10 is a custom board that is not defined in the upstream Zephyr project, we’re defining a custom board in boards/arm/ly10demo:
- board.cmake : cmake build file, specifying programming adapters to use.
- Kconfig : system-wide Kconfig settings affected by the LY10 board
- Kconfig.board : board-specific Kconfig settings
- Kconfig.defconfig : Kconfig defaults when building for an LY10 board
- ly10demo_defconfig : devicetree defaults when building for an LY10 board
- ly10demo.dts : board devicetree source
- ly10demo.yaml : YAML definition
- Zephyr RTOS Project, Linux Foundation hosted Collaboration Project
- Zephyr 2.0.0 Release Notes, Zephyr Project (September 2019)
- IoT Developer Survey 2019, Eclipse Foundation (April 2019)
- Zephyr Now Supports OMA LwM2M Protocol! What Can it Do for Me?, Zephyr Project (March 2018)
- Mynewt MCUmgr