How to install BitBake on Ubuntu and how to use it?
In this tutorial we are going to show you how to install BitBake on Ubuntu and dive into some details about it and also teach you some of the commands, or at least some basic commands to be precise.
It manages the entire build process, from fetching source code to configuring, compiling, and assembling the final system image. Pretty neat isn’t it?
So what is BitBake in simple terms?
Imagine you’re cooking a complex dish with many ingredients.
Each ingredient needs to be prepared in a specific way before combining them all to make the final dish. BitBake is like a smart chef in the world of software development.
Instead of cooking, it helps developers build customized software for specialized devices, like a smart thermostat or a digital camera.
Essentially, with BitBake you can make customized OS for specific usages.
This customized OS includes not only the core components like the Linux kernel but also the applications, libraries, and configurations needed for the device to function in a specialized way.
Here’s how BitBake works:
- Recipe Collection:
- BitBake follows recipes, just like a chef follows a cooking recipe. In software, a recipe is a set of instructions that tells BitBake how to fetch the source code, configure the software, compile it, and package it.
- Fetching Ingredients (Source Code):
- BitBake goes to the internet or a specific source to fetch the raw ingredients—the source code for the software you want to build.
- Preparation (Configuration):
- Next, BitBake prepares the ingredients by configuring the software. It decides how the software should behave on the specific device you’re building for.
- Cooking (Compilation):
- Now comes the cooking part. BitBake compiles the source code, turning it into a form that the device can understand and use.
- Plating (Assembling the System Image):
- Finally, BitBake assembles all the cooked components into a final dish—the system image. This is what gets installed on the embedded device, making it work as intended.
- Cleanup (Cleaning):
- Sometimes, you want to start over. BitBake can also clean up the kitchen by removing all the intermediate files and starting fresh.
In a nutshell, BitBake is like a specialized chef for building software.
It takes care of the entire process, from gathering ingredients to cooking and serving a customized software meal for your embedded device.
How to install BitBake on Ubuntu?
If you tried to use Bitbake and got “bitbake command not found” its probably because its either not installed at all, or not installed properly.
BitBake requires a lot of dependencies to work properly, but by following these steps, you should be able to install it quickly and get it up and running.
Like always, let’s first update the packages.
sudo apt update -y
Now we have to install some dependencies. This command is pretty big, and it was tested by us on Ubuntu 22.04, but it should work on Ubuntu 20.04 as well.
Make sure to copy and paste all of it.
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ build-essential chrpath socat cpio python2 python3 python3-pip python3-pexpect \ xz-utils debianutils iputils-ping libsdl1.2-dev xterm liblz4-tool
It may take few minutes since there is a lot of packages that need to be installed.
Now after that is done, since BitBake is a part of Yocto Project Repository, we will clone it like this.
git clone https://github.com/yoctoproject/poky
Now go into new directory “poky“.
And run this.
After building is done, let’s check if BitBake is installed by running this command.
Yeap, we did it!
How to use BitBake?
Unfortunately we can’t show you all of it. In order to properly use BitBake, you should learn more about it in their documentation.
We will list some basic commands that we think you should know, but unless you are already familiar with BitBake, they will hardly be useful to you.
We highly encourage you to go through this official documentation.
This is the basic command to build a specific recipe. Replace <recipe> with the name of the recipe you want to build.
bitbake -c clean <recipe>
This command cleans the build artifacts for a specific recipe. It removes temporary files and built binaries.
bitbake -c fetch <recipe>
This command fetches the source code for a specific recipe.
bitbake -c configure <recipe>
This one configures the build for a specific recipe.
bitbake -c compile <recipe>
This will compile the source code for a specific recipe.
bitbake -c deploy <recipe>
This command deploys the built artifacts to the target system or creates a package.
bitbake -k <recipe>
This command continues with the build even if there are failures in some tasks.
bitbake -e <recipe>
This command displays the environment variables and their values for a specific recipe.
This command shows available recipes.
And this one shows the layers in the current configuration.
Conclusion – BitBake is a “bit” harder to install than your usual Linux software
But it’s worth it and you did it!
And by following these easy steps, everything should be working now the way its supposed to. We hope that this article has helped you to install BitBake on your system and we hope you will have fun with it.
Have any questions? Feel free to reach out to us!