Build Yocto Project Step By Step¶

Yocto Project Build For Linux

1. Requirements [All The OS ]

You should be familiar with the Yocto tools and the concept of recipes. For more information, see Yocto Project documentation.

Please make sure your host PC is running Ubuntu 18.04/20.04 64-bit and install the following packages:

$ sudo apt-get install gawk wget git 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

$ sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev \
sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \
help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \
mercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils pv \
libncurses5 libncurses5-dev libncursesw5-dev libelf-dev zlib1g-dev bc rename \
git-core p7zip g++-multilib xterm gperf bison

which git-lfs > /dev/null || sudo apt-get install git-lfs || \
  (curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash &&
  sudo apt-get install git-lfs)

The Build Host Packages

Required build host packages vary depending on your build machine and what you want to do with the Yocto Project. For example, if you want to build an image that can run on QEMU in graphical mode (a minimal, basic build requirement), then the build host package requirements are different than if you want to build an image on a headless system or build out the Yocto Project documentation set.

Collectively, the number of required packages is large if you want to be able to cover all cases.

Note

In general, you need to have root access and then install the required packages. Thus, the commands in the following section may or may not work depending on whether or not your Linux distribution has sudo installed.

The following list shows the required packages needed to build an image that runs on QEMU in graphical mode (e.g. essential plus graphics support). For lists of required packages for other scenarios, see the "Required Packages for the Host Development System" section in the Yocto Project Reference Manual.

  • Ubuntu and Debian

         $ 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
                                
  • Fedora

         $ sudo dnf install gawk make wget tar bzip2 gzip python3 unzip perl patch \
         diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \
         ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue perl-bignum socat \
         python3-pexpect findutils which file cpio python python3-pip xz SDL-devel xterm
                                
  • OpenSUSE

         $ sudo zypper install python gcc gcc-c++ git chrpath make wget python-xml \
         diffstat makeinfo python-curses patch socat python3 python3-curses tar python3-pip \
         python3-pexpect xz which libSDL-devel xterm
                                
  • CentOS

         $ sudo yum install -y epel-release
         $ sudo yum makecache
         $ sudo yum install gawk make wget tar bzip2 gzip python unzip perl patch \
         diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath socat \
         perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python34-pip xz \
         which SDL-devel xterm
                                

    Notes

    • Extra Packages for Enterprise Linux (i.e. epel-release) is a collection of packages from Fedora built on RHEL/CentOS for easy installation of packages not included in enterprise Linux by default. You need to install these packages separately.

    • The makecache command consumes additional Metadata from epel-release.

Once you complete the setup instructions for your machine, you need to get a copy of the poky repository on your build host. Continue with the "Yocto Project Release" section.

Download or Clone the Poky Repo.

Yocto Project Release

Now that your build host has the right packages (native Linux machine) or you have the Poky container set up (CROPS), you need to get a copy of the Yocto Project. It is recommended that you get the latest Yocto Project release by setting up (cloning in Git terms) a local copy of the poky Git repository on your build host and then checking out the latest release. Doing so allows you to easily update to newer Yocto Project releases as well as contribute back to the Yocto Project.

Here is an example from a native Linux machine that is running Ubuntu.

Note

If your build host is using a Poky container, you can use the same Git commands.

The following example clones the poky repository and then checks out the latest Yocto Project Release by tag (i.e. yocto-2.4.2):

     $ git clone git://git.yoctoproject.org/poky
     Cloning into 'poky'...
     remote: Counting objects: 361782, done.
     remote: Compressing objects: 100% (87100/87100), done.
     remote: Total 361782 (delta 268619), reused 361439 (delta 268277)
     Receiving objects: 100% (361782/361782), 131.94 MiB | 6.88 MiB/s, done.
     Resolving deltas: 100% (268619/268619), done.
     Checking connectivity... done.
     $ git checkout tags/yocto-2.4.2 -b poky_2.4.2
                

The previous Git checkout command creates a local branch named poky_2.4.2. The files available to you in that branch exactly match the repository's files in the rocko development branch at the time of the Yocto Project 2.4.2 release.

Note

Rather than checking out the entire development branch of a release (i.e. the tip), which could be continuously changing while you are doing your development, you would check out a branch based on a release tag as shown in the previous example. Doing so provides you with an unchanging, stable set of files.

For more options and information about accessing Yocto Project related repositories, see the "Working With Yocto Project Source Files" section in the Yocto Project Development Tasks Manual.

Note : you can also check current release version of yocto project after cloning ..

    $ git clone git://git.yoctoproject.org/poky
     Cloning into 'poky'...
     remote: Counting objects: 361782, done.
     remote: Compressing objects: 100% (87100/87100), done.
     remote: Total 361782 (delta 268619), reused 361439 (delta 268277)
     Receiving objects: 100% (361782/361782), 131.94 MiB | 6.88 MiB/s, done.
     Resolving deltas: 100% (268619/268619), done.
     Checking connectivity... done.
     
     
     
    cd poky
    git checkout yocto-3.1.14 # or just press Tab button after git checkout yocto-
    #you can found latest release of yocto project ...

Building Images

go to current directory of poky

add the environment variable

source poky/oe-init-build-env

git checkout yocto-3.1.14
#go to current directory of poky 
#add the environment variable 
cd ..
source poky/oe-init-build-env
# compile your source code ...
time bitbake core-image-minimal # core-image-minimal just minimum configuration
#in yocto project ..

Run image of yocto project..

After compile successfully you can find the image

../build/tmp/deploy/images/qemux86-64/

qemux86-64 this is default device image you can also set /build/conf/local.conf

file...

MACHINE ??="qemux86-64"

then save and recompile ..

Run The Image

# run the final image 
#runqemu <image-name> nographic
runqemu qemux86-64 nographics 
#booting process started 
#type the password root.
# Now your minimal image working..

Last updated