Yocto — getting started

Pranav Thakkar
4 min readMay 19, 2021

Well, You may be well-doing with the official documents which are very best for every update if you are reading this post ahead of time. But this is for a demo project where I’m doing a direct demo and give some information about it.

My purpose for yocto is to develop a lightweight Operation System where I can install my Software in a predefined way.

So I come across at Yocto and in the beginning, first, it was all bounce out of my head because I’m not from a background of core embedded development. I design an architecture for the Industrial Internet of Things from edge devices to the cloud. so yes If I’m doing that. You can.. (Little motivation :) )

So Let’s get Started. By defining some concepts.

poky: which is reference distribution. on top of poky, you are building your OS.

bitbake: which is a scheduler, For my understanding It Executed tasks that have been requested.

So for these two things, you have to keep first in mind to work in Yocto. also for non-programmer or wanted GUI for programmers (like Me) Yocto has that thing for you. Which is called a TOASTER. which is amazing.

also, there are recipes and layers. which I will explain with an example later.

Getting started with Yocto, You need to have at least this system requirement which is documented. If you are using Ubuntu in VM. you might end up with more build time which will be 8–10 hours for a simple image(only the first time). So Native Desktop will be a good choice for building the OS.

So let’s start the coding part.

On Ubuntu install pre-requisite.

build this package

sudo apt-get install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev

clone poky

git clone git://git.yoctoproject.org/poky

check out with the latest branch or old one

cd poky
git checkout -t origin/hardknott -b my-hardknott

Now Let’s Build an Image for Raspberry Pi 3 (64 bit)

for that, we need to get its layer. So layer is one kind of image which have code for your hardware. so if you develop your OS in terms of LAYER (one layer at top of the other) it will be good why because if want to remove you can remove the individual layer easily without modification of the layer. and ALSO never build your image on only ONE Layer where all layers come to one. put it differently.

So for our board, we need to download the layer from yocto index. HERE

git clone git://git.yoctoproject.org/meta-raspberrypi

so if you see in this meta-layer meta-raspberry pi. It has poky and open embedded dependency so we already have poky now we need open embedded.

git clone https://git.openembedded.org/meta-openembedded

Done. Our basic requirement for Raspberry is fullfilment. now let’s move to initialize our environment inside the poky.

cd poky
source oe-init-build-env rpi_build # whatever you want to name

conf sub directory of rpi_build directory we will find two files bblayer.conf and local.conf.

so lets edit them,

cd rpi_build/conf
nano bblayer.conf
bblayer.conf

and for local. conf where we give our machine name (raspberrypi 3)

nano local.conf#change machine to
MACHINE ?= "raspberrypi3"

now all done. It’s time to build our image which will take two hours or longer.

so for making final image there are many recipes available to build your image.

here is the list

Source yocto for raspberry pi book

So we can build this type of image as per our requirements. and there are many more to them

So finally you add this command to bake your image for you.

bitbake core-image-base 

and get your coffee or book to utilize this time.

Congratulation! Your cake is ready. I mean your bake is ready. now install it on raspberry pi.

You will find your image in rpi_build/tmp/deploy/images/raspberrypi/*wic.bz2

  • note that .sdimg is renowned to wic.bz2

So now flash the sd card with that image.

So this is the First step to build an image for raspberry pi. Now next add the software recipes that you want to include in your OS. so that they can be produced and rebuild the image.

Thanks, the next article I will be showing with other software recipes with Toaster. Please share your review of how you doing with it. it will help both of us. as yocto’s tutorials are very less.

--

--

Pranav Thakkar

IIoT4.0, Data Analytics Love to collaborate with open source projects