Module 4 · Lesson 1 of 38

Embedded Linux landscape, four building blocks, serial console

What embedded Linux is, when to choose it over an RTOS, its four building blocks, and how to watch a board boot over a serial console.

  • Beginner to advanced
  • 26 min read
  • 40 min lab
What you will need

A Linux build host (Ubuntu 24.04 in WSL2, a VM, or a container); optionally a Raspberry Pi 4, a 3.3 V USB-to-serial adapter, and a microSD card for the serial-console lab

By the end you can 6 objectives
  • Explain what makes a system embedded and contrast bare-metal and RTOS firmware with embedded Linux.
  • Name the four building blocks of an embedded Linux system and trace the boot chain that connects them.
  • Decide, using MMU, RAM, storage, boot-time and latency criteria, whether Linux or an RTOS fits a product.
  • Describe the SoC, board and BSP relationship and the vendor versus mainline kernel trade-off.
  • Explain UART wiring, TTL versus RS-232 voltage levels, and the 115200 8N1 framing convention.
  • Use picocom, minicom or screen to open a serial console and read the early boot log.
Read the lesson below; the video will appear here when published.
01

What embedded Linux is, and why you should care

3 min read

An is not defined by its size, price or power draw. It is defined by its job. A washing machine controller, a smart thermostat, a network router, a digital instrument cluster in a car and a video doorbell are all embedded systems, even though they span a thousandfold range of cost and performance. What they share is that the computer is a means to an end, not the product itself.

For most of this program we have used Linux as a general-purpose operating system on a PC or a server. Embedded Linux is the same kernel and the same set of user-space tools, but shaped into a single-purpose system. A such as a Cortex-M part typically runs a tight loop of C code directly on the metal, or a small . An embedded Linux system instead runs a full Linux kernel on an application processor, a larger chip such as a Cortex-A that is closer to a desktop CPU.

The practical dividing line is the . Linux requires an MMU, because process isolation, virtual memory and the ability to safely run many programs at once all depend on it. A small MCU has no MMU, which is exactly why it runs one trusted firmware image instead of a general-purpose OS.

The line is worth drawing precisely. A desktop or server Linux system is general-purpose: many users, many programs, a display, a package manager, and hardware that is discovered and configured at run time. An embedded Linux system has one purpose, one set of applications, no user beyond the device's function, and hardware that is fixed at design time. The kernel is the same, but the system around it is built, trimmed and locked down for one job.

Why should an engineer care? Because embedded Linux is everywhere the work needs connectivity, a filesystem, a network stack or a real UI, and it is the fastest way to get those things without writing them from scratch. Android phones, in-car systems, Wi-Fi routers, smart TVs, industrial gateways, cash machines, drones and medical monitors all run Linux kernels. Understanding where the boundaries are, and what the four building blocks are, is the foundation of the entire module.

Bare metal and RTOS, embedded Linux, and desktop Linux comparedBare metal /RTOS MCUEmbeddedLinux MPUDesktop /server LinuxTypical CPUCortex-MCortex-Ax86-64MemorykilobytesMiB to GiBgigabytesMMUabsentpresentpresentOperating systemnone or RTOSLinux, onepurposefulldistribution
Bare-metal and RTOS firmware, embedded Linux, and desktop Linux side by side
02

A short history of embedded Linux

4 min read

Linux itself started in 1991 as a hobby kernel by Linus Torvalds, running on x86 PCs. For its first years it was a server and workstation operating system, far too large and RAM-hungry for the microcontrollers of the day. The turning point for embedded use came around 1999, when Axis shipped a Linux-powered network camera and TiVo shipped a Linux-based digital video recorder. Both were "appliances": products that did one job but needed real networking and real storage, and both proved that a full OS could fit into a consumer device.

Two technical changes made embedded Linux practical. The first was the falling cost of memory and the rise of the , which put a capable application processor plus RAM and flash into a small, cheap package. The second was the availability of tooling to shrink Linux. The BusyBox project packaged dozens of standard Unix utilities into one small binary, so a usable root filesystem could fit in a few megabytes. A project called uClinux allowed Linux to run without an MMU for a while, but as SoCs with MMUs became cheap, mainline Linux's MMU requirement stopped being a barrier and uClinux faded.

In 2000 the bootloader that became U-Boot appeared as PPCBoot, renamed U-Boot in 2002, a bootloader for PowerPC boards that grew into the standard loader for Arm systems. In 2001 Buildroot began as a build system for producing small root filesystems, and in 2003 the OpenEmbedded project started work on a more general build framework. The Yocto Project, founded in 2010 under the Linux Foundation, standardized much of that work into the build system used across the industry today. Meanwhile Russell King's Arm port, merged in the late 1990s, matured through the 2.4 and 2.6 kernels, and by the time Google shipped Android in 2008 the Linux kernel was already the default choice for a new connected product.

Key dates: Linux 1991, Axis and TiVo appliances 1999, PPCBoot 2000, Buildroot 2001, U-Boot rename 2002, OpenEmbedded 2003, Android 2008, Yocto 2010.

  • events: [{"date": "1991", "label": "Linux kernel begins", "detail": "Linus Torvalds starts Linux as a hobby kernel on x86 PCs."}, {"date": "1999", "label": "Linux reaches appliances", "detail": "Axis ships a Linux network camera and TiVo ships a Linux DVR."}, {"date": "2000", "label": "PPCBoot appears", "detail": "The bootloader that becomes U-Boot, first for PowerPC boards."}, {"date": "2001", "label": "Buildroot begins", "detail": "A build system for producing small root filesystems."}, {"date": "2002", "label": "Renamed U-Boot", "detail": "PPCBoot is renamed U-Boot and grows into the standard Arm loader."}, {"date": "2003", "label": "OpenEmbedded starts", "detail": "A more general build framework for embedded distributions."}, {"date": "2008", "label": "Android ships", "detail": "Google ships Android, and Linux is now the default for new connected products."}, {"date": "2010", "label": "Yocto Project founded", "detail": "Founded under the Linux Foundation to standardize the embedded build system."}]

The pattern across this whole history is a chain of specialization. CPU designers define the instruction set, SoC vendors build the chip, board vendors design the PCB, and a build system assembles the software. Each link adds software that the next link uses, and each link tends to keep its changes to itself. That chain, and the friction it creates, is the subject of this module.

Key milestones in embedded Linux historyLinux 0.01released1991, hobbykernel forx86Axiscamera,TiVo DVR1999, firstLinuxappliancesU-Bootreleased2000, asPPCBootBuildrootstarted2001, smallrootfsbuildsOpenEmbedded started2003,generalbuildframeworkYoctoProjectfounded2010, LinuxFoundationLinux 0.01released1991, hobbykernel forx86Axiscamera,TiVo DVR1999, firstLinuxappliancesU-Bootreleased2000, asPPCBootBuildrootstarted2001, smallrootfsbuildsOpenEmbedded started2003,generalbuildframeworkYoctoProjectfounded2010, LinuxFoundation
Key milestones from the first Linux release to the modern embedded ecosystem
03

The four building blocks and the boot chain

4 min read

Every embedded Linux system, however it is built, is assembled from four parts. The is the first. It produces the binaries that will run on the target, and on an embedded project it is almost always a cross toolchain, one that runs on your PC but emits code for the board's architecture. You will meet it properly in the next sections and again in sessions on cross-compiling.

The second part is the . On almost every modern board this is U-Boot, which knows how to initialize memory, read the kernel from flash or an SD card, and hand it a description of the hardware. The bootloader is the first software you can interact with, which is why its banner is the first thing you see on a serial console.

The third part is the kernel. Linux manages memory, schedules processes, and mediates every access to hardware through device drivers. On an embedded system the kernel is configured and built for one specific board, not for every device on the planet, which keeps it small and fast.

The fourth part is the . It contains the C library, BusyBox or a full set of tools, the init program, and your application. Without it the kernel boots and then stops, because there is nothing for it to run.

These four blocks are connected by a boot chain, a fixed sequence in which each stage loads and starts the next. On the STM32MP1 boards used in this course the chain is ROM code, then TF-A, then U-Boot, then the Linux kernel, then init. The exact names differ across chips, and you will study each stage in detail in later sessions, but the shape is universal.

Step by stepThe boot chain, stage by stage
  1. ROM code: the SoC's built-in firmware runs first, from a mask ROM, and loads a small first-stage loader from flash or an SD card.

  2. TF-A: the first-stage loader (here Trusted Firmware-A) initializes essential hardware and RAM, then loads U-Boot.

  3. U-Boot: the full bootloader sets up memory and clocks, reads the kernel and device tree, and jumps into the kernel.

  4. Linux kernel: the kernel initializes drivers and mounts the root filesystem, printing progress to the console.

  5. init: the first user-space program (PID 1) starts services and eventually your application or a login prompt.

The boot chain runs ROM code, then TF-A, then U-Boot, then the Linux kernel, then init, each stage loading and starting the next.

  • states: [{"id": "romcode", "label": "ROM code"}, {"id": "tfa", "label": "TF-A"}, {"id": "uboot", "label": "U-Boot"}, {"id": "kernel", "label": "Linux kernel"}, {"id": "init", "label": "init"}]
  • transitions: [{"from": "romcode", "to": "tfa", "event": "loads TF-A"}, {"from": "tfa", "to": "uboot", "event": "loads U-Boot"}, {"from": "uboot", "to": "kernel", "event": "starts kernel"}, {"from": "kernel", "to": "init", "event": "runs init"}]
The software stack that runs on the targetYour applicationthe product's purposeRoot filesystemC library, init, BusyBoxLinux kerneldrivers, scheduler, memoryBootloaderU-BootHardwareSoC, RAM, flashruns on the target, built by the cross toolchainon the hostYour applicationthe product's purposeRoot filesystemC library, init, BusyBoxLinux kerneldrivers, scheduler, memoryBootloaderU-BootHardwareSoC, RAM, flashruns on the target, built by thecross toolchain on the host
The software stack that runs on the target, from hardware up to your application
The kernel is not the OS

A common mistake is to say "the kernel is the operating system". The kernel is one block. A working system also needs a bootloader to start it, a root filesystem to run programs from, and a toolchain that built all of it.

04

Choosing Linux: the decision matrix

3 min read

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.

Choosing between an RTOS and embedded LinuxRTOS or baremetalEmbeddedLinuxNeeds MMUnoyesTypical RAMkilobytes16 MiB ormoreBoot timemillisecondsabout asecondWorst-caselatencymicroseconds,boundedmilliseconds,best-effortPowercoin-cellcapablebattery ormains
The criteria that push a design toward an RTOS or toward embedded Linux

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.

05

Hardware criteria and the course boards

2 min read

A 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.

The three boards in this course

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.

SoC, board and BSPBSPvendor kernel, drivers, U-BootBoardpower, connectors, RAM, flashSoCCPU cores plus peripheralsvendor software sits on the board, which is builtaround the SoCBSPvendor kernel, drivers,U-BootBoardpower, connectors, RAM, flashSoCCPU cores plus peripheralsvendor software sits on theboard, which is built around theSoC
The three layers: SoC, board and the BSP that ties them to Linux
06

The host/target split and cross-compilation

3 min read

The 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.

bash
sudo apt update
sudo apt install -y build-essential git
From source on the host to a running target binarySourcehello.c onthe hostCross-compilearm-linux-gnueabihf-gccTargetbinaryArm ELFexecutableCopy toboardSD card ornetworkRun ontargetthe boardexecutes itSourcehello.c onthe hostCross-compilearm-linux-gnueabihf-gccTargetbinaryArm ELFexecutableCopy toboardSD card ornetworkRun ontargetthe boardexecutes it
Source is compiled on the host into target binaries that are then copied and run on the board
07

UART, logic levels and the USB-serial adapter

3 min read

A is the oldest and simplest form of device communication, and it is the one thing that works on a new board from the very first instruction the ROM code executes. The connection is two data wires plus a ground reference. The rule is crossed: one side's transmit (TX) connects to the other side's receive (RX), and vice versa, so that what one sends the other hears. The ground wires must be joined, because the two ends need a common reference voltage, and without it the data lines cannot be interpreted.

The subtlety is the voltage level. A PC's traditional serial port follows the RS-232 standard, which uses inverted, bipolar voltages around plus and minus 3 to 15 volts. An idle RS-232 line sits at a negative voltage, and a data bit is a positive voltage. A modern board's UART, by contrast, speaks TTL logic at 3.3 V: roughly 0 V for a logic 0 and 3.3 V for a logic 1. The two are electrically incompatible, so a bare PC serial port cannot be wired straight to a board.

Going deeperWhy RS-232 is inverted and bipolar

RS-232 dates from the 1960s, when it drove long cables and electromechanical equipment. Using a negative voltage for the idle "mark" state and a positive voltage for "space" made it robust against noise and capacitive coupling over tens of metres of cable, and meant a broken or unplugged line simply read as idle. The modern USB-to-serial adapter contains a small chip that translates between USB and either TTL or RS-232 levels, which is why the same adapter exists in both a 3.3 V TTL version and a full RS-232 version.

This is where the USB-to-serial adapter enters. It converts USB on the host into the TTL-level UART signals the board expects, and it presents the result to Linux as a device node such as /dev/ttyUSB0. The adapter you need for a board is a 3.3 V TTL adapter, with pins for TX, RX and ground. The adapter's TX goes to the board's RX, its RX to the board's TX, and the grounds join.

Never feed 5 V TTL into a 3.3 V board

A Raspberry Pi's UART and GPIO pins are 3.3 V and are not 5 V tolerant. A 5 V serial adapter connected straight to them can damage the SoC. Check the adapter's voltage before wiring, and use a 3.3 V adapter or a level shifter.

Correct UART wiringAdapter TXto board RXAdapter RXto board TXGround togroundAdapter TXto board RXAdapter RXto board TXGround toground
Crossed TX and RX with a shared ground, the only correct way to wire a UART
08

Serial framing and flow control

3 min read

A UART is asynchronous, which means there is no separate clock line telling the receiver when to sample. Both ends must be configured to the same , the same number of data bits, the same parity, and the same number of stop bits. The common shorthand for the standard configuration is 115200 8N1: 115200 baud, 8 data bits, no parity, 1 stop bit.

Each byte is sent as a frame. The line idles in the "mark" state, which for TTL is high. A start bit (always low) announces the beginning, then come the data bits least-significant first, then an optional parity bit, then one or more stop bits returning the line to idle. At 115200 baud with 8N1, each byte costs 10 bit times, so the wire carries roughly 11,520 bytes per second.

Step by stepHow one byte becomes a UART frame
  1. Idle: the line rests in the mark state, high for TTL, and stays there between frames.

  2. Start bit: the transmitter pulls the line low for exactly one bit time to signal the frame's beginning.

  3. Data bits: eight bits follow, least significant bit first, each held for one bit time.

  4. Parity (none): with 8N1 no parity bit is sent, so there is no per-byte error check.

  5. Stop bit: the line returns high for one bit time, and the receiver waits for the next start bit.

Parity is an optional single bit that makes the count of 1 bits even or odd, catching single-bit errors. Modern embedded consoles almost always use no parity (the N in 8N1), relying on higher-level protocols for error detection, so a corrupt byte shows up as a wrong character rather than as a flagged error.

Flow control prevents a fast sender from overflowing a slow receiver. Hardware flow control uses two extra wires, RTS and CTS, where the receiver asserts its ready-to-send line to say it can accept data. Software flow control uses two reserved bytes instead, XON and XOFF: the receiver sends XOFF to ask the sender to pause and XON to resume. For a console connection flow control is normally left off, because both ends and the human at the keyboard keep up easily, and the extra wires only complicate the wiring.

One 115200 8N1 frameUART framestartD0..D7stop115200 8N1: no parity bit
The bit layout of a single 115200 8N1 byte: start bit, eight data bits, stop bit
09

Serial console programs and reading the boot log

4 min read

Three programs dominate embedded serial work, and they all do the same thing: open a serial device node, set the baud rate and framing, and pass characters between your terminal and the wire. picocom is the smallest and the usual first choice. minicom is the veteran, with menus and file-transfer support. screen is a general terminal multiplexer that also speaks serial. All three can drive the same /dev/ttyUSB0.

bash
# open a 115200 8N1 console with each tool
picocom -b 115200 /dev/ttyUSB0
minicom -b 115200 -D /dev/ttyUSB0
screen /dev/ttyUSB0 115200

Each has its own escape and exit key. In picocom the escape key is Ctrl-A, so you exit with Ctrl-A then Ctrl-X. In screen the escape is Ctrl-A too, and you quit with Ctrl-A then K. In minicom the escape is Ctrl-A, and you quit with Ctrl-A then X. This is a frequent source of confusion, so remember the tool you are in before typing Ctrl-A.

The device node name tells you which kind of adapter you have. A USB-to-UART bridge chip, such as an FTDI, CP210x or CH340, is driven by a dedicated USB-serial driver and appears as /dev/ttyUSB0. A board that implements the USB CDC-ACM class, which many modern boards and microcontroller programmer ports do, appears as /dev/ttyACM0 instead. Both are just serial ports to the console program, but the name is a useful clue about what is on the other end.

Underneath all three tools is the kernel's tty layer. When a console program opens the device it sets the line discipline into raw mode, disabling the terminal's normal line editing and echo so that the bytes pass through untouched. The same settings can be applied by hand with stty:

bash
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb

That command sets 115200 baud, 8 data bits, one stop bit, and no parity, the exact 8N1 framing.

Reading the boot log is the payoff. As the board powers on, the bootloader prints its banner, then the kernel prints a line for each subsystem it initializes, then init starts services and finally a login prompt appears. Typical output looks like this (yours will differ in version strings and hardware):

text
U-Boot SPL 2023.04 (Apr 03 2023 - 12:00:00 +0000)
Trying to boot from MMC1

U-Boot 2023.04 (Apr 03 2023 - 12:00:00 +0000)

Model: STMicroelectronics STM32MP157C-DK2 Discovery Board
Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 6.1.28 (learner@labpc) (arm-linux-gnueabihf-gcc (GCC) 12.2.0)
[    0.000000] CPU: ARMv7 Processor
...
STM32MP login:

The number in square brackets is the number of seconds since the kernel started, so it shows how long each step took. Every kernel message has a severity level assigned by the printk function, from KERN_EMERG at 0, the most urgent, through KERN_ALERT, KERN_CRIT, KERN_ERR, KERN_WARNING, KERN_NOTICE and KERN_INFO, down to KERN_DEBUG at 7.

Going deeperprintk levels and the console filter

Each printk call carries a numeric level. The kernel keeps a console_loglevel, and a message is printed to the console only if its level is more severe than (numerically below) that threshold. The default console_loglevel is 7, so everything down to KERN_DEBUG is shown by default. The quiet kernel argument lowers the threshold to 4, hiding INFO and DEBUG so only warnings and worse appear, which shortens boot and reduces log noise. The loglevel=N argument sets the threshold to N explicitly, and debug raises it to show every message. The early console, enabled with earlycon, is a minimal console set up before the real drivers exist, so you can see output even when the UART driver has not loaded yet. You will tune all of this when optimizing boot time in a later session.

The console= kernel argument selects which device the kernel uses as its console and with what settings, for example console=ttySTM0,115200. On the host side, the same boot log is available after the fact from the kernel ring buffer with dmesg, and you can identify the four building blocks in a running system with a handful of commands:

bash
uname -a              # the kernel version
cat /proc/version     # how the kernel was built, including the toolchain
mount | head -5       # where the root filesystem is mounted from
The sequence of banners in a boot logBootloaderbannerU-Boot SPL,then U-BootEarlyconsolefirstkerneloutputKernelmessagestimestampedprintklinesinit andservicessystemd orBusyBoxinitLoginpromptready for asessionBootloaderbannerU-Boot SPL,then U-BootEarlyconsolefirstkerneloutputKernelmessagestimestampedprintklinesinit andservicessystemd orBusyBoxinitLoginpromptready for asession
The sequence of banners in a boot log, from bootloader through kernel to login
10

Device tree as a concept, and common mistakes

4 min read

A desktop PC discovers its hardware at run time: it can ask the PCI bus what is plugged in. An embedded board cannot, because much of its hardware is wired directly to the SoC with no way to be discovered. For years the kernel encoded this knowledge in per-board C files, which meant every new board needed kernel source changes. The modern mechanism is the .

The device tree is written as source in a file with a .dts extension, compiled by the dtc tool into a binary .dtb blob, and handed to the kernel by the bootloader alongside the kernel image. It lists the SoC's memory, CPUs, and each peripheral with its memory address, interrupt and clock, in a tree of named nodes. The kernel's drivers match against these nodes and claim the devices they describe, which is how a single kernel build can run unchanged on many different boards.

Going deeperA small device tree in source form

Here is a simplified example of the shape of a device tree, showing a board node, a memory node, and a UART node with its address:

dts
/ {
    model = "Acme Widget Board";
    compatible = "acme,widget-board";

    memory@c0000000 {
        device_type = "memory";
        reg = <0xc0000000 0x20000000>;
    };

    uart0: serial@40010000 {
        compatible = "arm,pl011";
        reg = <0x40010000 0x1000>;
    };
};

The compatible property names the driver that should claim each node. The kernel reads the compiled .dtb at boot, and this is why the same kernel image boots across many boards. You will write and debug device trees in a dedicated session later in the module.

Per the device tree example, memory sits at 0xc0000000 (512 MiB) and the UART registers at 0x40010000 (4 KiB).

  • regions: [{"name": "Memory", "start": "0xc0000000", "size": "0x20000000", "detail": "512 MiB DDR at memory@c0000000"}, {"name": "UART", "start": "0x40010000", "size": "0x1000", "detail": "PL011 UART register block at serial@40010000"}]

Every one of these topics has a classic mistake attached to it. Learning to recognize the symptom and the cause, not just the fix, is what separates a professional from someone who types commands at random.

Common mistakes and how to undo them

Wrong voltage. Symptom: the board does not respond at all, or it responds once and then stops. Cause: a 5 V adapter wired to a 3.3 V-only UART, or a missing ground. Diagnose: check the adapter's marked voltage and confirm TX, RX and ground are all connected, crossed correctly. Fix: use a 3.3 V adapter or a level shifter, and join the grounds.

Baud mismatch. Symptom: the console shows a stream of nonsense characters. Cause: the two ends disagree on baud rate or framing. Diagnose: this is the most common "board is broken" false alarm. Fix: set both ends to the same value, almost always 115200 8N1, and confirm the adapter's own settings match.

Assuming the vendor kernel is forever. Symptom: a product runs an old kernel and cannot receive security fixes. Cause: building only from the vendor BSP and never checking mainline. Diagnose: test whether the board's drivers exist in a current mainline kernel. Fix: prefer vendors who upstream their code, and track mainline support when selecting the chip.

Calling serial obsolete. Symptom: a project skips the debug UART to save cost and then cannot bring up the board. Cause: forgetting that the serial console is the first thing that works. Fix: keep at least a test-point UART on prototypes, because it works before USB, video or networking exist.

A device tree describing a board/root nodememoryRAM rangecpuprocessor coresuart0serial porti2c0sensor bus/root nodememoryRAM rangecpuprocessor coresuart0serial porti2c0sensor bus
A device tree describes memory and peripherals as nodes the kernel matches to drivers
11

Try it

1 min read

Open a serial console on a real or emulated board and watch it boot end to end. Flash a stock Raspberry Pi OS image to a microSD card, wire a 3.3 V USB-to-serial adapter to the Pi with TX crossed to RX and grounds joined, and connect with picocom at 115200 8N1. Capture the full boot log to a file, then identify each of the four building blocks in the running system with uname -a, /proc/version and mount, and experiment with sending a file and interrupting the bootloader prompt over the same serial line. The companion practice pack walks through each step, including the QEMU fallback when no board is available.

Key takeaways

  • An embedded system is a computer with one dedicated job inside a product, and it is not defined by being small or cheap.
  • 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.
  • 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.
  • A UART serial console works from the very first boot stage, long before USB, video or networking exist.
  • Board UARTs are 3.3 V TTL logic; RS-232 ports use inverted bipolar signals, so a USB-to-serial adapter is needed to connect the two.
  • 115200 8N1 means 115200 baud, 8 data bits, no parity and one stop bit, and both ends must agree or you see garbage.

Reflect

  1. Explain to a colleague, in two sentences: explain what makes a system embedded and contrast bare-metal and RTOS firmware with embedded Linux.
  2. Which objective are you least sure about? Re-read that section, then do its exercise in the practice pack.
  3. 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.

Practise this lessonExercises, quiz, interview preparation and spaced review

References and further reading

Official documentation first. Links checked when the lesson was published.

Find your next step

↑ ↓ to move · Enter to open · Esc to close