Minimum Requirements for Running RTOS on Any MCU

Some beginners ask: What are the requirements for running an RTOS on an MCU?

This is a broad question. Currently, there are hundreds of different RTOSes on the market, big and small. If we’re talking about the minimum requirements for an MCU to run an RTOS, I’d say the requirements are very low. Most MCUs on the market today can run an RTOS.

However…

The lower the requirements an RTOS has for the MCU, the simpler its functionality, and some corresponding features will be limited.

Here, the requirements for an MCU usually refer to: MCU performance (clock speed), and the size of RAM and Flash. Other aspects such as peripherals, power consumption, and number of pins are secondary.

Even 8-bit MCUs can run an RTOS.
Even the 8051 from forty years ago can run an RTOS, but look at the performance and RAM resources of the 8051—how much does it have? An RTOS running on the 8051 can only implement very limited functionality, and once the RTOS is running, the application code (or number of tasks) will be restricted.

Nowadays, most 8-bit MCUs have relatively good performance and resources, so running some basic RTOSes isn’t a big problem.

There are actually many RTOSes that can run on 8-bit MCUs. If you’re interested, you can look them up online. Here’s something I shared earlier: “Easily Running RTOS on 8-bit Microcontrollers.”

RTOS supports tailoring
What is system tailoring? Simply put, system tailoring means keeping the components you need and removing the ones you don’t. In other words, configure only the system resources you need and “hide” the ones you don’t, thereby saving MCU resources.

Most embedded systems support tailoring, including Linux. Most RTOSes on the market have a “tailoring file,” usually named something like xxOS + Config (system configuration).

For example:

FreeRTOS has the file FreeRTOSConfig.h
uC/OS has the file os_cfg.h

The configurations in those files are usually controlled with macro definitions. For instance, the os_cfg.h file:

#ifndef OS_CFG_H
#define OS_CFG_H

/* --------------------------- MISCELLANEOUS --------------------------- */
#define OS_CFG_APP_HOOKS_EN                        1u
#define OS_CFG_ARG_CHK_EN                          1u
#define OS_CFG_CALLED_FROM_ISR_CHK_EN              1u
#define OS_CFG_DBG_EN                              0u
#define OS_CFG_TICK_EN                             1u
#define OS_CFG_DYN_TICK_EN                         0u
#define OS_CFG_INVALID_OS_CALLS_CHK_EN             1u
#define OS_CFG_OBJ_TYPE_CHK_EN                     1u
#define OS_CFG_OBJ_CREATED_CHK_EN                  1u
#define OS_CFG_TS_EN                               0u
#define OS_CFG_PRIO_MAX                           64u
#define OS_CFG_SCHED_LOCK_TIME_MEAS_EN             0u
#define OS_CFG_SCHED_ROUND_ROBIN_EN                1u
#define OS_CFG_STK_SIZE_MIN                       64u

/* --------------------------- EVENT FLAGS ----------------------------- */
#define OS_CFG_FLAG_EN                             1u
#define OS_CFG_FLAG_DEL_EN                         1u
#define OS_CFG_FLAG_MODE_CLR_EN                    1u
#define OS_CFG_FLAG_PEND_ABORT_EN                  1u

/* ------------------------ MEMORY MANAGEMENT -------------------------- */
#define OS_CFG_MEM_EN                              1u

/* ------------------- MUTUAL EXCLUSION SEMAPHORES -------------------- */
#define OS_CFG_MUTEX_EN                            1u
#define OS_CFG_MUTEX_DEL_EN                        1u
#define OS_CFG_MUTEX_PEND_ABORT_EN                 1u

/* -------------------------- MESSAGE QUEUES --------------------------- */
#define OS_CFG_Q_EN                                1u
#define OS_CFG_Q_DEL_EN                            1u
#define OS_CFG_Q_FLUSH_EN                          1u
#define OS_CFG_Q_PEND_ABORT_EN                     1u

/* ---------------------------- SEMAPHORES ----------------------------- */
#define OS_CFG_SEM_EN                              1u
#define OS_CFG_SEM_DEL_EN                          1u
#define OS_CFG_SEM_PEND_ABORT_EN                   1u
#define OS_CFG_SEM_SET_EN                          1u

/* -------------------------- TASK MANAGEMENT -------------------------- */
#define OS_CFG_STAT_TASK_EN                        1u
#define OS_CFG_STAT_TASK_STK_CHK_EN                1u
#define OS_CFG_TASK_CHANGE_PRIO_EN                 1u
#define OS_CFG_TASK_DEL_EN                         1u
#define OS_CFG_TASK_IDLE_EN                        1u
#define OS_CFG_TASK_PROFILE_EN                     1u
#define OS_CFG_TASK_Q_EN                           1u
#define OS_CFG_TASK_Q_PEND_ABORT_EN                1u
#define OS_CFG_TASK_REG_TBL_SIZE                   1u
#define OS_CFG_TASK_STK_REDZONE_EN                 0u
#define OS_CFG_TASK_STK_REDZONE_DEPTH              8u
#define OS_CFG_TASK_SEM_PEND_ABORT_EN              1u
#define OS_CFG_TASK_SUSPEND_EN                     1u

/* ------------------ TASK LOCAL STORAGE MANAGEMENT -------------------- */
#define OS_CFG_TLS_TBL_SIZE                        0u

/* ------------------------- TIME MANAGEMENT --------------------------- */
#define OS_CFG_TIME_DLY_HMSM_EN                    1u
#define OS_CFG_TIME_DLY_RESUME_EN                  1u

/* ------------------------- TIMER MANAGEMENT -------------------------- */
#define OS_CFG_TMR_EN                              1u
#define OS_CFG_TMR_DEL_EN                          1u

/* ------------------------- TRACE RECORDER ---------------------------- */
#define OS_CFG_TRACE_EN                            0u
#define OS_CFG_TRACE_API_ENTER_EN                  0u
#define OS_CFG_TRACE_API_EXIT_EN                   0u

#endif

So, through system tailoring, RTOS can support MCUs with very limited resources.

In fact, many RTOS promotional pages advertise things like: “Supports MCUs with as little as 1K RAM and 8K ROM.”

And it’s not just RTOSes—many embedded modules support tailoring, such as GUIs, protocol stacks, and more.

So, what are the requirements for an MCU to run an RTOS?
Looking back, what do you think?

Most RTOSes support tailoring, so when MCU performance and resources are limited, you can tailor the RTOS to keep only the core functionalities.

For MCUs with rich performance and resources, you can run all the built-in RTOS components—offering more comprehensive functionality.

Of course, since the kernel source code differs among RTOSes, the extent to which they can be tailored varies. The minimum resource requirement ultimately depends on the RTOS itself.

But purely in terms of running an RTOS, the requirements for an MCU are very, very low.

Finally, what’s the lowest-resource MCU you’ve ever run an RTOS on? Feel free to share in the comments.

End-of-Yunze-blog

Disclaimer:

  1. This channel does not make any representations or warranties regarding the availability, accuracy, timeliness, effectiveness, or completeness of any information posted. It hereby disclaims any liability or consequences arising from the use of the information.
  2. This channel is non-commercial and non-profit. The re-posted content does not signify endorsement of its views or responsibility for its authenticity. It does not intend to constitute any other guidance. This channel is not liable for any inaccuracies or errors in the re-posted or published information, directly or indirectly.
  3. Some data, materials, text, images, etc., used in this channel are sourced from the internet, and all reposts are duly credited to their sources. If you discover any work that infringes on your intellectual property rights or personal legal interests, please contact us, and we will promptly modify or remove it.

Leave a Reply