Yocto Build Guidline

From WIKI SECO

Introduction

This guideline provides instructions to setup and build Yocto 1.7 for SECO boards only with SECO BSP. The guideline is not valid using the community BSP.

Host Setup

To get the Yocto Project expected behavior in a Linux Host Machine, the packages and utilities described below must be installed. An important consideration is the hard disk space required in the host machine. For example, when building on a machine running Ubuntu, the minimum hard disk space required is about 50 GB for the X11 backend. It is recommended that at least 120 GB is provided, which is enough to compile any backend.

The recommended minimum Ubuntu version is 14.04 but builds for dizzy will work on 12.04 or later. Earlier versions may cause the Yocto Project build setup to fail, because it requires python versions only available starting wtih Ubuntu 12.04. See The Yocto Project reference manual for more information.

Ubuntu Distro release Supported/Unsupported
Ubuntu Release 12.04 (precise) Supported
Ubuntu Release 14.04 (Trusty) Supported
Ubuntu Release 16.04 (Xenial) Unsupported
Ubutnu Release 18.04 (Bionic) Unsupported

Host Packages

A Freescale Yocto Project Community BSP build requires that some packages be installed for the build that are documented under the Yocto Project.

You can go to Yocto Project Quick Start and check for the packages that must be installed for your build machine.

Essential Yocto Project host packages:

$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat dialog

i.MX layers host packages for a Ubuntu 12.04 or 14.04 host setup:

$ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html \
docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils \ 
libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc

i.MX layers host packages for a Ubuntu 12.04 host setup only:

$ sudo apt-get install uboot-mkimage

i.MX layers host packages for a Ubuntu 14.04 host setup only:

$ sudo apt-get install u-boot-tools

The configuration tool uses the default version of grep that is on your build machine. If there is a different version of grep in your path, it may cause builds to fail. One workaround is to rename the special version to something not containing "grep".

Setting up the repo utility

Repo is a tool built on top of Git that makes it easier to manage projects that contain multiple repositories, which do not need to be on the same server. Repo complements very well the layered nature of the Yocto Project, making it easier for customers to add their own layers to the BSP.

To install the “repo” utility, perform these steps:

1. Create a bin folder in the home directory.

$ mkdir ~/bin (this step may not be needed if the bin folder already exists)
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo

2. Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable.

$ export PATH=~/bin:$PATH

Yocto Project Setup

The Freescale Yocto Project BSP Release directory contains a "sources" directory, which contains the recipes used to build, one or more build directories, and a set of scripts used to set up the environment.

The recipes used to build the project come from both the community and Freescale. The Yocto Project layers are downloaded and placed in the sources directory. This sets up the recipes that are used to build the project.

The following example shows how to download the Freescale Yocto Project Community BSP recipe layers. For this example, a directory called fsl-release-bsp is created for the project.

$ mkdir ~/fsl-release-bsp
$ cd ~/fsl-release-bsp
$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"
$ git config --list
$ repo init -u https://source.codeaurora.org/external/imx/fsl-arm-yocto-bsp/ -b nxp/imx-3.14.28-1.0.0_ga

Once init your repo modify default manifest, with the following. To see a hidden folder like .repo you need to press ctrl + h, or open it from terminal using:

$ gedit .repo/manifests/default.xml

Then copy and paste the following Manifest:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>

 <default sync-j="2"/>
 <remote fetch="https://source.codeaurora.org/external/imx/" name="meta-fsl-bsp-release" />
 <remote fetch="git://git.yoctoproject.org" name="yocto"/>
 <remote fetch="git://github.com/Freescale" name="freescale"/>
 <remote fetch="git://git.openembedded.org" name="oe"/>
 <remote fetch="git://github.com/OSSystems" name="OSSystems"/>
 <remote fetch="git://github.com/meta-qt5" name="QT5"/>
 <project remote="yocto" revision="f20e4c0cf6ddb29a1aad6e7b095e1472e81d330c" name="poky" path="sources/poky"/>
 <project remote="yocto" revision="b74e5e690d8d4e149ea9de3f0fcca37bad93935f" name="meta-fsl-arm" path="sources/meta-fsl-arm"/>
 <project remote="oe" revision="7bbacd0023fa1111da94ba0b2aafd7d872301ffe" name="meta-openembedded" path="sources/meta-openembedded"/>
 <project remote="freescale" revision="89c605386ec81d64b38562acbc66942964fad971" name="fsl-community-bsp-base" path="sources/base">
 <copyfile dest="README" src="README"/>
 <copyfile dest="setup-environment" src="setup-environment"/>
 </project>
 <project remote="freescale" revision="b32528c10caac5e85f2b5efe0e5b95322dd68ace" name="meta-fsl-arm-extra" path="sources/meta-fsl-arm-extra"/>
 <project remote="freescale" revision="48cb0bcdd226d2e7eee1fdc222713e1dff93342c" name="meta-fsl-demos" path="sources/meta-fsl-demos"/>
 <project remote="OSSystems" revision="63963cc56c8d0291779693e62b66cb16e5c86883" name="meta-browser" path="sources/meta-browser" />
 <project remote="QT5" revision="41c5daa84af4466bfc9aa61f6f772c68470a628b" name="meta-qt5" path="sources/meta-qt5" />
 <project remote="meta-fsl-bsp-release" name="meta-fsl-bsp-release" path="sources/meta-fsl-bsp-release" revision="nxp/dizzy_3.14.28-1.0.0_GA" >
 <copyfile src="imx/tools/fsl-setup-release.sh" dest="fsl-setup-release.sh"/>
 </project>

</manifest>

Now you can sync:

$ repo sync
$ cd sources
$ git clone https://git.seco.com/arm/nxp/imx6/bsp5/release/meta-seco-bsp-release.git
$ cp meta-seco-bsp-release/seco-setup-release.sh ../
$ cp meta-seco-bsp-release/seco-yocto_configurator.sh ../
$ cd ..

When this process is completed, the source code is checked out into the directory fsl-release-bsp/sources . You can perform repo synchronization, with the command repo sync , periodically to update to the latest code.

If errors occur during repo initialization, try deleting the .repo directory and running the repo initialization command again.

Choosing a Freescale Yocto Project image

The Yocto Project provides some images which are available on different layers. Poky provides some images, meta-fslarm and meta-fsl-demos provide others, and additional image recipes are provided in the meta-fsl-bsp- release layer. The following table lists various key images, their contents, and the layers that provide the image recipes.

Image Name Target Provided By Layer
core-image-minimal A small image that only allows a device to boot. poky
core-image-base A console-only image that fully supports the target device hardware. poky
core-image-sato An image with Sato, a mobile environment and visual style for mobile devices. The image supports X11 with a Sato theme, Pimlico applications. It contains a terminal, an editor and a file manager. poky
fsl-image-machine-test An FSL Community i.MX core image with console environment - no GUI interface. poky
fsl-image-gui i Builds a Freescale image with a GUI without any QT content. This image recipe works on all backends for X11, DirectFB, Frame Buffer and Wayland meta-fsl-bsp-release/imx/meta-fsl demos
fsl-image-qt5 Builds a QT5 image for X11, Frame Buffer and Wayland backends meta-fsl-bsp-release/imx/meta-fsl demos

Configurations and build

The following chapters describes the manual steps and automatic steps which you have to follow for configure and build yocto manually as well automatically.

Automatic

The Seco Yocto Project provided a tools called "seco-yocto_configurator.sh" that you can launch from commandline in this way:

$ ./seco-yocto_configurator.sh -c

Once you entered the command, the configuration dialogue will be appear,

800px]

Now, you have to configure the hardware requirements accordingly. The requirements to set the correct configuration which you are having.

>>> DDR Size  --> Select the DDR size tab and  which size of DDR you are using for your hardware.
>>> Board Type  --> Then click the board type tab and  choose the board which board you using.
>>> CPU type  --> Click the CPU type and set the CPU type which you are using.
>>> Environment device --> Go to the environment device and select what device you going to use.
>>> Yocto build directory  --> This device contains some specific final image of the board like Uboot,Linux_kernel and File system.
>>> Yocto backend option  --> Select the tab and set the back end option for your requirements.
>>> Yocto image type  --> Go to the tab and accordingly click the image type which you are going to use.

Once you done the configure then press the exit tab ,the dialogue box will appear and choose the option Yes with compilation.Once you compiled successfully you can get the whole Yocto image, if you are getting error you find it and clear the error then do the steps again.

Manual

The following chapters describes the manual steps that you have to follow for configure and build Yocto manually.

In the meta-fsl-bsp-release layer, Freescale provides new or updated machine configurations that overlay the metafsl-arm machine configurations. These files are copied into the meta-fsl-arm/conf/machine directory by the fslsetup-release.sh script.

The following are all the machine configuration files that can be selected:

$ source setup-environment

Usage: source setup-environment <build-dir>

<build-dir>: specifies the build directory location (required).

If undefined, this script will set $MACHINE to 'imx6qsecosbca62'.

Use the machine configuration for the board that is being used and specify the graphical backend desired.

The backend can be x11, fb (Frame Buffer), dfb (DirectFB), or wayland.

Ignore the imx6qdlsolo machine. In the meta-fsl-bsp-release layer, a consolidated machine configuration is provided,

imx6qdlsolo. Freescale uses this to build a common image with all the device trees for i.MX 6Quad, 6DualLite, and Solo (not SoloLite) in one image for testing. Do not use this image for a real build.

The command below is used to set up a directory and configuration files for the specified board and backend. After this step,

the build environment is initialized and configured for building an image.

800px]
$ MACHINE=<machine name> source seco-setup-release.sh -b <build dir> -e <backend>

The EULA must be accepted the first time. After that, the acceptance is logged and EULA acceptance is not required again.

MACHINE= <machine configuration name> is the machine name which points to the configuration file in meta-fsl-arm/conf/machine.The setup script checks for a valid machine. Without setting MACHINE , the setup script assumes imx6qsecosbca62 as the default.The i.MX machine files are provided in meta-fsl-arm/conf/machine and meta-fsl-bsprelease/imx/meta-fsl-arm/conf/machine.The MACHINE configuration can also be changed in <builddir>/conf/local.conf.

The following is a part of a local.conf created from the setup-environment script:

MACHINE ??= 'imx6qsecosbca62'

DISTRO ?= 'poky'

ACCEPT_FSL_EULA = "1"

The fsl-setup-release.sh script integrates the Freescale Yocto Project release layer into the Yocto Project build by inserting the layer into the <build dir>/conf/bblayers.conf file.

This setup script has the following optional parameters:

*-b sets the build directory.
-b <build dir >
* -e sets the graphical back end for frame buffer and direct fb images. X11 is default if no backend is set.
* -e fb
* -e dfb
* -e wayland
* -e x11

ACCEPT_FSL_EULA in the local.conf file indicates that you have accepted the conditions of the EULA.

Build Image

The Yocto Project build uses the bitbake command. For example, bitbake <component> builds the named component.

Each component build has multiple tasks, such as fetching, configuration, compilation, packaging, and deploying to the target rootfs.

The bitbake image build gathers all the components required by the image and build in order of the dependency per task.

The first build is the toolchain along with the tools required for the components to build.

The following command is an example on how to build an image:

$ bitbake fsl-image-gui

Copying Image to SD card

After the successful compilation . The first possibility is to use the SD card image build by Bitbake, a tool integrated in Yocto. This image has the ending *.sdcard and can be found under build/deploy/images/<MACHINE>/<IMAGENAME>-<MACHINE>.sdcard. It contains all BSP files in correctly formatted partitions already and can be easily copied to the SD card using dd.

Get the correct device name (<your_device>) with sudo fdisk –l or from the last outputs of dmesg after inserting the SD card.

Now use the following command to create your bootable SD card

host$ sudo dd if=<IMAGENAME>‐<MACHINE>.sdcard of=/dev/<your_device> bs=1MB conv=fsync

where <your_device> could be for example "sde", depending on your system. The parameter conv=fsync forces a sync operation on the device before dd returns. This ensures that all blocks are written to the SD card and are not still in memory.

Adding meta-java layer

The java layer provides recipes related to java. Most layers are registered at openembedded.org

For meta-java layer, we have to refer the link to clone the source using below command to the yocto source.

 
git clone --no-checkout http://git.yoctoproject.org/git/meta-java

After the cloning source need to added java layer to build/conf/bblayers.conf :

 
BBLAYERS += " ${BSPDIR}/sources/meta-java "

Note: Need to clone the working branch clone

 
git clone -b krogoth http://git.yoctoproject.org/git/meta-java

</syntaxhighlight>

And need to be provide the package in local.conf as per java versions,Here with providing the example of building openjdk-7 as follow the below configuration to build.

 
PREFERRED_PROVIDER_virtual/java-initial = "cacao-initial"
PREFERRED_PROVIDER_virtual/java-native = "jamvm-native"
PREFERRED_PROVIDER_virtual/javac-native = "ecj-bootstrap-native"
PREFERRED_VERSION_cacao-initial = "0.98"
PREFERRED_VERSION_classpath-initial = "0.93"
PREFERRED_VERSION_cacao-native = "0.99.3"
PREFERRED_VERSION_classpath-native = "0.97.2"
PREFERRED_VERSION_cacao = "0.99.4"
PREFERRED_VERSION_classpath = "0.98"
PREFERRED_PROVIDER_virtual/java-initial-native = "cacao-initial-native"
PREFERRED_PROVIDER_openjdk-7-jre = "openjdk-7-jre" 

IMAGE_INSTALL_append = "openjdk-7-jre \
                        jamvm \
"

then we add the local.conf, then we can build the yocto as following below,

 
mathan@mathan:~/imx-yocto-bsp$ MACHINE=seco-a62-qd-256mbx4 bitbake openjdk-7

Once get build yocto, you can find the Java file in usr/bin/java..

Eg: As result expected

 
root@seco-a62-qd-256mbx4:~# java -version
java version "1.7.0_99"
OpenJDK Runtime Environment (IcedTea 2.6.5) (99b00-2.6.5)
OpenJDK Zero VM (build 24.95-b01, mixed mode)