▼Click the card below to follow the public account▼
What are the differences between microcontrollers, Cortex-M, and Linux in embedded systems?
What processors are needed to run the Linux operating system? ARM9, ARM11?
Cortex-M is newer than ARM9, why can’t it run Linux?
Many friends might have similar questions, so let’s discuss the related content around Cortex-M, ARM, and Linux.
The ARM processor architecture defines the instruction set (ISA) and the models of processors based on this architecture. The ARM instruction set has evolved from ARMv1 to the current ARMv9, with each modification adding practical technologies.

Before ARMv6, the core instruction set architectures were of a single style, but starting from ARMv7, the instruction set architecture evolved into three styles, namely the well-known Cortex-M, Cortex-R, and Cortex-A, or ARMv7-A, ARMv7-R, and ARMv7-M.
-
Cortex-M: mainly refers to microcontrollers;
-
Cortex-R: mainly refers to real-time processors;
-
Cortex-A: mainly refers to application processors;
For more information, refer to the article: The Relationship Between STM32, Cortex-M3, and ARMv8-M.
It is worth noting that processors under Cortex-M do not have a Memory Management Unit (MMU).
Memory Management Unit (MMU)
MMU: Memory Management Unit.
The Memory Management Unit is mainly responsible for mapping virtual addresses to physical addresses and checking memory access permissions at the hardware level.
In multi-user and multi-process operating systems like Linux, the MMU allows each user process to have an independent address space to prevent memory overflow.

Figure 2: The Role of MMU
MCUs have an address space known as the virtual address range. For example, for Cortex-M 32, the virtual address range is 0 ~ 0xFFFFFFFF (4G address space).
When the controller addresses a 256M memory, its available address range is limited to 0 ~ 0x0FFFFFFF (256M).
1. In processors without memory management, virtual addresses are sent directly to the memory bus to read and write the physical memory at that address.
Here is further reading:The Preemption Mechanism of Non-MMU Preemptive Operating Systems
2. In controllers with memory management, virtual addresses are first sent to the MMU, mapped to physical addresses, and then sent to the memory bus.

Figure 3: Memory Management Mechanism
Note: The above figure only reflects the mapping mechanism of memory management simply, and other discussions are not included.
The main role of MMU virtual memory management is to allow each process to have an independent address space.
The same virtual address in different processes is mapped by the MMU to different physical addresses, and accessing any address in one process cannot access the data of another process. This ensures that any illegal memory access caused by executing erroneous instructions or malicious code in one process does not unintentionally overwrite the data of other processes, thus ensuring the stability of the entire system.
On the other hand, each process believes it exclusively owns the entire virtual address space, making the implementation of linkers and loaders easier, without worrying about whether the address ranges of different processes conflict.
Operating systems are usually divided into real-time operating systems and non-real-time operating systems.
1. Real-time operating systems are mostly single-process and multi-threaded (multi-tasking), so they do not involve address space allocation between threads and do not need to use MMU, such as ucos, FreeRTOS, RT-Thread, etc.
2. The Linux system is a non-real-time operating system, with multi-process being its main feature. For reference, see the article:Is Linux a Real-Time System or a Time-Sharing Operating System?
Taking Ubuntu as an example, we open a shell and check the address range of the bash process as shown in Figure 4, which ranges from 0x0000000000400000 to 0xffffffffff600000.

Figure 4: Bash Address in Shell 1
We open another shell and check the address range of the bash process in that shell, as shown in Figure 5. It is not difficult to find that the address ranges of the two different bash processes are completely the same. In fact, the operating system or user does not need to consider the physical memory address allocation when forking() a process; this task is handled by the microcontroller’s memory management unit (MMU).

Figure 5: Bash Address in Shell 2
Since multi-processes depend on the memory management unit, can we run embedded Linux with just one process? Definitely not! After booting, even if the user does nothing, the visible necessary processes for system operation have already started dozens to hundreds, as shown in Figure 6.

Figure 6: Process Tree
Through the above description, we can see that the Linux operating system has a strong dependence on the MMU (Memory Management Unit). If Linux were to run on a CPU without a memory management unit, the entire system would likely only stay at the Uboot stage.
Since ARM’s Cortex-M processors do not have a memory management unit, it is generally not recommended to run the Linux operating system.
Of course, nothing is absolute. If you rewrite the Linux kernel and pair it with a sufficiently large memory chip, theoretically, it is possible to do without the MMU.
However, is such a workload really worth it? In fact, the MMU was created to solve the increasingly complex memory management of operating systems.
Source: Zhiyuan Electronics, StrongerHuang
Copyright belongs to the original author, please contact for deletion if there is infringement.
Recommended Articles Click the blue text to jump
Foreign Embedded Programming Specifications (Worth a Look)
2021-07-08
Very Powerful! Low Coupling High Cohesion MCU Practical Software Framework
2021-07-07
MQTT Protocol, Finally Someone Explained It Clearly
2021-07-05
Welcome to forward, leave a message, like, and share with your friends, thank you for your support!

Long press to identify the QR code to follow me
You click every good-looking thing, I take seriously as likes