PX5 RTOS: 2 KB of Flash, 1 KB of RAM, a thousand ways to optimize your application on an STM32 MPU

PX5 hero

PX5 RTOS from PX5, a member of the ST Partner Program, is an advanced real-time operating system based on industry-standard IEEE POSIX pthreads APIs. It also has a minimum memory footprint of 2 KB of Flash and 1 KB of RAM, and supports symmetric multiprocessing on cores like the Cortex-A35. It is, therefore, an ideal choice RTOS for STM32 microprocessors developers who need an alternative to Embedded Linux. PX5 also provides PX5 NET (TCP/IP) and PX5 FILE (FAT file system). Engineers don’t have to spend time writing their network or file management systems, which greatly simplifies development. PX5 RTOS is also certified for safety-critical applications, thus enabling it to support a wider range of use cases.

The importance of Embedded Linux

A popular solution

ST aims to be a strong supporter of the open-source and Linux communities. We publish the source code for most of our software packages and have our own Embedded Linux distribution, OpenSTLinux, that we update regularly to leverage the latest features, such as M33-TD in the STM32MP2 series. We seek to mainline our drivers and try to contribute to various open source projects because we understand the importance of collaborating with the entire industry to make microprocessors and their operating systems better. It makes a difference when an entire community can audit a repository to find vulnerabilities or support a system for decades, thus ensuring that products can extend their lifespan.

The necessity of real-time operating systems on MPUs

The reality is that not every project that uses an STM32 MPU needs to use Embedded Linux or a Unix kernel on all of its cores. In certain industrial or safety-critical applications, an RTOS with fast real-time execution, determinism, safety certification, and a smaller footprint is a better choice. If we take, for example, a smart factory that uses an STM32 MPU to control an automated robot arm, we can envision designers using Embedded Linux to run the human-machine interface, the motor control application, sensor fusion algorithms, and most of the runtimes needed for smooth operations. However, a small RTOS would offer the safety, security, and agility needed to protect against failures, monitor operations, and alert users.

The challenges behind an RTOS on an MPU

The challenge is that running an RTOS on a microprocessor is not always straightforward because it puts developers closer to the bare metal, meaning they must deal with a more complex architecture than a regular MCU Many real-time operating systems also use proprietary APIs, which entail a steeper learning curve. Some systems may even require royalties, which can be an issue for large projects, while others may not meet the requirements set by safety certifications. More importantly, all these issues can take a life of their own as projects scale, and companies must deal with large volumes.

The importance of PX5 RTOS

Royalty-free Licensing with Industry-standard APIs

PX5 RTOS stands out in part due to its native implementation of the industry-standard IEEE POSIX pthread APIs. This alone enables developers to use the PX5 RTOS with little to no learning required. It also helps protect developers’ software investment by making application firmware portable across all platforms that support the pthread API, including Linux. Moreover, PX5 natively implements the Linux file system APIs in PX5 FILE, and the BSD sockets APIs in PX5 NET. Developers can thus use APIs they are already familiar with. PX5 RTOS is also compatible with legacy middleware such as NetX Duo, FileX, and USBX. And PX5 provides the complete source code for all products while offering perpetual, royalty-free licensing.

Small, Fast, and Safe

Installing PX5 RTOS requires two files (px5.c and px5_binding.s). Once they are in the application build pipeline, a bare-metal application can start using the PX5 RTOS by including pthread.h and calling px5_pthread_start. The smallest PX5 RTOS install requires 2 KB of Flash and 1 KB of RAM on typical platforms. Performance-wise, according to the 2024 RTOS Performance report by the Beningo Embedded Group, the latest-to-date, PX5 RTOS “outperformed the [other] open source RTOSes—in some cases, by as much as 5.8 times faster!” Finally, PX5 RTOS, PX5 FILE, and PX5 NET are certified for use in applications requiring IEC 61508 SIL 4, ISO 26262 ASIL D, IEC 62304 Class C, and EN 50128 SIL 4 certifications.

Advanced RTOS Technology

One reason behind the performance of PX5 RTOS is its use of encapsulated global data structures (patent-pending). Basically, all PX5 RTOS global data elements are encapsulated into a typedef. This typedef is then instantiated as a single instance. Hence, behind the scenes, the compiler generates code to access most internal global data elements using a single register-relative instruction. This encapsulation technique significantly reduces code size and improves performance.

Another advanced (and patent-pending) technology is Pointer/Data Verification (PDV). When fully enabling PDV, the RTOS computes small verification codes (“hashes”) for various critical data elements, including function pointers, metadata between allocated memory, internal system object control blocks, global data, and even function return addresses. On most architectures, this requires very little overhead, with only a few instructions to create and verify. If the architecture has a True Random Number Generator (TRNG), these run-time verification codes are unique to each run, making it difficult for an attacker to circumvent. PDV is thus a valuable tool for a device’s broader security mechanisms. PDV also helps detect and mitigate accidental memory corruption from the firmware itself.

Scroll to Top