X-CUBE-AZRTOS, The Most Extensive Integration of Azure RTOS Features on STM32 MCUs

X-CUBE-AZRTOS is the latest chapter in the story that brought Azure RTOS and STM32 MCUs together. The STM32Cube Expansion packages now support nearly all STM32 MCUs sold today. Available on GitHub, the packages are out of beta and are fully compatible with STM32CubeMX. As a result, engineers can configure the middleware stacks within STM32CubeMX’s graphical user interface, which further integrates Azure RTOS into the STM32 ecosystem and lowers the barrier to entry.

The packages are also unique because they include a lot more application examples than what developers traditionally get with these sorts of solutions. For instance, the new solution offers applications revolving around FileX, NetXDuo, ThreadX, and USBX. It is thus one of the most comprehensive integrations of Azure RTOS middleware in the industry. Additionally, it’s a way to help developers experiment in minutes. For example, the X-CUBE-AZRTOS-H7 contains demos for the NUCLEO-H723ZG Nucleo-144 development board, the STM32H735G-DK, or STM32H747I-DISCO Discovery Kits, and the STM32H743I-EVAL evaluation board.

X-CUBE-AZRTOS: STM32Cube and Azure RTOS
X-CUBE-AZRTOS: STM32Cube and Azure RTOS

Azure RTOS and the STM32

What Will Be the Azure RTOS Experience on STM32?

Azure RTOS is the only free OS with user-friendly licensing terms for embedded systems that comes with such an extensive list of certifications, both for safety (IEC 61508 SIL 4, ISO 26262 ASIL D, IEC 62304 Medical Class C), and security (EAL4+, FIPS 140-2). Users looking to penetrate the industrial, automotive, or medical markets, among others, will, therefore, benefit from these standards and offer greater guarantees to their customers. Moreover, we are working with Microsoft® to ensure that Azure RTOS takes advantage of key IPs present in STM32 MCUs, such as our hardware crypto core. Hence, teams will also enjoy hardware optimizations for greater security and efficiency.

Another thing to consider is that moving from proof-of-concept to a final product can be daunting. Hence, to reduce the time to market, all our STM32 MCUs receive a free evaluation and production Azure RTOS license. Thanks to our collaboration with Microsoft, developers can thus modify the source code and distribute it. Additionally, ST will also update and continue to release new STM32Cube embedded software packages and tools to take advantage of the Azure RTOS middleware and stacks.

What Will Azure RTOS Bring to STM32Cube?

At the core of Azure RTOS, we find ThreadX RTOS, which stands out for its powerful scheduling capabilities, among other things. In a white paper on Preemption-Threshold Scheduling, the software company explains how, traditionally, an RTOS allows any thread with a higher priority to preempt, meaning take over, a currently running thread with a lower priority. ThreadX provides a lot more granularity and enables developers to set thresholds to prevent preemptions and reduce context switching, thus vastly optimizing performances. Similarly, it also offers event-chaining, which enables a specific action when an event occurs. As a result, threads waiting for an event can start automatically, which facilitates the development and reduces the resources necessary.

Offering Azure RTOS as one of our STM32Cube middleware means our users will more easily benefit from Azure RTOS while still enjoying the best our development platform has to offer. For instance, Azure RTOS comes with FileX, a filesystem offering advanced features on NAND and NOR Flash memories like fault tolerance, or wear leveling. NetX, and NetX Duo, are network stacks that provide TCP/IP, IPv4, and IPv6, as well as many upper-level protocols used in IoT like MQTT or COAP. There’s also USBX that facilitates the use of a USB interface, both as a host or as a device, with a complete set of supported USB classes.

X-CUBE-AZRTOS and Developers

Running a Demo Application in 3 Clicks

Exploring an RTOS’s middleware is not a trivial task, and X-CUBE-AZRTOS doesn’t pretend otherwise. However, it does enable developers to run demo applications so quickly and study source codes so easily that it can greatly improve workflows. Looking at X-CUBE-AZRTOS-H7, it’s possible to run ST’s Tx_FreeRTOS_Wrapper demo in just three clicks. After connecting an STM32H735G-DK to a PC:

  1. In STM32CubeIDE, select File -> Import, and then Existing Projects into Workspace.
  2. In the root directory, choose the folder x-cube-azrtos-h7-main/Projects/STM32H735G-DK/Applications/ThreadX/Tx\_FreeRTOS\_Wrapper/STM32CubeIDE, then Finish
  3. The last step consists of right-clicking on the project that appeared in the Project Explorer, then choosing Debug As -> STM32 Arm® Cortex®-M C/C++ Application. If a configuration pane appears, clicking OK will suffice.

STM32CubeIDE will build the project and flash it onto the Discovery Kit. The demo is working if the red light at the back of the board suddenly flashes rapidly between green and red.

X-CUBE-AZRTOS: Learning How to Migrate From FreeRTOS to Azure RTOS

The STM32H735G-DK Discovery Kit
The STM32H735G-DK Discovery Kit

The Tx_FreeRTOS_Wrapper demo teaches how to take advantage of ThreadX when coming from FreeRTOS. ThreadX reduces context switching and helps manage thread priorities to optimize performance. However, developers only familiar with FreeRTOS may find the concept a bit disorienting. The demo, therefore, exposes an adaptation layer that defines a thread handled by ThreadX, and shows how to use it.

Hence, engineers migrating from FreeRTOS to Azure RTOS can benefit from a familiar concept and move to Microsoft’s operating system more efficiently. The application also serves as a testament to ST’s desire to help developers transition to Microsoft’s platform.

The X-CUBE-AZRTOS packages also serve as an object lesson. Once the demo is running, the main.c file appears within STM32CubeIDE’s debug window, so developers can see it running. It thus shows how the application calls the tx\_application\_define() function in the app_tx_freertos.c files to create the LEDThread\_Entry thread at startup. Hence, X-CUBE-AZRTOS represents a new solution for teams looking to reduce their time to market by obtaining a production-ready code faster.

To read more in detail, kindly visit: ST Blogs