First of all, welcome to the Embedded Linux world. In this tutorial, we will tell you how to set up make first yocto build. You don’t need any embedded linux board for this tutorial. Because we will tell you about getting started with yocto on your pc using QEMU.
So, let’s get started!
What Is Yocto Used For?
Yocto is an open-source project that can help you create customized linux for any board regardless of the hardware architecture. Yocto Documentation offers great help in customizing a linux according to your requirements and hardware. In this tutorial, we will guide you how to make your first yocto project. You don’t need any hardware or microcontroller to run your first yocto project. Instead, you can easily run it on your host machine (PC).
In the coming articles, we will tell you the advance concepts like what is a recipe in yocto, how to create a yocto recipe, what is bitbake used for etc. Stay connected with this Yocto Tutorial Pdf series to become a master in yocto in minimum time.
Pre-Requisites for Getting Started with Yocto:
Before following this getting started with yocto tutorial, make sure that you have a Linux OS on your PC or host machine. Besides, you should also ensure that you have more than 50 gb free space in your host machine. The reason is that Yocto build downloads a lot of things for setup.
If you don’t have a linux OS, you can easily make a virtual machine on your PC using the following tutorial. You can run both windows and ubuntu simultaneously on your PC using the virtual box. Make sure to give more than 50 GB space to your virtual box following the above tutorial.
First Build with Yocto:
Follow the below steps to make your first build with Yocto now!
Step 1:
You should need some packages in your host machine to run Yocto. In order to install these packages, you should run the following command in the ubuntu terminal.
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python
python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping libsdl1.2-dev xterm
Step 2:
After installing the required packages, you should clone poky. Poky is the reference distro in Yocto for embedded Linux projects. Check Yocto Poky Documentation to learn more about distors and importance of poky. To install poky, paste the following command in terminal one by one.
mkdir yocto
cd yocto
git clone git://git.yoctoproject.org/poky.git-b dunfell
Step 3:
After that, you should initialize the environment to make your first build. In order to do this, you should run the following command
source poky/oe-init-build-env
Now, you will see a new folder named as “build” in your project directory. Besides, you will also see that you are currently in the build folder in your terminal. If you open local.conf file in the you_project/build/conf folder, you will see that the default machine is qemu-x86 as shown in screenshot below. Qemu is an emulator that allow us to run embedded linux on host machines.
Step 4:
Now, its time to make our first embedded linux. Simply run the following command in your terminal. Make sure that you run the below command in the same terminal in which you run the above command. Otherwise, it will not work.
bitbake core-image-minimal
This step will take hours to complete. It will take estimate 3-4 hours depending on your internet speed and PC specifications. You can go for a lunch or coffee with your girlfriend until this step is complete. Just Kidding. This step is very time consuming so you can do other things instead of waiting for it.
Step 5:
Now, I hope you are fine and not dead while waiting for build to complete. Once your build is complete, you should run the following command to run your first embedded linux on your pc. In order to do this, run the following command
runqemu qemux86-64
It will open a new terminal for you. Here, you can see a new linux system that you have just built. Simply login to that system by typing root as the login password. Boom! You have made your first Linux system yourself. As we have made a minimal image, the new linux system won’t have any graphics. It will just be a terminal.
We hope that you like our getting started with yocto tutorial and made your first build by following this article. You can learn more about devtool in yocto here. It is one of the best tools in yocto for modifying recipes and creating patches.