Skip to content
Back to skills

Embedded Linux

ASecurity

This skill should be used when the user builds or reviews a product that runs Linux on an application processor, for example "embedded Linux", "Raspberry Pi CM4 / CM5 product", "Yocto", "Buildroot", "device tree", "U-Boot", "i.MX", "STM32MP" or "MCU or Linux?". It covers the SoM choice, boot chain, drivers, A/B updates and hardening. Load it before recommending a module or an update method, because its choices are checked against the vendors' documents.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentsrustgotestingdebugginggitdatabasedocumentation

Works with

  • cli

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add gkochievi/boulder-hardware-skills --skill embedded-linux --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Embedded Linux?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Embedded Linux
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gkochievi-embedded-linux/badge)](https://www.skillsdirectory.com/skills/gkochievi-embedded-linux)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: embedded-linux
description: This skill should be used when the user builds or reviews a product that runs Linux on an application processor, for example "embedded Linux", "Raspberry Pi CM4 / CM5 product", "Yocto", "Buildroot", "device tree", "U-Boot", "i.MX", "STM32MP" or "MCU or Linux?". It covers the SoM choice, boot chain, drivers, A/B updates and hardening. Load it before recommending a module or an update method, because its choices are checked against the vendors' documents.
user-invocable: false
---

# Embedded Linux products

Take a product from "it runs on a dev kit" to a device that boots the same way every time, updates itself without bricking, survives power cuts and can be built again in five years. The references hold the detail with sources; this file sets the order of work and the checks. MCU choice and firmware stay in `microcontrollers` and `embedded-firmware`; board layout in `pcb-design`.

## 1. Decide: microcontroller or Linux

Ask what the device must do, then use the table. Default to an MCU; move to Linux for a named reason.

| Requirement | MCU (`microcontrollers`) | Linux on an MPU |
|---|---|---|
| Time from power-on to working outputs | milliseconds | seconds (typically 2–30 s, common practice) |
| Hard real-time, microsecond jitter | yes, in hardware or an ISR | PREEMPT_RT reduces but does not bound worst-case latency without measurement; put the loop on the SoC's Cortex-M core or an MCU |
| Sleep on a battery | µA with RAM retained | mA at best in suspend to RAM (common practice); usually mains powered |
| Full TCP/IP with TLS, many sockets, a web stack, databases | constrained | yes |
| Camera, video, GPU UI, USB host classes, cellular modem with PPP / QMI / MBIM, audio, Bluetooth audio | partial | yes |
| BOM and board | MCU or module, 2–4 layers | DDR, PMIC, eMMC: a SoM, or a 6+ layer chip-down board |
| Software maintenance | one firmware image | hundreds of packages with CVEs for the product's life |
| Team | firmware engineer | BSP, kernel and userspace skills |

Common splits: Linux for the network, UI and storage plus an MCU (or the SoC's M-core) for I/O that must stay safe when Linux crashes or reboots. Keep the safety rules from `embedded-firmware` ("outputs off before anything else", "nothing switches on by itself") on the MCU side. Products with digital elements sold in the EU fall under the Cyber Resilience Act: vulnerability reporting obligations apply from 11 September 2026, the main obligations from 11 December 2027. Plan CVE tracking and updates from day one (`references/build-systems.md` section 7).

## 2. Pick the platform

1. **SoM unless volume and team justify chip-down.** DDR routing, PMIC sequencing and DDR calibration are why SoMs exist (`references/platforms-and-boot.md` section 1). Chip-down makes sense at volume (thousands of units a year is a common threshold, common practice) with an experienced layout and BSP team, or with a SiP that integrates the DDR (Microchip SAM9X60D1G: 1 Gbit DDR2 in the package).
2. **Shortlist SoCs by need:** real-time core, NPU, video, Ethernet ports, CAN-FD, temperature grade, secure boot, mainline kernel support, longevity statement. Table in `references/platforms-and-boot.md` section 2.
3. **Raspberry Pi CM4 / CM5** for fast development with a large community: CM4 stays in production until at least January 2034, CM5 until at least January 2036 (Raspberry Pi product pages, October 2026). Check the temperature range and that you can live with one vendor's boot firmware.
4. **Check the SoM vendor's BSP** before the hardware: which Yocto release and kernel version it supports, whether the SoC is in mainline Linux and U-Boot, how long the vendor maintains it, and the carrier-board design guide.
5. Record the choice with two runners-up (`/engineering:architecture` if installed).

## 3. Choose the BSP and build system

| Pick | When | Watch |
|---|---|---|
| Yocto / OpenEmbedded | default for products; vendor BSPs ship as Yocto layers; SBOM and license tooling built in | learning curve, build machine (hundreds of GB of disk) |
| Buildroot | small, single-purpose images, fast builds, a team that wants simplicity | no package feeds; every change is a full image; fewer vendor BSPs |
| Debian / Ubuntu / Raspberry Pi OS based | prototypes, low volume, apps that need many Debian packages | large images, slower boot, harder reproducibility and license bundle, distro release cadence |

As of October 2026: Yocto 6.0 "Wrynose" is the newest LTS (supported to April 2030) and 5.0 "Scarthgap" is still LTS (to April 2028); Buildroot 2025.02.x is the current LTS (to March 2028), and since 2025 Buildroot makes an LTS only in odd years. Pin every layer or Buildroot commit; never build products from `master`. Details: `references/build-systems.md`.

## 4. Boot chain and secure boot

1. Draw the chain for the chosen SoC: ROM → SPL or TF-A BL2 (DDR init) → TF-A BL31 / OP-TEE → U-Boot → kernel + device tree + initramfs → rootfs. Raspberry Pi replaces this with its EEPROM bootloader and `config.txt`.
2. Put the boot environment where it survives power loss (U-Boot redundant environment) and reach it from Linux with `fw_printenv` / `fw_setenv`.
3. Set up A/B boot with boot counting before the first field unit: `bootcount` / `bootlimit` / `altbootcmd` or the update tool's own variables (RAUC: `BOOT_ORDER`, `BOOT_x_LEFT`). Userspace marks a boot good only after its health check.
4. Plan secure boot early, enable it late: NXP HABv4 (i.MX 6 / 7 / 8M) or AHAB (i.MX 8 / 8X / 9x), STM32MP authenticated FSBL with keys in OTP, Raspberry Pi signed boot with a key hash in OTP. Fusing keys and closing the device are one-way: rehearse on scrap boards, check the ROM's event log (`hab_status`, `ahab_status`) shows no events with signed images, keep unlocked boards. Extend the trust into the rootfs (dm-verity or a signed read-only image) or secure boot stops at the kernel.
5. Choose storage: eMMC for products, SD only with industrial cards and a recovery path, raw NAND with UBI / UBIFS. Details: `references/platforms-and-boot.md` sections 3–7.

## 5. Write the device tree for the carrier board

- Include the SoM vendor's `.dtsi` and describe only the carrier in your `.dts`: enable used controllers, add the devices on each bus, set pinctrl for every pin, disable everything unused.
- Use existing bindings and compatibles from `Documentation/devicetree/bindings`; a new vendor-prefixed compatible needs a binding (YAML) if it goes upstream. Validate with `make dtbs_check`.
- Name GPIO lines (`gpio-line-names`) so userspace uses names, not numbers. Define boot-time output levels in hardware (pull resistors), not only in the device tree.
- Use overlays for add-on boards and options, compiled with `dtc -@`. Test merges on the host with `fdtoverlay` before booting.
- Details and a carrier `.dts` example: `references/kernel-dt-and-drivers.md` sections 1–4.

## 6. Drivers

1. Search for an existing driver and binding first (`grep -r '"vendor,part"' drivers/ Documentation/devicetree/`). Most sensors, RTCs, EEPROMs, LEDs, keys, ADCs and expanders have one.
2. Expose hardware through the right subsystem: LEDs class, `gpio-keys` (input), IIO for ADCs and IMUs, hwmon for temperatures and fans, RTC, nvmem for EEPROMs, PWM, watchdog. A custom char device or ioctl is the last resort.
3. If you must write one, write a platform (or I2C / SPI) driver bound by `compatible`, with `devm_*` resources and `dev_err_probe()`; start from `examples/hello-module/`.
4. Build out-of-tree modules with a `Kbuild` file and `make -C <kernel build dir> M=$PWD modules`; in Yocto use a `module` recipe, in Buildroot the kernel-module package infrastructure.
5. Loadable modules need `CONFIG_MODULES=y` in the target kernel (and signed modules when `CONFIG_MODULE_SIG_FORCE=y`). Disable modules only when every driver is built in.
6. From userspace: GPIO through the character device with libgpiod v2 (never `/sys/class/gpio`), I2C with i2c-tools, SPI with spidev bound to a real compatible. Details: `references/kernel-dt-and-drivers.md` sections 5–11.

## 7. Userspace services

- One systemd unit per service: `Type=notify`, `WatchdogSec=` with `sd_notify("WATCHDOG=1")` from the main loop, `Restart=on-failure`, a start limit with `StartLimitAction=reboot` for services the product cannot live without, and sandboxing (`ProtectSystem=strict`, `NoNewPrivileges=yes`, a dedicated user).
- Hand the hardware watchdog to systemd with `RuntimeWatchdogSec=` in `system.conf`; one process owns `/dev/watchdog`.
- Read-only root filesystem; writable state only on a data partition (or tmpfs); journald with size limits or volatile storage; chrony with the RTC; NetworkManager (with ModemManager for cellular) or systemd-networkd; containers only when the application set changes independently of the OS.
- Details and unit files: `references/userspace-and-updates.md` sections 1–6.

## 8. Updates

Pick one A/B image update system and integrate it with the bootloader before the first release:

| Tool | Choose when |
|---|---|
| RAUC | Yocto or Buildroot, you run your own server or none; signed bundles, streaming install |
| SWUpdate | you need flexible handlers (MCU firmware, FPGA, partitions) or single-copy recovery; hawkBit client |
| Mender | you want a ready server (hosted or self-hosted) with fleet management |
| OSTree | file-level, delta-friendly updates; Debian- or Fedora-style systems, Torizon |

Every update is signed, installs to the inactive slot, boots with a boot counter, and is committed only after a self-test; the data partition carries state across slots with a schema version. Never update the bootloader in routine releases. Comparison and configuration: `references/userspace-and-updates.md` section 7.

## 9. Field hardening checklist

Check each before release:

1. Hardware watchdog active from early boot (U-Boot or kernel) to the main service.
2. Read-only rootfs; data partition mounted with a filesystem suited to power loss; atomic writes (write temp, `fsync`, `rename`, `fsync` the directory).
3. Power-cut test: hundreds of random power cuts during writes and updates without a lost boot (common practice).
4. No default passwords; SSH keys only or SSH off; per-unit credentials; serial console disabled or behind a login in production.
5. Logging bounded in size; no logs that wear the eMMC.
6. Time comes from NTP or an RTC before TLS starts.
7. Update with rollback tested by pulling power during install and by installing a deliberately failing image.
8. Secure boot and JTAG lock decided and documented per hardware revision.
9. SBOM, license bundle (source offer for GPL code) and CVE scan generated by the build for every release.
10. Factory reset path that wipes the data partition and keeps factory data (serial, MAC, calibration).
11. PREEMPT_RT only after a measured need; latency checked with `cyclictest` under load (`references/userspace-and-updates.md` section 8).

## 10. Production programming

- Program over USB from the ROM's recovery mode: NXP `uuu`, ST `STM32_Programmer_CLI` with a flashlayout TSV, Raspberry Pi `rpiboot` (or `rpi-sb-provisioner` for secure boot). Script it; no manual steps on the line.
- Write per-unit data (serial number, MAC addresses, keys, calibration) to a factory partition, eMMC boot area or OTP, and log it with the unit's ID.
- Fuse secure boot keys only from a verified station, verify, and keep the signing keys in an HSM or offline.
- Run a functional test from a test image or test mode, then boot the production image once before packing. Details: `references/platforms-and-boot.md` section 9.

## Corrections to common advice

- A kernel config fragment that sets `# CONFIG_MODULES is not set` while the same project ships a loadable `.ko` cannot work: the kernel refuses `insmod` and Kbuild will not build modules against it. Loadable modules need `CONFIG_MODULES=y` (and, when signing is enforced with `CONFIG_MODULE_SIG_FORCE=y`, modules signed with a key the kernel trusts). Disabling modules is a valid hardening choice only when all drivers are built in.
- `/sys/class/gpio` is deprecated (kernel Kconfig help for `GPIO_SYSFS`); use `/dev/gpiochipN` through libgpiod v2. libgpiod v2 tools changed syntax from v1; Ubuntu 24.04 still ships v1.6.3, Debian 13 ships 2.2.1.
- PREEMPT_RT is mainline since Linux 6.12 for x86, arm64 and RISC-V; LoongArch followed in 6.13 and 32-bit ARM only in 7.1. A 32-bit ARM SoC on an older kernel still needs the RT patch set.
- Buildroot's LTS is no longer every February: since 2025.02 it is the first release of odd years, supported for three years. 2026.02 is not an LTS.
- Yocto 6.0 obsoletes the `cve-check` class (replaced by `sbom-cve-check`) and supports only SPDX 3.
- UBIFS needs raw flash under UBI; it does not run on eMMC or SD, which are block devices.
- `compatible = "spidev"` no longer binds; use a compatible listed in the spidev driver or `driver_override`.

## References

| File | Use for |
|---|---|
| `references/platforms-and-boot.md` | why SoMs exist, SoC and SoM landscape with vendor support, boot flows, U-Boot environment, boot counting and A/B, secure boot per vendor, storage choice, production flashing |
| `references/build-systems.md` | Yocto (layers, machine, distro, images, devtool, SDK, releases), Buildroot (defconfig, BR2_EXTERNAL, LTS), Debian-based images, reproducibility, license compliance, SBOM and CVE tracking |
| `references/kernel-dt-and-drivers.md` | device tree, bindings, carrier `.dts`, overlays, pinctrl, kernel config fragments, out-of-tree modules, platform and misc drivers, subsystems instead of ioctls, libgpiod v2, I2C / SPI userspace, debugging |
| `references/userspace-and-updates.md` | systemd units and watchdogs, read-only rootfs, logging, time, networking, containers, RAUC / SWUpdate / Mender / OSTree, PREEMPT_RT and cyclictest, power-loss robustness, factory reset |

## The bundled example

`examples/hello-module/`: a platform driver bound by `compatible = "boulder,hello"` with module parameters, a misc device `/dev/hello` and an optional LED GPIO, a `Kbuild` + `Makefile`, and an overlay `hello-overlay.dts`. Its README lists the commands that built it against Ubuntu kernel headers 6.17 and 6.8 and compiled and merged the overlay with dtc 1.7.0. Copy its patterns; rename the compatible to the user's vendor prefix.

## Engineering plugin skills

If the Engineering plugin is installed: `/engineering:architecture` for MCU-versus-Linux, SoM and build-system decisions; `/engineering:system-design` for the service split and update architecture; `/engineering:testing-strategy` for power-cut, update and latency tests; `/engineering:deploy-checklist` before an image release; `/engineering:incident-response` for field failures.

## Related skills

- `microcontrollers`: when the answer to section 1 is "MCU", and for the companion MCU next to the SoC.
- `embedded-firmware`: production rules for the MCU side, OTP / fuse cautions, flashing probes (`embedded-firmware/references/flashing-and-debugging.md`).
- `pcb-design`: carrier-board layout, high-speed interfaces (`pcb-design/references/stackups-and-routing.md`), power and thermal (`pcb-design/references/power-and-thermal.md`).
- `electronics-fundamentals`: level shifting, power sequencing and protection around the SoM.
- `peripherals`: the sensors, RTCs, displays and radios the device tree describes.
- `ask-gela`: phases, decision log and deliverables for the whole product.

## Next step

When this is done, say what comes next: `microcontrollers` or `embedded-firmware` for a companion MCU, `iot-systems` for the fleet side, `bringup-and-test` for the first boot.

Files in this skill

  • SKILL.md15.4 KB
  • examples/hello-module/Kbuild183 B
  • examples/hello-module/Makefile973 B
  • examples/hello-module/README.md7.1 KB
  • examples/hello-module/hello-overlay.dts1.6 KB
  • examples/hello-module/hello.c5.1 KB
  • references/build-systems.md27.9 KB
  • references/kernel-dt-and-drivers.md31.3 KB
  • references/platforms-and-boot.md38.3 KB
  • references/userspace-and-updates.md31.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.