The DeviceHive team provides versions of its software for a wide range of end-device architectures such as Microchip’s PIC, TI’s MSP, Atmel’s AVR and various implementations of ARM, maintaining a separate code branch for each one. Though written in C, the end device part uses hardware specific code for every particular SoC, thus making support and development a tricky and time-intensive job.
What has existed in the world of big machines for over than 50 years, the operating system (OS), is now finding its place on tiny boards, driven by cheap yet well-equipped modern SoC’s. Such high-performance cores, as late AVR or ARM devices can easily afford, not only user code (quite complicated sometimes) on their ROMs, but various compact but powerful real time kernels – the piece of ‘system’ code called the real time OS (RTOS).
A typical RTOS has ready-to-use implementations for a wide variety of ‘system’ tasks that an “embedder” might need – from organizing multithreading, serving interrupts, cross-thread data exchange to effective wrappers around various onboard peripherals, and yet this is still a rare case when a RTOS has ports to many different platforms.
The latter feature is quite vital for embedders, as the richness in on-chip features is often diminished by the substantial difference in ways the features can be controlled by various architectures. What, for example, can be easily done using a built-in direct memory access (DMA) controller in one system, might require a quirky interrupt-driven piece of code in the other, so it is a big advantage for a RTOS if it supports a set of effective wrappers for a variety of SoC hardware.
This support, often called the hardware abstraction layer (HAL) is becoming one of the key features to consider when it comes to choosing a RTOS for DeviceHive-like purposes. The others are the minimum program memory footprint, good performance, and whether it is open source.
Having the above considerations in mind, the DeviceHive team has chosen an open source solution, ChibiOS, as the RTOS for the end-device DeviceHive code. The team has conducted experiments and real time performance measurements for different AVR and ARM platforms that have shown that the HAL and the kernel are quite fast, convenient and versatile; the performance of the RTOS kernel is the best in its class, with its program memory footprint for popular architectures being as small as about 6000 bytes.
Pic 1. Cross-platform performance measurement – instruments and DeviceHive platforms running ChibiOS
Pic 2. Hardware interrupt response time comparison for ARM and Arduino boards