knaxuslearn · build · ship

Roadmaps / Embedded Linux / Phase 1

Phase 1 of 4 · Study weeks 1-4

Reproducible builds and your own layer

This phase gives you an image you can rebuild exactly, so every later change has a baseline. Read the Yocto Project overview and the BitBake user manual sections on tasks and the shared state cache (sstate) as you go.

Topics every week

  1. Week 18 h
    • Yocto concepts: layers, recipes, images, machines, the BitBake task graph, the sstate cache
    • the first build with kas

    Hand inA build of a minimal qemuarm64 image booting in QEMU, with a record of build time, disk use and the sstate hit rate on a second build

  2. Week 28 h
    • Your own layer: an image recipe, a recipe and systemd unit for gwd, devtool for changing a recipe

    Hand inmeta-fleetgw with gwd in the image, started by a unit, with the smoke test

  3. Week 38 h
    • Pinning and reproducibility: commit pins, source mirrors, what makes a build differ between runs (timestamps, build paths, wic UUIDs), buildhistory and diffoscope
    • image size

    Hand inA diff of two clean builds: package list, versions and image hash, with each difference explained

  4. Week 48 h
    • Read-only root (and a plan for /var and volatile paths), a data partition and the wic image layout
    • check scripts for CI

    Hand inCheckpoint 1, built in four steps: the kas file; the layer; the pin check; the two-build diff (then the captures)

Practice projects

  1. Add a second package to the image with devtool add and remove it again. Done when the package appears in and then leaves the manifest and the image size changes by the number you predicted.
  2. Rebuild from a clean directory with a populated sstate cache and again without one. Done when you report both times and the cache hit rate, and explain the gap.
  3. (Optional for a fresher) Add a pre-commit check that fails on any unpinned repository. Done when the seeded fault (fault 1) makes it fail.

GitHub repos to study

RepoWhat to readWeek
siemens/kasThe documentation and the configuration format for pinning layers1, 4
bootlin/yocto-kissA deliberately small Yocto setup (branch wrynose) to compare with yours1 to 3
openembedded/meta-openembeddedRecipes you will copy the style of (meta-oe)2

Milestone checkpoint

Build twice from clean directories, diff the results and run the seeded unpinned layer. Done when the Checkpoint 1 row passes. Evidence: the two manifests and their diff, the check script and its failure on the seeded fault, build time and disk use, ADR-1 (why Yocto and not Buildroot: layers, a long-term release to April 2030 and the SBOM and CVE tooling, against a smaller build, with your numbers; the ten-year promise outlasts that release, so state the migration plan).

Check yourself

Answer each question in your head first, then open it to check.

  1. What is the difference between a recipe, a layer and an image?
    A recipe says how to fetch, build and package one piece of software; a layer is a directory of recipes and settings; an image recipe lists what goes into the root filesystem.
  2. Why does a branch name make a build non-reproducible?
    The branch moves, so the same name gives different source on different days.
  3. What does the sstate cache save, and what can make it miss?
    It saves task outputs (compiled packages) keyed by their inputs; a change to a recipe, a variable or a dependency invalidates the key and forces a rebuild.
  4. Why mount the root filesystem read-only?
    A power cut cannot corrupt what is never written, and a changed system file is easy to detect; writable state goes to a data partition, and /var and other volatile paths need a plan (tmpfs or the data partition).
  5. What is a machine, and what changes when you switch from qemuarm64 to a real board?
    A machine names the hardware settings (CPU architecture, kernel, bootloader, image layout). A real board changes the kernel configuration, the device tree and the bootloader.