Engineering Core
ISB Vietnam's skilled software engineers deliver high-quality applications, leveraging their extensive experience in developing financial tools, business management systems, medical technology, and mobile/web platforms.

Have you heard of the Yocto Project? This article aims to introduce the concepts and guide you through the basic steps to get started with Yocto Project development.

The Yocto Project is an open-source collaboration project that provides templates, tools, and methods for creating custom Linux-based systems tailored for embedded products, regardless of the hardware architecture. It is particularly designed for resource-constrained embedded and IoT devices, optimizing the size of the operating system to only include necessary components.
 
The standout characteristics of the Yocto Project
 
  • High Customizability: Yocto Project allows you to create fully customized Linux distributions for target boards, minimizing unnecessary components and optimizing system size.
  • Wide Architecture Support: It supports a variety of architectures and hardware platforms.
  • Automation Tools: Provides templates, tools, and methods to automate the build and development process, enhancing developer productivity and efficiency.
  • Strong Community Support: Yocto Project has a vibrant community providing extensive documentation and detailed guides, facilitating quick issue resolution and maximizing the platform's potential.
Here are the basic steps to generate a Linux image for QEMU
 
Begin by installing the Yocto Project on your system. Depending on your distribution, you may need to install prerequisite packages. For example, on Ubuntu, install necessary packages:
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
Create a Working Directory: Create a new directory for your Yocto Project workspace. For example:
mkdir yocto-qemu && cd yocto-qemu
Clone Yocto Project: Clone the Yocto Project from the official repository:
git clone git://git.yoctoproject.org/poky
cd poky
Select a Distribution: Yocto Project offers various distributions (meta layers). Choose one, e.g., jethro:
git checkout jethro
Initialize Build Environment: Source the script to initialize the build environment for the selected distribution:
This command creates a build directory and sets up necessary environment variables.
source oe-init-build-env
Inside the build directory, configure Yocto Project for QEMU by editing conf/local.conf. Adjust settings such as target architecture (MACHINE), distribution, and features. For example:
 
Once configured, start the build process with below command
This command initiates building a minimal image (core-image-minimal) suitable for QEMU
bitbake core-image-minimal
After the build completes, run the built image using QEMU, For example:
runqemu qemux86-64
 
By following these steps, you have successfully built a custom Linux image using Yocto Project and executed it on QEMU. This process allows you to test and develop applications without physical embedded devices, saving time and costs in product development.
 
Now, let's create a "Hello World!" recipe and run the program after building it on QEMU
 
Use the following command to quickly create a folder for the recipe file
 
Open the bb File, you will automatically see the following content
 
Open helloworld.c file, the program content will be as simple as
 
Copy the entire example folder to the path below
 
Run the following Command to build the "Hello World!" Program
 
Rebuild QEMU image
bitbake core-image-minimal
Run QEMU
 
Verify output on QEMU
 
By following these steps, you have successfully created a simple recipe to build and run a "Hello World" program using Yocto Project. This approach empowers you to start developing and integrating custom applications into embedded systems with ease and flexibility.
 
Refer links
https://tutorialadda.com/yocto/what-is-yocto-project-poky-and-bitbake
https://www.devprojournal.com/technology-trends/internet-of-things/why-iot-system-developers-need-the-yocto-project-for-custom-linux-solutions/
https://www.yoctoproject.org/
 
External image links
Written by
Author Avatar
Engineering Core
ISB Vietnam's skilled software engineers deliver high-quality applications, leveraging their extensive experience in developing financial tools, business management systems, medical technology, and mobile/web platforms.

COMPANY PROFILE

Please check out our Company Profile.

Download

COMPANY PORTFOLIO

Explore my work!

Download

ASK ISB Vietnam ABOUT DEVELOPMENT

Let's talk about your project!

Contact US