</>EmbeddedInterview

What is the difference between an MMU and an MPU?

EasyOperating System Concepts

Short answer: An MMU translates virtual addresses to physical addresses using page tables and enforces permissions per page, which gives each process its own address space (Cortex-A, x86, RISC-V with Sv39/Sv48). An MPU does no translation: it only checks permissions and memory attributes for a small number of physical address regions (typically 8 or 16), giving basic protection with predictable timing (Cortex-M, Cortex-R).

MMU MPU
Address translation yes (virtual → physical) no (addresses are physical)
Granularity pages (4 KB, 16 KB, 64 KB, huge pages) regions (on Armv7-M: power-of-two size ≥ 32 B, aligned; on Armv8-M: any 32-byte-aligned base and limit)
Number of mappings millions (tables in RAM) 8–16 regions (registers)
Per-process address spaces yes no, one shared address space
Timing TLB misses add variable latency deterministic
OS Linux, Windows, Android FreeRTOS-MPU, Zephyr userspace, SafeRTOS, PikeOS on Cortex-R

What an MPU is used for on a microcontroller

  • Stack overflow detection: a no-access region just below each task's stack.
  • Making flash or code regions read-only/execute-only and RAM execute-never (stops many code-injection attacks).
  • Isolating unprivileged tasks so they can only touch their own data and the peripherals they need.
  • Setting memory attributes: device memory for peripheral regions, non-cacheable regions for DMA buffers (Cortex-M7).

Linux without an MMU: the kernel can be built for no-MMU targets (!CONFIG_MMU), but there is no fork() (use vfork/posix_spawn), no memory protection between processes, and memory fragmentation becomes a problem. It is rare now that small Cortex-A parts are cheap.

Interview follow-up: "Cortex-R52 has two MPU stages, one for the OS and one for a hypervisor" — so even without an MMU, ARMv8-R can run a hypervisor with spatial isolation between guests.