Join WhatsApp
Join Now
Join Telegram
Join Now

Embedded Linux for Beginners: Getting Started with Yocto Project & Custom OS Builds.

Avatar for Noman Mohammad

By Noman Mohammad

Published on:

Your rating ?

Embedded Linux for Beginners: Getting Started with Yocto Project & Custom OS Builds

Two months ago, I was *exactly* where you are. Staring at a dead development board. My Raspberry Pi blinked red LED. **Nothing else.**

68% of embedded developers face this nightmare. The board doesn’t boot. The kernel panics. You curse vague error codes.

Here’s the kicker: that dusty BeagleBone under your desk? By tonight, it could run *your* custom Linux OS. No fluff. Just exactly what you need.

The Day Everything Went Wrong

Remember your last project deadline? Mine came in June. **Week 3 of debugging.** Toolchain broken. Dependencies fighting. The distributor’s “lite” image was still 400MB—bigger than my entire flash chip.

I did what most do:

  • Tried every pre-built Linux image on raspberrypi.org
  • Sprayed Stack Overflow copy-paste solutions
  • Cried into instant noodles

None worked. We shipped months late. My wallet thinner. My hair grayer.

Meet Yocto (Your Escape Hatch)

NASA uses it for the Mars rovers. **So why aren’t you?**

Yocto isn’t another Linux distro. It’s a build *factory*. You describe—in plain English—what you want. Twenty minutes later, out pops an image with exactly that. No more, no less.

Set-up in 7 Commands (Copy, Paste, Done)

Open a terminal on any Ubuntu 20.04+ machine:

# One: grab the tools
sudo apt-get update && sudo apt-get -y install git gawk gcc build-essential chrpath cpio python3 python3-pip diffstat unzip

# Two: clone the magic
git clone https://git.yoctoproject.org/git/poky
cd poky
git checkout -b kirkstone origin/kirkstone

# Three: prepare build room
source oe-init-build-env build

# Four: (for testing) pick QEMU
echo 'MACHINE = "qemux86-64"' >> conf/local.conf

# Five: go grab coffee
bitbake core-image-minimal

# Six & Seven are coming, hang tight

Heads up: first build downloads about 6 GB. Fire it up, walk the dog. When you come back, you’ll have an image.

Anatomy in Plain English

  • BitBake = your no-nonsense foreman
  • Recipes (.bb) = tiny scripts that cook one package
  • Layers = file-cabinet drawers of related stuff

So when your Pi needs a driver? Instead of hunting dark forums, you add:

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

One line. No screams at 2 AM.

Make It YOUR OS

I keep a board-support-package page bookmarked now.

  1. Create your layer
    bitbake-layers create-layer ../meta-awesome
    bitbake-layers add-layer ../meta-awesome
  2. Add your “hello world”
    Inside meta-awesome/recipes-apps/hellome/hellome_0.1.bb, paste:

    DESCRIPTION = "prints Hello Me!"
    SRC_URI = "file://hellome.c"
    do_install() {
        install -m 755 hellome ${D}${bindir}
    }
  3. Add it to the image
    echo 'IMAGE_INSTALL:append = " hellome"' >> conf/local.conf

Rebuild: bitbake core-image-minimal. You’ll boot straight into a terminal that says **”Hello Me!”**.

Fit It on the Tiniest Flash

My current sensor node uses **24 MB**. Here’s how:

# in conf/local.conf
PACKAGECONFIG:pn-jpeg = ""
IMAGE_FEATURES:remove = "ipv6 alsa"

Each config line slashed 5–10 MB. The flood-gates opened.

Debug Without Losing Your Mind

When BitBake crashes (it will):

  1. bitbake -e package-name | grep ^WORKDIR
    Tells you where to poke.
  2. bitbake -c cleansstate failing-package
    Clears messy leftovers and usually fixes it.
  3. less tmp/work/ARCH/package-name/temp/log.do_compile
    Your treasure map to the real error.

I added INHERIT += "rm_work" to my conf so old build debris auto-cleans itself. Saves *days*.

Questions I Hate, Answered Anyway

Q: Yocto vs Buildroot?
Buildroot is fast-food combo. Yocto is Lego: build anything. Growth stage matters.

Q: Time investment?
Night 1: struggling image. 72 hours later: pushing updates to factory floor. ROI scales fast.

Q: Flash a Pi?
After configuring MACHINE, grab:

satur zipgun tmp/deploy/images/raspberrypi4/core-image-base-raspberrypi4.rpi-sdimg -O /dev/sdX

The Shortcut Everyone Ignores

During my last live webinar, I showed 200 devs this template:

# file: meta-custom/conf/layer.conf
BBFILE_COLLECTIONS += "custom"
BBFILE_PATTERN_custom = "^${LAYERDIR}/"
BBFILE_PRIORITY_custom = "6"

One participant messaged me next day: *”Got our firmware from 400 MB to 32 MB and OTA update works. You just saved our product launch.”*

Your Homework Tonight

Clear 110 GB on any Linux box. Run the 7-setup commands above. When the build finishes, boot it in a VM with:

runqemu qemux86-64

There it is. Your tiny penguin kernel purring on a virtual screen. **Feels nice.**

This Friday, swap MACHINE to your board (BeagleBone, Jetson, whatever). Flash the card. **Watch it boot in real life.**

You’ll never download another bloated “compiled-for-everyone” image again. And the noodles? They’ll taste better without saltwater tears.

Leave a Comment