Yocto Project Introduction

Building Embedded Linux system is a complex task, you need to choose a toolchain, configure and build bootloader, kernel, file system and applications. It becomes more complex to maintain the process over more many products.

To build a system, you can use some tools like buildroot, crosstool, busybox and more

Yocto project helps to solve the problem

downloading the sources:

# git clone http://git.yoctoproject.org/git/poky

Setup

# cd poky
# source ./oe-init-build-env
# bitbake core-image-minimal

Test your system

# runqemu qemux86

 

Configuring the kernel

# bitbake -c menuconfig virtual/kernel
# bitbake virtual/kernel

 

Building Packages

To see a list of available tasks for recipe run:

# bitbake -c listtasks virtual/kernel

 

Adding a new packages to the images

Edit the poky/build/conf/local.conf and add the following:

IMAGE_INSTALL_append = " dropbear python"

 

To see the available packages run:

# bitbake -s

 

Creating a new recipe

 

Create a new directory in /meta/recipes-extended

 

Add files folder and put source file hello.c in that folder

 

Create a file hello_1.0.bb with the following content

 

DESCRIPTION = "Hello world program"
HOMEPAGE = "http://example.net/helloworld/"
PRIORITY = "optional"
SECTION = "examples"
LICENSE = "GPLv2"
SRC_URI = "file://hello.c"


LIC_FILES_CHKSUM = \
  "file://hello.c;md5=a36bbae7c27df6a9531031eda450cbd7"

do_compile() {
    ${CC} ${CFLAGS} ${LDFLAGS} -o hello ${WORKDIR}/hello.c
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 hello ${D}${bindir}
}

 

To see the available images run:

# find ./meta*/recipes*/images -name "*.bb"

 

create a standalone toolchain

# bitbake meta-toolchain

 

after the build is finished find it in [build dir]/tmp/deploy/sdk

run the script: poky-glibc-x86_64-meta-toolchain-aarch64-toolchain-2.3.sh to install the toolchain