- Learning Embedded Linux Using the Yocto Project
- Alexandru Vaduva
- 1085字
- 2021-07-16 13:49:32
The Yocto Project reference
As I have mentioned, the major advantage and available feature of the Yocto Project environment is represented by the fact that a Yocto Project build does not use the host available packages, but builds and uses its own packages. This is done to make sure that a change in the host environment does not influence its available packages and that builds are made to generate a custom Linux system. A toolchain is one of the components because almost all packages that are constituents of a Linux distribution need the usage of toolchain components.
The first step for the Yocto Project is to identify the exact sources and packages that will be combined to generate the toolchain that will be used by later built packages, such as U-Boot bootloader, kernel, BusyBox and others. In this book, the sources that will be discussed are the ones available inside the dizzy branch, the latest poky 12.0 version, and the Yocto Project version 1.7. The sources can be gathered using the following command:
git clone -b dizzy http://git.yoctoproject.org/git/poky
Gathering the sources and investigating the source code, we identified a part of the packages mentioned and presented in the preceding headings, as shown here:
cd poky find ./ -name "gcc" ./meta/recipes-devtools/gcc find ./ -name "binutils" ./meta/recipes-devtools/binutils ./meta/recipes-devtools/binutils/binutils find ./ -name "glibc" ./meta/recipes-core/glibc ./meta/recipes-core/glibc/glibc $ find ./ -name "uclibc" ./meta-yocto-bsp/recipes-core/uclibc ./meta-yocto-bsp/recipes-core/uclibc/uclibc ./meta/recipes-core/uclibc
The GNU CC and GCC C compiler package, which consists of all the preceding packages, is split into multiple fractions, each one with its purpose. This is mainly because each one has its purpose and is used with different scopes, such as sdk
components. However, as I mentioned in the introduction of this chapter, there are multiple toolchain build procedures that need to be assured and automated with the same source code. The available support inside Yocto is for gcc 4.8 and 4.9 versions. A quick look at the gcc
available recipes shows the available information:
meta/recipes-devtools/gcc/ ├── gcc-4.8 ├── gcc_4.8.bb ├── gcc-4.8.inc ├── gcc-4.9 ├── gcc_4.9.bb ├── gcc-4.9.inc ├── gcc-common.inc ├── gcc-configure-common.inc ├── gcc-cross_4.8.bb ├── gcc-cross_4.9.bb ├── gcc-cross-canadian_4.8.bb ├── gcc-cross-canadian_4.9.bb ├── gcc-cross-canadian.inc ├── gcc-cross.inc ├── gcc-cross-initial_4.8.bb ├── gcc-cross-initial_4.9.bb ├── gcc-cross-initial.inc ├── gcc-crosssdk_4.8.bb ├── gcc-crosssdk_4.9.bb ├── gcc-crosssdk.inc ├── gcc-crosssdk-initial_4.8.bb ├── gcc-crosssdk-initial_4.9.bb ├── gcc-crosssdk-initial.inc ├── gcc-multilib-config.inc ├── gcc-runtime_4.8.bb ├── gcc-runtime_4.9.bb ├── gcc-runtime.inc ├── gcc-target.inc ├── libgcc_4.8.bb ├── libgcc_4.9.bb ├── libgcc-common.inc ├── libgcc.inc ├── libgcc-initial_4.8.bb ├── libgcc-initial_4.9.bb ├── libgcc-initial.inc ├── libgfortran_4.8.bb ├── libgfortran_4.9.bb └── libgfortran.inc
The GNU Binutils package represents the binary tools collection, such as GNU Linker, GNU Assembler, addr2line
, ar
, nm
, objcopy
, objdump
, and other tools and related libraries. The Yocto Project offers support for the Binutils version 2.24, and is also dependent on the available toolchain build procedures, as it can be viewed from the inspection of the source code:
meta/recipes-devtools/binutils/ ├── binutils ├── binutils_2.24.bb ├── binutils-2.24.inc ├── binutils-cross_2.24.bb ├── binutils-cross-canadian_2.24.bb ├── binutils-cross-canadian.inc ├── binutils-cross.inc ├── binutils-crosssdk_2.24.bb └── binutils.inc
The last components is represented by C libraries that are present as components inside the Poky dizzy branch. There are two C libraries available that can be used by developers. The first one is represented by the GNU C library, also known as glibc
, which is the most used C library in Linux systems. The sources for glibc
package can be viewed here:
meta/recipes-core/glibc/ ├── cross-localedef-native ├── cross-localedef-native_2.20.bb ├── glibc ├── glibc_2.20.bb ├── glibc-collateral.inc ├── glibc-common.inc ├── glibc.inc ├── glibc-initial_2.20.bb ├── glibc-initial.inc ├── glibc-ld.inc ├── glibc-locale_2.20.bb ├── glibc-locale.inc ├── glibc-mtrace_2.20.bb ├── glibc-mtrace.inc ├── glibc-options.inc ├── glibc-package.inc ├── glibc-scripts_2.20.bb ├── glibc-scripts.inc ├── glibc-testing.inc ├── ldconfig-native-2.12.1 ├── ldconfig-native_2.12.1.bb └── site_config
From these sources, the same location also includes tools, such as ldconfig
, a standalone native dynamic linker for runtime dependencies and a binding and cross locale generation tool. In the other C library, called uClibc
, as previously mentioned, a library designed for embedded systems has fewer recipes, as it can be viewed from the Poky source code:
meta/recipes-core/uclibc/ ├── site_config ├── uclibc-config.inc ├── uclibc-git ├── uclibc_git.bb ├── uclibc-git.inc ├── uclibc.inc ├── uclibc-initial_git.bb └── uclibc-package.inc
The uClibc is used as an alternative to glibc
C library because it generates smaller executable footprints. At the same time, uClibc
is the only package from the ones presented in the preceding list that has a bbappend
applied to it, since it extends the support for two machines, genericx86-64
and genericx86
. The change between glibc
and uClibc
can be done by changing the TCLIBC
variable to the corresponding variable in this way: TCLIBC = "uclibc"
.
As mentioned previously, the toolchain generation process for the Yocto Project is simpler. It is the first task that is executed before any recipe is built using the Yocto Project. To generate the cross-toolchain inside using Bitbake, first, the bitbake meta-ide-support
task is executed. The task can be executed for the qemuarm
architecture, for example, but it can, of course, be generated in a similar method for any given hardware architecture. After the task finishes the execution process, the toolchain is generated and it populates the build directory. It can be used after this by sourcing the environment-setup
script available in the tmp
directory:
cd poky source oe-init-build-env ../build-test
Set the MACHINE
variable to the value qemuarm
accordingly inside the conf/local.conf
file:
bitbake meta-ide-support source tmp/environment-setup
The default C library used for the generation of the toolchain is glibc
, but it can be changed according to the developer's need. As seen from the presentation in the previous section, the toolchain generation process inside the Yocto Project is very simple and straightforward. It also avoids all the trouble and problems involved in the manual toolchain generation process, making it very easy to reconfigure also.
- 計(jì)算思維與算法入門(mén)
- Fundamentals of Linux
- Getting Started with ResearchKit
- JSP開(kāi)發(fā)案例教程
- JavaScript by Example
- Java EE 7 Development with NetBeans 8
- Python編程:從入門(mén)到實(shí)踐
- D3.js 4.x Data Visualization(Third Edition)
- Jupyter數(shù)據(jù)科學(xué)實(shí)戰(zhàn)
- Machine Learning in Java
- 軟件測(cè)試綜合技術(shù)
- UML2面向?qū)ο蠓治雠c設(shè)計(jì)(第2版)
- PyQt編程快速上手
- INSTANT Apache Hive Essentials How-to
- PHP Microservices