Master Yocto Interview Questions (2025) SET #2
, , , , , ,

Master Yocto Interview Questions (2025) | SET #2

Prepare for your embedded Linux career with our comprehensive guide on Yocto Interview Questions. This article covers common and advanced questions, practical tips, and step-by-step explanations to help you confidently crack Yocto-related interviews. Ideal for beginners and experienced developers aiming to strengthen their Yocto knowledge and ace technical rounds.

When Ravi, a young embedded developer, first joined an automotive company, he was super excited about working with Yocto. On his very first task, he was asked to customize the Linux kernel and add a new package to the image. But he frozeโ€”he only knew the basics of Yocto and BitBake. His senior smiled and said:

โ€œDonโ€™t worry, once you understand the intermediate concepts, Yocto will feel less scary and more powerful.โ€

Thatโ€™s exactly what this article is about. If youโ€™ve already covered the Yocto basics, these intermediate interview questions will help you prepare for real-world scenarios like Raviโ€™s.

Meet Priya, an embedded engineer who needs a custom Linux image for a BeagleBone. Sheโ€™s never built a full Yocto image before, so she treats the work like a recipe: gather ingredients, prepare the kitchen, follow the steps, and taste-test the result. Below is the recipe Priya followed โ€” written so you can copy, paste, and run it yourself.

Short roadmap (what youโ€™ll do)

  1. Prepare your build host and install prerequisites.
  2. Fetch Yocto (poky) and any BSP/meta layers.
  3. Create a build directory and source the environment.
  4. Configure local.conf and bblayers.conf.
  5. Add custom layers or recipes (optional).
  6. Run bitbake <image> to build.
  7. Inspect outputs, SDKs, and caches.
  8. Debug and iterate.

The step-by-step story (with commands & why)

1) Prepare the build host

Priya installs the packages the Yocto docs list (Python, git, required dev libs). Having the recommended host packages avoids weird failures later. The Yocto Quick Start lists the build-host prerequisites and the basic flow to get started. (Yocto Project Documentation)

Why: Yocto builds are heavy and sensitive to host tools. Install the distro packages the docs recommend before you start.

2) Get the source: clone poky and layers

Priya clones poky (the Yocto reference distribution) and any layers she needs (for example meta-openembedded, vendor BSP layers, or meta-myproject).

git clone git://git.yoctoproject.org/poky
cd poky
git clone git://git.openembedded.org/meta-openembedded ../meta-openembedded
# add other BSP/meta layers as needed

This is the usual starting point for a Yocto build. The Quick Build shows the typical checkout-and-build flow. (Yocto Project Documentation)

3) Create a build directory and source the environment

Priya runs the helper script to create and enter a build environment:

source oe-init-build-env build
# or: . ./oe-init-build-env

That script creates build/conf/ and sets up environment variables so bitbake works from the build directory. (Yocto Project Documentation)

4) Configure the build (local.conf & bblayers.conf)

Inside build/conf/ there are two files you edit:

  • local.conf โ€” set MACHINE, BB_NUMBER_THREADS, PARALLEL_MAKE, and paths for DL_DIR and SSTATE_DIR.
  • bblayers.conf โ€” list the layers (paths) the build should use.

Priya sets MACHINE to her board (e.g., beaglebone), points DL_DIR and SSTATE_DIR to a big fast disk, and tweaks thread counts so the build uses her CPU effectively. The Yocto build docs explain how these files control the build and where to set caches and machine targets. (Yocto Project Documentation)

Tip: Use a shared sstate-cache if you build multiple images or share between developers โ€” it saves a lot of rebuild time.

5) Add or create a layer (optional; for your recipes)

If Priya needs to add a custom driver or recipe, she either adds an existing layer with:

bitbake-layers add-layer ../meta-my-layer

or creates one (yocto-layer helper or templates) and puts .bb recipes there. Layers let you keep custom code separate from upstream meta layers. The Yocto docs and common tasks sections show how layers and recipes organize metadata. (Yocto Project Documentation, The Yocto Project)

6) Build the image with BitBake

Now the main command:

bitbake core-image-minimal   # or your custom-image

What happens under the hood? BitBake parses recipes, resolves dependencies, and runs recipe tasks in order (for each recipe: do_fetch โ†’ do_unpack โ†’ do_patch โ†’ do_configure โ†’ do_compile โ†’ do_install โ†’ do_package โ†’ do_populate_sysroot / image assembly). These tasks and their ordering are defined in the build system and are executed automatically. (Yocto Project Documentation)

Practical notes:

  • Build time depends on what needs to be compiled and whether artifacts exist in sstate/DL_DIR.
  • Use bitbake -k <image> to keep building other packages when failures occur, or bitbake -c cleansstate <recipe> to force rebuilding a recipe from scratch.

7) Where the results live (artifacts)

When the build succeeds, Priya finds images and packages under:

build/tmp/deploy/images/<MACHINE>/

There will be kernel zImage/uImage, rootfs tarballs, wic images, and package feeds. If she built an SDK, it appears from bitbake -c populate_sdk <image> (or bitbake <image>-sdk). The Yocto Quick Build and build docs describe where these outputs are placed. (Yocto Project Documentation)

8) Caching & downloads โ€” why they matter

Two folders are critical:

  • DL_DIR โ€” stores downloaded source tarballs.
  • SSTATE_DIR โ€” shared state cache with prebuilt intermediate results.

Priya points these to persistent storage so subsequent builds (or other developers) reuse downloads and compiled pieces โ€” massively speeding up rebuilds. The docs emphasize using DL_DIR and SSTATE_DIR to optimize builds. (Yocto Project Documentation)

9) Useful BitBake commands for iteration & debugging

  • bitbake -c listtasks <recipe> โ€” show available tasks.
  • bitbake -c fetch <recipe> โ€” fetch sources only.
  • bitbake -c cleansstate <recipe> โ€” erase sstate for a recipe.
  • bitbake -e <recipe> โ€” show environment variables.
  • bitbake <recipe> -c devshell โ€” drop into a build shell for debugging (if supported).
  • Inspect logs: build/tmp/work/<arch>/<recipe>/<version>/temp/log.* for do_compile, do_configure, etc.
    See the tasks and common tasks docs for more debugging workflows. (Yocto Project Documentation)

Quick troubleshooting checklist (like Priyaโ€™s pocket notes)

  • If a dependency fails to fetch: check DL_DIR and proxy settings.
  • If compile fails: inspect the recipeโ€™s log.do_compile and try bitbake -c cleansstate <recipe> and rebuild.
  • If build is slow: increase BB_NUMBER_THREADS and PARALLEL_MAKE in local.conf and ensure sstate is on fast storage.
  • If image missing a package: add it to IMAGE_INSTALL in local.conf or the image recipe.

Final โ€” a one-paragraph recap

Priyaโ€™s Yocto build was a sequence of preparation (host packages), pulling the right metadata (poky and layers), configuring local.conf/bblayers.conf, and running bitbake which orchestrates many recipe tasks (fetch โ†’ configure โ†’ compile โ†’ package โ†’ assemble image). Artifacts end up in tmp/deploy/images/<MACHINE>, while DL_DIR and SSTATE_DIR speed up future builds. The Yocto docs (Quick Start, build/dev manual, and BitBake tasks reference) are excellent companions while you learn and iterate. (Yocto Project Documentation, The Yocto Project)

Imagine you are working in a kitchen that serves hundreds of recipes every day. Instead of writing the same steps like โ€œwash vegetables, cut onions, add oil to the panโ€ in every recipe card, you create a shared guidebook. Every new recipe just says โ€œfollow the guidebook for chopping and fryingโ€ โ€” simple, clean, and reusable.

Thatโ€™s exactly what a .bbclass file does in Yocto.

A .bbclass file is a BitBake class file used in Yocto.
It contains common functions, tasks, and variables that can be inherited by multiple recipes (.bb files).

Instead of duplicating code across recipes, developers put shared logic in a .bbclass file and then use:

inherit <classname>

inside their .bb recipe.

Why is it used? (Benefits)

  1. Code Reuse โ†’ Write once, use everywhere.
    Example: packaging steps, fetching from Git, or autotools build flow.
  2. Consistency โ†’ Ensures all recipes follow the same structure for similar tasks.
  3. Simplifies Maintenance โ†’ Fix a bug or update logic in one .bbclass file, and all recipes that inherit it get the fix automatically.
  4. Customization โ†’ Developers can create their own custom classes (like mycompany-update.bbclass) to enforce company-specific build rules.

Examples in Yocto

  • autotools.bbclass โ†’ Provides standard tasks for configure/compile/install when building with GNU Autotools.
  • cmake.bbclass โ†’ Defines how to build packages using CMake.
  • kernel.bbclass โ†’ Provides helper tasks for building Linux kernels.

In short:
A .bbclass file in Yocto is like a shared recipe guide. It holds reusable build instructions that multiple recipes can inherit, making builds more efficient, cleaner, and easier to maintain.

Rreal-life mini example to show how .bbclass makes your Yocto recipes clean and reusable.

Step 1: Create a custom .bbclass file

Letโ€™s say you often write recipes that install a simple script into /usr/bin. Instead of repeating the do_install task everywhere, you can create a .bbclass file:

my-common.bbclass

# my-common.bbclass
# A reusable class to install scripts into /usr/bin

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${WORKDIR}/${PN}.sh ${D}${bindir}/${PN}
}

What this does:

  • Creates /usr/bin in the rootfs (${bindir}).
  • Installs a script named after the recipe (${PN}.sh) into /usr/bin.

Step 2: Create two recipes that use this class

Now weโ€™ll write two recipes that inherit this class.

hello-script.bb

SUMMARY = "A simple hello world script"
LICENSE = "MIT"
SRC_URI = "file://hello-script.sh"

S = "${WORKDIR}"

inherit my-common

goodbye-script.bb

SUMMARY = "A simple goodbye script"
LICENSE = "MIT"
SRC_URI = "file://goodbye-script.sh"

S = "${WORKDIR}"

inherit my-common

Step 3: Add the scripts

Inside each recipeโ€™s files/ directory, add the scripts:

hello-script.sh

#!/bin/sh
echo "Hello, Yocto World!"

goodbye-script.sh

#!/bin/sh
echo "Goodbye, Yocto World!"

Step 4: Build and check

When you run:

bitbake hello-script
bitbake goodbye-script

๐Ÿ‘‰ Both will install their scripts into /usr/bin/hello-script and /usr/bin/goodbye-script, but thanks to my-common.bbclass, you didnโ€™t duplicate the do_install logic in each recipe.

Key Takeaway:
The .bbclass file acts like a reusable library of tasks. Instead of repeating installation steps across multiple recipes, you write them once and just inherit it.

Typical Layer Structure

When you create a new layer (say meta-mycustom), the structure looks like this:

meta-mycustom/
โ”œโ”€โ”€ conf/
โ”‚   โ””โ”€โ”€ layer.conf
โ”œโ”€โ”€ classes/
โ”‚   โ””โ”€โ”€ my-common.bbclass   <-- put your .bbclass file here
โ”œโ”€โ”€ recipes-example/
โ”‚   โ”œโ”€โ”€ hello-script/
โ”‚   โ”‚   โ”œโ”€โ”€ hello-script.bb
โ”‚   โ”‚   โ””โ”€โ”€ files/
โ”‚   โ”‚       โ””โ”€โ”€ hello-script.sh
โ”‚   โ””โ”€โ”€ goodbye-script/
โ”‚       โ”œโ”€โ”€ goodbye-script.bb
โ”‚       โ””โ”€โ”€ files/
โ”‚           โ””โ”€โ”€ goodbye-script.sh

Step 1: Add the .bbclass file

Inside your layer, create the classes/ directory (if it doesnโ€™t exist).
Then place your file here:

meta-mycustom/classes/my-common.bbclass

# my-common.bbclass
do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${WORKDIR}/${PN}.sh ${D}${bindir}/${PN}
}

Step 2: Update layer.conf

Make sure your layerโ€™s layer.conf knows where to find classes.
Inside meta-mycustom/conf/layer.conf, add:

BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
            ${LAYERDIR}/recipes-*/*/*.bbappend"

BBCLASS += "${LAYERDIR}/classes"

This tells Yocto where to look for recipes (.bb) and classes (.bbclass).

Step 3: Inherit the class in your recipes

Inside each recipe (hello-script.bb or goodbye-script.bb), add:

inherit my-common

Thatโ€™s it โ€” now both recipes reuse the logic from your .bbclass.

Step 4: Build and verify

From your build directory:

bitbake hello-script
bitbake goodbye-script

After build, check inside the rootfs (tmp/work/.../image/usr/bin/) and you should see:

/usr/bin/hello-script
/usr/bin/goodbye-script

In short:

  • .bbclass files live in classes/ inside your layer.
  • Point to them via layer.conf.
  • Inherit them in recipes to avoid duplicating code.

Imagine youโ€™re a chef in a big kitchen.

  • A recipe card (.bb file) tells you exactly how to cook a dish โ€” what ingredients to fetch, how to prepare them, and how to plate it.
  • But sometimes, you donโ€™t want to rewrite the whole recipe. Instead, you just want to say: โ€œAdd extra spicesโ€ or โ€œServe with saladโ€. Thatโ€™s where a .bbappend file comes in โ€” it lets you extend or modify the original recipe without copying the entire thing.

What is a .bb file?

  • A BitBake recipe file (.bb) describes how to build a package.
  • It contains instructions like:
    • where to fetch source code (SRC_URI)
    • how to configure and compile (do_compile, do_install)
    • what license applies
    • dependencies and tasks

Example: hello.bb

SUMMARY = "Hello World App"
LICENSE = "MIT"
SRC_URI = "file://hello.c"

do_compile() {
    ${CC} ${CFLAGS} ${LDFLAGS} hello.c -o hello
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 hello ${D}${bindir}/hello
}

This file defines the entire recipe for building the “hello” program.

What is a .bbappend file?

  • A BitBake append file (.bbappend) is used to extend or modify an existing recipe (.bb).
  • Its filename must match the recipe name and version it extends.
    • Example: hello_1.0.bbappend modifies hello_1.0.bb.
  • You can:
    • Add extra source files
    • Change dependencies
    • Add new tasks or override existing ones

Example: hello_1.0.bbappend

# Add an extra patch to hello recipe
SRC_URI += "file://hello-fix.patch"

do_install_append() {
    echo "Hello Yocto!" > ${D}${bindir}/extra.txt
}

This doesnโ€™t replace the original recipe โ€” it piggybacks on it and adds modifications.

Key Differences

Feature.bb File.bbappend File
PurposeDefines a recipe from scratchExtends or modifies an existing recipe
ContentFull build instructions (fetch, compile, install)Only contains changes or additions
Naming<recipe>_<version>.bb<recipe>_<version>.bbappend
Use CaseWhen creating a new package/recipeWhen tweaking an existing recipe (add patches, change variables, etc.)

In short:

  • .bb โ†’ full recipe (like the original cookbook entry).
  • .bbappend โ†’ patch/extension to an existing recipe (like adding your own notes on the cookbook page).

Ans: Imagine youโ€™ve just started working on a Yocto project. You open the project folder and see so many files and directories that it feels like walking into a big library with no map. Every book (or in Yoctoโ€™s case, every recipe) is kept in a section called a layer. But the question is: how do you quickly find out which sections exist, what books are inside, or where a new book should go?

Thatโ€™s where the bitbake-layers command becomes your guide. Think of it as the librarian of Yocto layers.

What can this “librarian” do for you?

  1. Show all the sections (layers) you already have bitbake-layers show-layers => Just like asking the librarian, โ€œWhich sections are in this library?โ€
  2. List all the books (recipes) inside bitbake-layers show-recipes => Youโ€™ll see all the recipes Yocto knows about.
  3. Find out who provides a specific book bitbake-layers show-recipes <recipe-name> => If the same book exists in two sections, this command tells you which one is being used.
  4. Add a new section to your library bitbake-layers add-layer ../meta-myproject => Imagine bringing a brand-new section of books and placing it in the library.
  5. Remove a section you no longer need bitbake-layers remove-layer ../meta-myproject => Just like taking out an old, unused section.
  6. Check which books have special notes (appends) bitbake-layers show-appends => Shows you all .bbappend filesโ€”like sticky notes attached to certain books with extra instructions.

Why is this helpful for beginners?

When youโ€™re new to Yocto, itโ€™s easy to get lost. The bitbake-layers command gives you clarity and control:

  • You know which layers are active.
  • You can quickly spot which recipe is being used.
  • Adding or removing layers becomes simple.

In short:
The bitbake-layers command is like a friendly librarian for your Yocto projectโ€”it shows you the layers, recipes, and lets you manage them without confusion.

Ans: Imagine you are building a huge Lego city with thousands of pieces. To make it faster and smoother, you donโ€™t want to run to the shop every time you need a piece, right? Youโ€™ll keep some parts in storage, reuse old ones, and have a special workbench where you assemble everything.

In Yocto, these three directories act just like that:

1. DL_DIR โ†’ The Lego Shop Bag

Whenever you need new Lego parts, you first download them. In Yocto, source codes, patches, and tarballs are downloaded and saved inside DL_DIR.

Purpose:

  • Stores all downloaded source files.
  • Prevents downloading the same thing again in future builds.
  • Saves internet bandwidth and time.

Think of it as the bag you bring home from the Lego shopโ€”you keep it safe so you donโ€™t need to buy the same piece twice.

2. SSTATE_DIR โ†’ The Reusable Parts Box

As you build, sometimes you already assembled something earlier, like a Lego house wall. Instead of rebuilding it from scratch, you pull it out of your reusable box.

Purpose:

  • Stores precompiled and cached build outputs.
  • Allows Yocto to reuse previous builds.
  • Makes repeated builds much faster.

Itโ€™s like your personal storage of pre-built Lego walls, windows, and doorsโ€”ready to plug in without wasting time.

3. TMPDIR โ†’ The Workbench

This is where the real action happens. You open the bag, take out pieces, use some from your reusable box, and build on your workbench.Purpose:

  • Stores all temporary build files.
  • Contains the working space for compiling, assembling, and linking.
  • Usually the largest directory in size.

Itโ€™s like the big table where you build your Lego city before showing it to the world.

Why are these three important together?

  • DL_DIR ensures you donโ€™t keep downloading sources.
  • SSTATE_DIR ensures you donโ€™t rebuild the same thing again.
  • TMPDIR is where Yocto actually builds your final image.

By using these three smartly, Yocto saves time, resources, and makes the build process efficient.

In short:

  • DL_DIR = Download bag (sources).
  • SSTATE_DIR = Reusable parts box (cached builds).
  • TMPDIR = Workbench (active build area).

Where do DL_DIR, SSTATE_DIR, and TMPDIR exist?

When you set up a Yocto build environment (by sourcing oe-init-build-env), a new folder called build/ (or whatever you named it) gets created. Inside this, there is a configuration folder called conf/local.conf.

This is the place where DL_DIR, SSTATE_DIR, and TMPDIR are defined.

Default locations:

  1. DL_DIR
    • Default: build/downloads/
    • You can change it in local.conf: DL_DIR ?= "${TOPDIR}/downloads"
    • This folder will contain all the tarballs, source code archives, and patches.
  1. SSTATE_DIR
    • Default: build/sstate-cache/
    • You can change it in local.conf: SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
    • This is where Yocto saves prebuilt shared state objects (cache).
  1. TMPDIR
    • Default: build/tmp/
    • You can change it in local.conf: TMPDIR ?= "${TOPDIR}/tmp"
    • This folder is the biggest oneโ€”it contains all intermediate build files, sysroots, and the final images.

So, do they always exist?

  • Yes, by default they get created automatically when you run your first bitbake build.
  • Their locations are controlled from local.conf (inside build/conf/).
  • You can move them outside the build folder if you want to share downloads or sstate across multiple projects.

In short:

  • These three directories exist inside your Yocto build directory by default.
  • Youโ€™ll see them as:
    • build/downloads โ†’ (DL_DIR)
    • build/sstate-cache โ†’ (SSTATE_DIR)
    • build/tmp โ†’ (TMPDIR)

Ans: Imagine you are preparing a lunchbox for a school trip. By default, the lunchbox already has some food itemsโ€”like rice, vegetables, and water. But suddenly your friend says: โ€œHey, can you also add some chocolates?โ€

In Yocto, your image is just like that lunchbox. It already contains some software packages, but you can add extra packages (like chocolates) to it before it is built.

Step-by-Step (with Story)

  1. Find the package you want
    • First, make sure the package exists in one of your Yocto layers.Example: Letโ€™s say you want to add nano (a text editor).
    Itโ€™s like checking if chocolates are available in your kitchen before packing. bitbake-layers show-recipes | grep nano
  1. Edit the Image Recipe ๐Ÿฅก
    • Open your custom image recipe or local.conf.Add the package under IMAGE_INSTALL_append.
    Example (inside local.conf): IMAGE_INSTALL_append = " nano" Just like putting chocolates inside the lunchbox.
  1. Rebuild the Image
    • Now build the image again using:
    bitbake core-image-minimal (or whichever image recipe you are using). This is like closing the lunchbox and preparing it for the trip.
  1. Flash and Check
    • Once the image is built, flash it to your board and boot.Run:
    nano --version If you see the version, it means your โ€œchocolateโ€ (package) is inside the lunchbox.

Why is this important?

Adding packages to a Yocto image is how you customize your embedded Linux system. Instead of shipping a plain box, you create a tailored image that has exactly the tools and applications you need.

In short:
To add a new package to a Yocto image, you:

  • Check if the package recipe exists.
  • Add it to your image (IMAGE_INSTALL_append).
  • Rebuild the image.
  • Boot and verify.

Itโ€™s just like packing extra food in your lunchbox before a tripโ€”simple, flexible, and under your control.

Adding Packages in Yocto: local.conf vs. Custom Image Recipe

Continuing with our lunchbox story

Imagine you are preparing lunch for a short picnic today. You quickly add a chocolate bar ๐Ÿซ inside your own lunchbox. But when you open a canteen business (serving hundreds of students every day), you wouldnโ€™t go and edit each lunchbox one by oneโ€”youโ€™d create a standard menu ๐Ÿฑ that always includes chocolates.

Thatโ€™s exactly the difference between using local.conf and a custom image recipe in Yocto.

Method 1: Add Packages in local.conf

This is the quick and easy way, like packing your own lunchbox just for today.

  • Open build/conf/local.conf.
  • Add your package: IMAGE_INSTALL_append = " nano htop"
  • Build the image.

Best for testing and experimenting with packages.
Not good for long-term projects, because your changes stay only in your local setup.

Method 2: Create a Custom Image Recipe

This is the professional way, like writing a canteenโ€™s fixed lunch menu ๐Ÿฑ. Every lunchbox that comes out will automatically follow this recipe.

Steps:

  1. Create a new recipe inside your own layer, e.g.: meta-myimage/recipes-core/images/my-image.bb
  2. Inside the .bb file, define your image: SUMMARY = "My Custom Image" LICENSE = "MIT" IMAGE_INSTALL += " \ nano \ htop \ vim \ " inherit core-image
  3. Build with: bitbake my-image

Best for real projects and teams where you want reproducibility and a clean history of changes.

Comparison Table

MethodWhen to UseExample Use Case
local.confQuick testing, one-time changesAdding nano just to try
Custom Image RecipePermanent project setupYour product image always needs nano + htop + vim

Ans : Letโ€™s imagine a real-life story:

You bought a smart coffee machine that runs on an embedded Linux system. The company shipped it with basic featuresโ€”make coffee, adjust temperature, etc. But as an engineer, you want to customize it. Maybe you want to add support for a new touchscreen display, or optimize the system to boot faster in the morning when youโ€™re half-asleep.

This is exactly like customizing the Linux kernel in Yocto. The kernel is the heart of your embedded device, and Yocto lets you tune it for your hardware.

Here are the steps youโ€™d follow in Yocto:

1. Identify Your Kernel Recipe

In Yocto, everything is managed with recipes. The Linux kernel recipe is usually found inside:

meta/recipes-kernel/linux/

For example: linux-yocto.bb or a vendor-specific kernel recipe.

In our coffee machine story: This is like finding the original recipe for your coffeeโ€”what beans, water temperature, and milk ratio are used.

2. Create Your Own Layer for Customization

Never edit Yoctoโ€™s default files directly. Instead, create a new layer (example: meta-coffee-kernel). This keeps your changes clean and separate.

Just like in real life: Instead of spoiling the companyโ€™s recipe book, you make your own recipe notes in a new diary.

3. Use a .bbappend File

To modify the kernel, create a .bbappend file that matches the original kernel recipeโ€™s name.
Example:

linux-yocto_%.bbappend

Here you can add patches, extra configurations, or point to a different kernel source.

Think of it like adding your own twist to the coffee recipeโ€”extra chocolate powder or almond milkโ€”without rewriting the whole recipe.

4. Add Kernel Configuration Changes

Yocto allows kernel configs using fragments. You can create a file like myconfig.cfg:

CONFIG_SPI=y
CONFIG_I2C=y
CONFIG_USB_SERIAL=m

Then reference it in your .bbappend.

In the coffee machine: This is like saying, โ€œAlways enable the steam nozzle, but make milk frother optional.โ€

5. Apply Kernel Patches (if needed)

If you want deeper customization (e.g., new driver, bug fix), you add a patch file (.patch) and tell Yocto to apply it.

Like fixing your coffee machineโ€™s button that sometimes doesnโ€™t workโ€”you solder a fix and update the design.

6. Rebuild the Kernel

Run:

bitbake linux-yocto

Yocto will fetch, patch, configure, and build the kernel.

This is like brewing the coffee with your new recipe. You test if it tastes better.

7. Deploy and Test

Flash the newly built kernel to your board or device. Boot it and check logs:

dmesg

Make sure your new features are working.

Like sipping the coffee โ˜•โ€”if itโ€™s too strong, adjust again. If perfect, enjoy .

[ 
Step 1 ] โž Find Kernel Recipe
   ๐Ÿ“‚ Location: meta/recipes-kernel/linux/
   Example: linux-yocto.bb

        |
        v

[ Step 2 ] โž Create Custom Layer
   ๐Ÿ“‚ Example: meta-coffee-kernel
   (Keep changes clean, separate from Yocto core)

        |
        v

[ Step 3 ] โž Add .bbappend File
   ๐Ÿ“ File: linux-yocto_%.bbappend
   (Extend original recipe without modifying it)

        |
        v

[ Step 4 ] โž Add Kernel Configurations
   ๐Ÿ› ๏ธ Example: myconfig.cfg
   CONFIG_SPI=y
   CONFIG_I2C=y
   CONFIG_USB_SERIAL=m

        |
        v

[ Step 5 ] โž Apply Kernel Patches (if needed)
   ๐Ÿงฉ Add .patch files for drivers, bug fixes, or features

        |
        v

[ Step 6 ] โž Rebuild Kernel
   ๐Ÿ’ป Command: bitbake linux-yocto

        |
        v

[ Step 7 ] โž Deploy & Test
   ๐Ÿ“ฑ Flash new kernel โ†’ Boot device
   ๐Ÿ” Check logs with: dmesg

Ans : Imagine youโ€™re setting up a smart home system .

  • If you want everything automated (lights turn on, coffee machine starts, doors lock), you choose a modern manager to handle all tasks โ†’ this is like systemd.
  • If you want an old-school approach where you manually start things one by one, you stick with SysVinit.

In Yocto, you can decide which init system (startup manager) your embedded device should use.

Steps to Enable or Disable systemd in Yocto

1. Add systemd to DISTRO_FEATURES

Edit your distro configuration file (e.g., local.conf or your custom distro .conf file):

To enable systemd:

DISTRO_FEATURES:append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = ""

To disable systemd (and use SysVinit instead):

DISTRO_FEATURES:remove = " systemd"
VIRTUAL-RUNTIME_init_manager = "sysvinit"
VIRTUAL-RUNTIME_initscripts = "initscripts"

2. Set the Default systemd Package in Image

When using systemd, make sure your image has the right packages:

IMAGE_INSTALL:append = " systemd systemd-analyze"

For disabling, remove systemd-related packages if they were added.

3. Rebuild Your Image

Run:

bitbake <image-name>

Example:

bitbake core-image-minimal

4. Test on Target Device

  • Boot your board/device.
  • Run:
ps -p 1 -o comm=

If it shows systemd, then systemd is enabled.
If it shows init, then SysVinit is running.

Real-Life Analogy

Think of systemd vs SysVinit as coffee brewing styles:

  • systemd = Fully automated smart coffee machine โ˜• (everything starts quickly and efficiently).
  • SysVinit = Old manual filter coffee maker ๐Ÿซ– (still works, but step by step).
    In Yocto, you decide which one your โ€œkitchenโ€ (embedded device) should use.

1. MACHINE

  • What it means:
    It tells Yocto for which hardware (board/SoC/CPU architecture) you are building the image.
  • Why it matters:
    Each board has different bootloaders, kernel configs, and device trees. The MACHINE variable ensures Yocto picks the right BSP (Board Support Package).
  • Example: MACHINE = "beaglebone-yocto" MACHINE = "qemuarm64" ๐Ÿ‘‰ If you set MACHINE="beaglebone-yocto", the image will include BeagleBone-specific kernel, bootloader, and drivers.

2. DISTRO

  • What it means:
    It defines the distribution policy โ€” i.e., the set of rules about how the image is built, what features are included, and how packages are managed.
  • Why it matters:
    Different distros can enable/disable systemd, package managers, debug tools, or optimizations.
  • Example: DISTRO = "poky" DISTRO = "nodistro" ๐Ÿ‘‰ If you use DISTRO="poky", you get the standard Poky distribution (Yoctoโ€™s reference distro). If you use nodistro, you get a very minimal build without distro-specific policies.

3. TCLIBC

  • What it means:
    It specifies which C library implementation will be used as the standard C library for the build.
  • Why it matters:
    The C library affects performance, footprint, and compatibility.
  • Options:
    • glibc โ†’ Default, full-featured, widely used
    • musl โ†’ Lightweight, fast, good for embedded
    • uclibc โ†’ Older, small footprint, but less common now
  • Example: TCLIBC = "glibc" TCLIBC = "musl" ๐Ÿ‘‰ For a resource-constrained IoT device, you might choose musl. For a general Linux system, glibc is standard.

In short:

  • MACHINE โ†’ Which hardware/board am I targeting?
  • DISTRO โ†’ What distribution rules/policies should I follow?
  • TCLIBC โ†’ Which C library will power my programs?

Real-life analogy:
Imagine you are cooking ๐Ÿ‘ฉโ€๐Ÿณ:

  • MACHINE = Which kitchen are you cooking in? (big restaurant kitchen vs. small home kitchen)
  • DISTRO = Which recipe book are you following? (Indian, Italian, or minimal diet plan)
  • TCLIBC = Which cooking oil are you using? (butter = full flavor, olive oil = light, coconut oil = minimal)

Where MACHINE, DISTRO, and TCLIBC are set

MACHINE

  • Where it is set:
    • Usually in your conf/local.conf file (in the build/conf/ directory).
    • Machine-specific details (bootloader, kernel, device tree) live inside meta-<board>/conf/machine/<machine>.conf.
  • Example (local.conf): MACHINE ?= "beaglebone-yocto"
  • Machine config file (beaglebone-yocto.conf): require conf/machine/include/tune-arm926ejs.inc UBOOT_MACHINE = "am335x_boneblack_config" KERNEL_DEVICETREE = "am335x-boneblack.dtb" -> This tells Yocto to use BeagleBoneโ€™s bootloader and kernel device tree.

DISTRO

  • Where it is set:
    • In conf/local.conf (to pick which distribution you want).
    • The actual distro configuration file is inside meta-poky/conf/distro/poky.conf (if youโ€™re using Poky).
  • Example (local.conf): DISTRO ?= "poky"
  • Distro config file (poky.conf): DISTRO_NAME = "Poky (Yocto Project Reference Distro)" DISTRO_VERSION = "4.0" INIT_MANAGER = "systemd" PACKAGE_CLASSES ?= "package_rpm" -> Here Yocto decides: use systemd as init, RPM as package format, etc.

TCLIBC

In short:

  • MACHINE โ†’ Set in local.conf, details in machine/*.conf.
  • DISTRO โ†’ Set in local.conf, rules defined in distro/*.conf.
  • TCLIBC โ†’ Set in local.conf, C library recipes chosen accordingly.

Real-life story:
Imagine youโ€™re running a food delivery kitchen:

  • MACHINE = Which branch kitchen you are cooking from (Delhi branch vs. Bangalore branch).
  • DISTRO = Which menu card you follow (North Indian thali, Italian pasta, or a custom diet menu).
  • TCLIBC = Which cooking base you use (butter, olive oil, or ghee).

All three work together so the customer (your embedded device) gets the right dish (final Linux image).

Ans: When we build an operating system image with Yocto, the root filesystem (rootfs) contains all the programs, libraries, and files that your device will use.
But in embedded devices (like routers, IoT boards, or automotive systems), storage is very limited. So, we must make the rootfs as small as possible.

Simple Ways to Minimize Yocto Rootfs

Use a Smaller Base Distribution

  • Instead of using the full poky (which is like a big buffet meal), you can use poky-tiny, which only gives you the essentials.
    This way, your system only gets what it really needs to run, nothing extra.

Remove Extra Tools and Debug Packages

  • By default, Yocto may add tools for debugging, profiling, or package management.
  • If your device doesnโ€™t need them, remove them.
    Itโ€™s like packing your travel bag โ€” if youโ€™re going on a weekend trip, you donโ€™t need to carry an iron, a heavy coat, or five pairs of shoes. Just take whatโ€™s necessary.

Use BusyBox Instead of Full Utilities

  • BusyBox is like a Swiss Army knife: it combines many small tools (like ls, cp, rm) into one lightweight binary.
  • This drastically cuts down size.
    Imagine instead of carrying 10 different kitchen tools (spoon, knife, peeler, corkscrew, openerโ€ฆ), you just carry a single Swiss knife that does all the jobs.

Choose a Lightweight C Library (musl)

  • Most Linux systems use glibc, but itโ€™s heavy.
  • For small embedded devices, musl is a better option.
    Itโ€™s like choosing a lightweight sports bike instead of a heavy truck when you only need to move around the city.

Strip Debug Information

  • Programs often include debugging details, which are helpful for developers but unnecessary on the final device.
  • Removing this information saves space.
    Itโ€™s like buying new clothes โ€” you donโ€™t keep the price tags and extra packaging, you throw them away before wearing them.

Disable Package Manager (if you donโ€™t need updates)

  • Package managers like RPM or opkg allow you to install new software later, but they also take up space.
  • If your device has a fixed purpose (like showing weather data on a screen), you donโ€™t need a package manager.
    Itโ€™s like a set-top box โ€” you donโ€™t install apps on it every day, so why keep that extra overhead?

Compress the Filesystem

  • Use compressed filesystems like squashfs to shrink the final image size.
    This is like vacuum-packing clothes before a trip โ€” same items, but taking up half the space.

Real-Life Application

Imagine youโ€™re designing a smart home temperature monitor with an ESP32 or BeagleBone:

  • You only need:
    • A Linux kernel
    • Drivers for Wi-Fi and sensors
    • A small web server
    • A few basic commands

You donโ€™t need:

  • Big GUI libraries
  • Multimedia tools
  • Heavy debugging utilities

By following the above tricks:

  • Your rootfs might shrink from 200 MB โ†’ 20 MB.
  • That means it fits easily into the deviceโ€™s flash memory, and your product becomes faster and cheaper to produce.

In short:

  • Pick the smallest base (like poky-tiny).
  • Use BusyBox + musl.
  • Remove extras and strip binaries.
  • Compress the filesystem.

Your embedded device then becomes like a minimal backpack for a short trip โ€” small, light, and only carrying what you need.

# ================================
# Yocto Minimal RootFS Configuration
# ================================

# 1. Select target machine (board/SoC)
MACHINE ?= "beaglebone-yocto"

# 2. Use a small distribution
DISTRO ?= "poky-tiny"

# 3. Use lightweight C library
TCLIBC ?= "musl"

# 4. Keep only minimal image features
IMAGE_FEATURES = "splash"
EXTRA_IMAGE_FEATURES = ""

# 5. Remove unnecessary tools (debug, profiling, package management)
IMAGE_FEATURES_remove = "tools-debug tools-profile package-management"

# 6. Prefer BusyBox over full GNU utilities
PREFERRED_PROVIDER_virtual/ps = "busybox"
PREFERRED_PROVIDER_virtual/init = "busybox"

# 7. Strip debug symbols to reduce binary size
INHERIT += "rm_work"
IMAGE_GEN_DEBUGFS = "0"

# 8. Choose smaller package format (ipk is usually lighter than rpm/deb)
PACKAGE_CLASSES ?= "package_ipk"

# 9. Add compressed root filesystem type
IMAGE_FSTYPES += "squashfs"

# 10. Set default image to a minimal base image
CORE_IMAGE_EXTRA_INSTALL = ""

What This Does in Real Life

Imagine you are making a smart home gateway (like a Wi-Fi hub for IoT devices).

  • โœ… poky-tiny + musl = minimal Linux base โ†’ fits into 16 MB flash.
  • โœ… busybox = one tool instead of many โ†’ reduces space.
  • โœ… rm_work = removes developer leftovers โ†’ smaller binaries.
  • โœ… squashfs = compresses everything โ†’ like vacuum-packing your OS.
  • โœ… No package manager โ†’ your device is locked, stable, and light.

So, instead of a 200 MB rootfs, you might end up with 20โ€“30 MB, which makes a huge difference for cost and performance in embedded systems.

Normal Yocto vs. Minimal Yocto RootFS

Feature / SettingNormal Yocto (poky + glibc)Minimal Yocto (poky-tiny + musl + tweaks)
RootFS Size~150โ€“250 MB~20โ€“40 MB
C Library (TCLIBC)glibc (full-featured, heavy)musl (lightweight, small footprint)
UtilitiesGNU Coreutils (separate tools)busybox (single binary, multiple tools)
Distro Policy (DISTRO)poky (default, rich features)poky-tiny (minimal policy)
Debug ToolsIncluded (gdb, profiling)Removed (IMAGE_FEATURES_remove)
Package ManagementEnabled (rpm, opkg, deb)Disabled โ†’ fixed image, smaller footprint
Filesystem CompressionUsually ext4squashfs / compressed ext4
Image Featuresssh-server, debug-tweaks, dev-pkgsOnly splash (or nothing extra)
Boot TimeLonger (more services)Faster (minimal services)
Use CaseDevelopment boards, rich OSIoT devices, gateways, automotive ECUs

Real-Life Analogy

  • Normal Yocto rootfs = A full suitcase for a month-long vacation. It has everything โ€” clothes, extra shoes, books, and gadgets.
  • Minimal Yocto rootfs = A backpack for a weekend trip. Only the essentials โ€” a pair of clothes, toothbrush, and a wallet.

The backpack is lighter, faster to carry, and easier to fit in tight spaces, just like a minimal rootfs fits into tiny embedded storage.

Master Yocto Interview Questions (2025) SET #2
Master Yocto Interview Questions (2025) SET #2

Leave a Reply

Your email address will not be published. Required fields are marked *