
Recall first from Embedded Linux and its four building blocks
- An embedded system is a computer with one dedicated job inside a product, and it is not defined by being small or cheap.
- Every embedded Linux system is built from four blocks: a cross toolchain, a bootloader, a kernel and a root filesystem.
- A board boots in a fixed chain: ROM code, then TF-A (or an equivalent first stage), then U-Boot, then the kernel, then init.
Choosing Linux: the decision matrix
3 min readYou can now name the four building blocks and the boot chain that links them. This lesson answers how to decide whether Linux fits a project and how to build software for the target.
Linux is not the answer to every embedded problem. It is the answer when the complexity of the job justifies the complexity of the system, and the way to decide is to reason from the hardware and the requirements rather than from preference.
The first and hardest gate is the MMU. Linux requires an MMU, which in practice means an application processor such as a Cortex-A, not a Cortex-M microcontroller. If the project is locked into an MMU-less MCU, Linux is off the table, and bare metal or an RTOS is the only option.
The second gate is RAM. A minimal Linux system can run in about 16 MiB, and determined engineers have squeezed it into less, but a comfortable, maintainable system with a full C library and a normal set of tools usually wants 32 MiB or more, and a modern connected product with a web interface or a display often needs hundreds of megabytes. An MCU with a few hundred kilobytes of RAM cannot run Linux at all.
The third gate is storage. Linux needs somewhere to keep the kernel and root filesystem: NOR or NAND flash, an SD card, or eMMC, typically 8 MiB and upward for a minimal image. Bare-metal firmware fits in a single chip's internal flash.
Two softer criteria then decide the choice. Boot time: an RTOS starts in milliseconds, while a full Linux boot takes on the order of a second, tunable down with real effort but never to RTOS levels. Real-time latency: Linux offers good but not hard real-time guarantees, and where a control loop needs microsecond-level, worst-case-bounded response, an RTOS or bare metal, or a Linux-plus-MCU split, is the safer design. Power is the final axis: a Linux SoC in an always-on, battery-powered sensor may simply draw too much current, where a Cortex-M MCU can sleep for years on a coin cell.
The result is a decision matrix, not a slogan. If the product needs an MMU, tens of megabytes of RAM, real storage, a network stack, a filesystem or a complex UI, choose Linux and accept the boot time and power cost. If it needs a hard real-time loop, microsecond latency, instant boot or coin-cell power, choose an RTOS such as Zephyr or FreeRTOS, or split the job: an MCU running the real-time loop beside a Linux SoC that handles connectivity, which is exactly the architecture of the STM32MP157 you will use.
Hardware criteria and the course boards
2 min readA the vendor-supplied bundle of kernel, drivers and bootloader that makes a specific board work (BSP) sits on top of a board, which sits on top of a SoC. The SoC is a single chip containing the CPU cores and the controllers for memory, storage, USB, Ethernet, and serial interfaces such as UART, SPI and I2C. The board is the PCB that adds the power supply, connectors, RAM and flash chips around the SoC. The BSP is the software layer the vendor wrote so that all of that specific hardware actually works.
The vendor-versus-mainline trade-off follows directly from this stack. A vendor kernel is feature-complete for the board on day one: it has the drivers for every peripheral the vendor built in. But it is usually a snapshot of an older kernel with the vendor's patches on top, and it may never receive security fixes. A mainline kernel is current and maintained, but it may lack support for a peripheral the vendor never contributed upstream. The professional response is to prefer vendors who push their code upstream, and to check what a chip actually has in mainline before choosing it.
Storage types matter for embedded Linux. NOR and NAND are raw flash chips addressed at a low level and need a flash-aware filesystem; eMMC and SD cards are "managed" flash that hide the complexity behind a block interface and behave like a small disk. Communication is the other criterion: almost every board has UARTs for a console and debugging, and most add Ethernet, USB, and the low-speed SPI and I2C buses for sensors and peripherals.
This module uses three targets. The STM32MP157 Discovery Kit is the product-style board: a dual Arm Cortex-A7 running Linux plus a Cortex-M4 co-processor, booting through the full ROM, TF-A, U-Boot chain. The Raspberry Pi 4 is a Broadcom BCM2711 with a quad-core Cortex-A72, useful for comparison. QEMU, emulating an Arm "virt" machine, is the no-hardware fallback when you have no physical board to hand.
The host/target split and cross-compilation
3 min readThe computer you write and build code on is the host, and the device the code runs on is the target. On a desktop project these are the same architecture: the gcc on your Ubuntu machine produces x86 binaries for that same machine. This is a native toolchain. On an embedded project the target is usually Arm, so the binaries the host compiler produces would not run on it at all. You need a cross toolchain, one that runs on the host but emits code for the target architecture.
The difference is visible in the tool names. A native compiler is just gcc. A cross compiler has a prefix that names the target, such as arm-linux-gnueabihf-gcc, where the tuple records the architecture (arm), the operating system the code will run on (linux), and the ABI (gnueabihf, meaning the GNU tools and a hard-float ABI). The same prefix appears on the rest of the toolchain: arm-linux-gnueabihf-ld, arm-linux-gnueabihf-objdump and so on.
Going deeperWhat is in a toolchain tuple
The full prefix encodes three decisions made when the toolchain was built: the CPU architecture, the target operating system, and the C library and ABI. arm-none-eabi is a bare-metal toolchain for an MCU with no operating system, used to build firmware and bootloaders. arm-linux-gnueabihf targets Linux on 32-bit Arm with a hard-float ABI. aarch64-linux-gnu targets 64-bit Arm. The distinction matters because the C library is different in each case: a Linux toolchain links against a C library that issues Linux system calls, while a bare-metal toolchain has no such library. You will build and select toolchains in a later session.
Cross-compiling is not just about the compiler. Every library the target program needs must also be built for the target architecture and installed into a sysroot, a directory that mirrors the target's filesystem on the host. A native library on the host is useless to a cross compiler. Managing the sysroot correctly is one of the classic sources of embedded build errors, and it is why build systems such as Buildroot and Yocto exist.
The development environment is deliberately simple. On the host you need a Linux distribution with the basic native build tools, which on Ubuntu is the build-essential package (the gcc and g++ compilers, make, and the C library headers), plus git for version control. Later sessions add the cross toolchains, U-Boot, QEMU and the build systems on top of this base.
sudo apt update
sudo apt install -y build-essential git
Key takeaways
- Linux needs an MMU and roughly 16 MiB of RAM or more; below that, bare metal or an RTOS such as Zephyr or FreeRTOS is the normal choice.
- An RTOS starts in milliseconds and can meet microsecond, worst-case-bounded latency; Linux boots in about a second and offers good but not hard real-time guarantees.
- A vendor kernel is feature-complete for its board on day one but is usually an older snapshot that may not get security fixes; mainline is current but may lack a peripheral never upstreamed.
- A cross toolchain runs on the host but emits code for the target, and its prefix such as arm-linux-gnueabihf names the architecture, OS and ABI.
Reflect
- Explain to a colleague, in two sentences: decide, using MMU, RAM, storage, boot-time and latency criteria, whether Linux or an RTOS fits a product.
- Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
- What surprised you when you ran the commands yourself?
On a real board
Repeat the key commands on your Raspberry Pi or lab board over SSH or the serial console. Note anything that behaves differently from your PC, such as missing tools, a BusyBox shell or a read-only filesystem.
References and further reading
Official documentation first. Links checked when the lesson was published.