Home > Article > System Tutorial > Yocto Getting Started Tutorial: Build Your Customized Linux System on Ubuntu
If you are an embedded developer, you may encounter this question: How to create a suitable Linux system for your hardware platform? How to customize the functionality and appearance of a Linux system? How to ensure the security and stability of Linux system? These problems can be solved by using the Yocto project. The Yocto Project is an open source collaborative project that helps you create custom Linux systems regardless of your hardware architecture. The Yocto project provides a flexible set of tools and resources that allow you to build your own Linux distribution from scratch, or modify and optimize based on existing Linux distributions. This article will introduce you to how to use Yocto to create a minimal Linux distribution on Ubuntu, as well as the basic concepts and workflow of Yocto.
Minimum 4-6 GB RAM
The latest version of Ubuntu system (this article uses 16.04 LTS)
The remaining disk space is at least 60-80 GB
Install the following packages before creating a Linux distribution
Download the latest Yocto (Poky is its minimum development environment) stable branch
apt-get update apt-get install wget git-core unzip make gcc g++ build- essential subversion sed autoconf automake texi2html texinfo coreutils diffstat python- pysqlite2 docbook-utils libsdl1.2-dev libxml-parser-perl libgl1-mesa-dev libglu1-mesa- dev xsltproc desktop-file-utils chrpath groff libtool xterm gawk fop
As shown below, the software package to be installed in the development environment is nearly 1GB in size.
In this tutorial, the morty stable branch of poky is cloned on the system.
git clone -b morty git://git.yoctoproject.org/poky.git
Enter the poky directory, and then run the following command to set (set/export) some environment variables for the Yocto development environment.
source oe-init-build-env
As shown below, after running the open embedded (oe) build environment script, the path in the terminal will automatically switch to the build directory for subsequent configuration and construction of the release version.
The screenshot above shows the file local.conf created in the conf directory. This is the configuration file used by Yocto to set the target machine details and target architecture of the SDK.
As shown below, the target machine set here is qemux86-64.
As shown in the screenshot below, uncomment the following parameters in local.conf.
DL_DIR ?= "${TOPDIR}/downloads"
SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
TMPDIR ?= "${TOPDIR}/tmp"
PACKAGE_CLASSES ?= "package_rpm" SDKMACHINE ?= "i686"
As shown below, set an empty password and some subsequent parameters in local.conf for Yocto-based Linux. Otherwise, users will not be able to log in to the new release.
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
We are not planning to use any graphical tools to create Linux OS, such as toaster (hob is no longer supported).
Now run the following bitbake tool command to start downloading and compiling the software package for the selected target machine.
bitbake core-image-minimal
It is very important to run the above command under a normal Linux user and not using the root user. As shown in the screenshot below, when you run the bitbake command under the root user, the error shown below will occur.
Run the script that exports environment variables (oe-init-build-env) again, and re-execute the same command to start the download and compilation process.
As shown below, the first step in building a script component is to parse the configuration (recipe).
The screenshot below shows the parsing process of the build script. It also shows the details of the build system used to build your new yocto-based distribution.
After downloading the SDK and necessary libraries, the next step is to download and compile the software package. The screenshot below shows the tasks performed to build a new distribution. This step will take 2-3 hours as the required packages must first be downloaded and then compiled for the new Linux distribution.
The screenshot below shows the completion of the task list.
The new image compiled for the target machine type qemux86-64 is located in build/tmp/deploy/images/qemux86-64:
As shown below, the above command will generate an error if run on Putty.
Run the above command again on the Ubuntu platform via rdp.
Open a new screen for qemu running the new Yocto-based Linux distribution.
The following shows the login interface of the new release, and also displays the version number of the yocto project used. The default username is root and the password is blank.
Finally use the root username and empty password to log in to the new release. As shown in the screenshot below, basic commands (data, ifconfig, and uname) are run on this minimal version of Linux.
The goal of this article is to understand the process of creating a new Linux distribution using Yocto.
Through this article, you have learned how to use Yocto to create a minimal Linux distribution on Ubuntu, as well as the basic concepts and workflow of Yocto. You can use Yocto to customize a suitable Linux system for your embedded devices or other scenarios to meet your needs and preferences. Of course, this is only part of the many features and options provided by the Yocto project. If you want to learn more about the Yocto project and embedded Linux development, you still need to continue to explore and practice. I hope this article can be helpful to your study and work. You are also welcome to share other practical Yocto skills you use or discover.
The above is the detailed content of Yocto Getting Started Tutorial: Build Your Customized Linux System on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!