Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Version 1.2.1
August 2012
Alex Gonzlez
Digi International
Agenda
Yocto Overview
Yocto 1.2.1 release System developers
Yocto components Installing the Yocto build tree
Yocto build system Using Yocto for system development
Yocto Layers Yocto build system
Bitbake recipes Yocto configuration
System development workflow
Overview
Application developers Image generation process
Application Development Kit Overview Image creation
Yocto standalone toolchain installation Package repository
Using the toolchain outside of Yocto Yocto Features
Yocto ADT installer Command line build
Application development workflow Bitbake commands
Command line workflow Build times
Eclipse plug-in for application developers Using Hob
Installation Fixing existing applications
Configuration Yocto's Kernel Tree
Running a Yocto project application Kernel customization
Debugging a Yocto project application Kernel patching
Bitbake commander Freescale's Yocto kernel
The meta-fsl-arm layer
Kernel configuration
Yocto Overview
Open source, collaborative, umbrella project.
They are directories to look for recipes and added to BBLAYERS in build/conf/bblayers.conf
Yocto layers
Management
bitbake-layers <command> [arguments]
Layer structure
Where command can be:
meta-<bsp_name>/
meta-<bsp_name>/<bsp_license_file> help
meta-<bsp_name>/README show-layers: Show current configured layers.
meta-<bsp_name>/README.sources show-recipes: List available recipes and its layer parents.
meta-<bsp_name>/binary/<bootable_images> show-overlayed: Show overlayed recipes (duplicated name on
meta-<bsp_name>/conf/layer.conf a higher priority layer)
meta-<bsp_name>/conf/machine/*.conf show-appends: List .bbappend files and their recipe files.
meta-<bsp_name>/recipes-bsp/* flatten: Flattens the layer configuration into a different folder.
meta-<bsp_name>/recipes-core/* This are all layers with overlayed recipes removed and .
meta-<bsp_name>/recipes-graphics/* bbappend files added to their corresponding recipes.
meta-<bsp_name>/recipes-kernel/linux/linux-yocto_<kernel_rev>.
bbappend
yocto-bsp help
yocto-bsp help create
Bitbake recipes
Each application has one or more bitbake recipe in the different layers. To add a new package to Yocto you need to provide
a .bb recipe for it. You can use any OpenEmbedded recipe as template.
meta/recipes-core/expat/expat_2.1.0.bb
require expat.inc
LIC_FILES_CHKSUM = "file://COPYING;md5=1b71f681713d1256e1c23b0890920874"
PR = "r0"
SRC_URI[md5sum] = "dd7dab7a5fea97d2a6a43f511449b7cd"
SRC_URI[sha256sum] = "823705472f816df21c8f6aa026dd162b280806838bb55b3432b0fb1fcca7eb86"
meta/recipes-core/expat/expat.inc
SUMMARY = "A stream-oriented XML parser library."
DESCRIPTION = "Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers
for things the parser might find in the XML document (like start tags)"
HOMEPAGE = "http://expat.sourceforge.net/"
SECTION = "libs"
LICENSE = "MIT"
SRC_URI = "${SOURCEFORGE_MIRROR}/expat/expat-${PV}.tar.gz \
file://autotools.patch"
inherit autotools lib_package gzipnative
# This package uses an archive format known to have issue with some versions of gzip
do_unpack[depends] += "gzip-native:do_populate_sysroot"
do_configure_prepend () {
rm -f ${S}/conftools/libtool.m4
}
Bitbake classes
Bitbake classes (.bbclass) provide encapsulation and inheritance logic. They abstract common functionality and share
it amongst several recipes.
Class files are placed in a classes directory under the meta or build directory, and are searched for in the BBPATH as
.conf files.
To enable its features it is usually enough to inherit the class. Every .bb recipe inherits the base.bbclass automatically.
It contains definitions of basic tasks as fetching, unpacking, configuring, compiling, installing and packaging. These are
usually overridden by other classes as autotool.bbclass or package.bbclass.
autotools.bbclass
distutils.bbclass
update-alternatives.bbclass
devshell.bbclass
update-rc.d.bbclass
package*.bbclass
binconfig.class
kernel.bbclas
pkgconfig.bbclass
image.bbclass
src_distribute.bbclass
rootfs*.bbclass
src_distribute_local.bbclass
sanity.bbclass
cpan.bbclass
insane.bbclass
Bitbake recipes
Multiple providers
If a target has multiple providers, like different kernel or application versions, bitbake defaults to the
higher version. But this selection can be qualified by adding the following to a recipe:
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto"
COMPATIBLE_MACHINE
Stops parsing unless machine listed here.
DEFAULT_PREFERENCE
Relative priority among like-named recipes. Overridden by
PREFERRED_VERSION_*
PREFERRED_VERSION_virtual/kernel = "3.2"
Bitbake recipes
License tracking
LIC_FILES_CHKSUM variable contains checksums of the license text in the source code for the recipe. It's mandatory
for all recipes, unless the LICENSE variable is set to "CLOSED".
LIC_FILES_CHKSUM = "file://COPYING;md5=xxxx \
file://licfile1.txt;beginline=5;endline=29;md5=yyyy \
file://licfile2.txt;endline=50;md5=zzzz \
Commercial licenses
Recipes which contain:
LICENSE_FLAGS = "commercial"
LICENSE_FLAGS = "license_${PN}_${PV}"
Need to have a matching entry in the LICENSE_FLAGS_WHITELIST in local.conf, as:
LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly"
LICENSE_FLAGS_WHITELIST = "commercial_gst-plugins-ugly license_emgd_1.10"
Introduction to Yocto
Application developers
Application developing contents
Application developing
Application Development Kit Overview
Yocto standalone toolchain installation
Using the toolchain outside of Yocto
Yocto ADT installer
Application development workflow
Command line workflow
Eclipse plug-in for application developers
Installation
Configuration
Running a Yocto project application
Debugging a Yocto project application
Bitbake commander
Application Development Kit Overview
The application developer can:
Use the ADT installer to install per architecture cross toolchains, environment setup scripts
(/opt/poky/1.2.1), a sysroot (configured location f.e ${HOME}/yocto), and QEMU images:
Or can use the toolchain and sysroot from a Yocto release tarball, what we will call Yocto Project
Build Tree (YPBT).
Yocto standalone toolchain installation
Download a precompiled tarball.
Built in the YPBT for deployment:
source oe-init-build-env [optional folder name]
bitbake meta-toolchain-gmae (sato)
bitbake meta-toolchain
In both cases the tarball is uncompressed in /opt/poky/x.y, the recommended toolchain location.
/opt/poky/1.2/environment-setup-${ARCH}-poky-linux
Autotools
Makefile
CC=arm-poky-linux-gnueabi-gcc
LD=arm-poky-linux-gnueabi-ld
CFLAGS=${CFLAGS} --sysroot=<sysroot-dir>
CXXFLAGS=${CXXFLAGS} --sysroot=<sysroot-dir>
Yocto ADT installer
Download a precompiled release
source oe-init-build-env
bitbake adt-installer
Extract anywhere:
Installs into /opt/poky/x.y the toolchain, sysroot (at the configured location) and QEMU kernel images
(in the adt-installer/download_image/zImage-qemuarm.bin)
Application development workflow
The Eclipse plug in allows you to:
Custom BSP
Copy an existing one
Make configuration
changes
Make recipe changes
Compile
Deploy
Run
Debug
Command line workflow
Build the ipk package
bitbake <pkgname>
bitbake package-index
Copy them to a web server and modify the base-feeds.conf file in the target:
/etc/opkg/base-feeds.conf
src/gz all http://www.mysite.com/somedir/deploy/ipk/all
2) Update with:
http://download.eclipse.org/releases/indigo
Programming Languages -> Autotools Support for CDT
Programming Languages -> C/C++ Development Tools
Linux Tools -> LTTng - Linux Tracing Toolkit
http://download.eclipse.org/tm/updates/3.3
TM and RSE Main Features
TM and RSE Optional Add-ons -> Every item except "RSE Unit Tests and RSE WinCE Services"
http://download.eclipse.org/tools/cdt/releases/indigo
CDT Main Features
CDT Optional Features -> C/C++ Remote Launch and Target Communication Framework.
http://downloads.yoctoproject.org/releases/eclipse-plugin/1.2.1
Development tools and SDKs for Yocto Linux
Eclipse plug-in for application developers
Configuration
Windows -> Preferences -> Yocto ADT (also per project configuration)
Standalone Pre-built Toolchain: Toolchain and sysroot installed separately, without the Yocto Project build tree.
Build System Derived Toolchain: Toolchain built as part of the Yocto Project build tree.
Toolchain: For standalone prebuilt toolchain use /opt/poky/x.y , otherwise, point to the Yocto's project build/tmp
directory
Sysroot: Point to the place where the rootfs for the target is created by the ADT installer. Used by QEMU, the NFS
boot process and the x-toolchain. Otherwise, the YBPT installs it in build/tmp.
Target architecture: Chose from the dropdown box.
QEMU: For a build system derived toolchain, the kernel will be in tmp/deploy/images. Otherwise, it's in the directory
specified to he ADT installer to download the image, by default adt_installer/download_image/zImage-qemuarm.bin.
Project -> "Change Yocto Project Settings" can change the toolchain configuration per project.
Eclipse plug-in for application developers
Running a Yocto project application
Creating a project
File -> New -> C/C++ project -> Yocto ADT project
root@qemuarm:/# /bin/HelloWorld;exit
Hello World
logout
Eclipse plug-in for application developers
Debugging a Yocto project application
Place a breakpoint in main().
Debug Configuration->C/C++ Remote applications, click Debug.
The debug perspective appears with the application executed in QEMU.
For this to work the target image needs to contain a TCF agent service, which is added to an image as part of the tools.
debug feature.
Eclipse plug-in for application developers
Bitbake Commander
Allows you to add and modify the project's layers. Once the metadata project is created, we can modify it as
follows:
As general rules:
1. File -> New -> Yocto BitBaker Commander -> Bitbake
You never change the metadata from upstream
recipe
(unless you are submitting a bug report upstream)
2. Point SRC_URI to the package source.
You always use additional layers to make your own
3. Click populate to auto complete some fields, and complete
changes.
"Description" and "License" fields.
When creating a new Yocto Project, you can point it to an 4. Project -> Launch Hob
existing YPBT, or you can instruct it to clone one from the 5. Choose the build directory to place the final images. (Not
upstream Yocto project in a new location (not the Eclipse the YPBT, just an output folder)
workspace). 6. Use Hob to customize and build your own images.
YoctoProjectTools -> yocto-bsp allows to create a new
layer.
Introduction to Yocto
System developers
System developing contents
System developers
Installing the Yocto build tree
Using Yocto for system development
Yocto build system
Yocto configuration
System development workflow
Overview
Image generation process
Image creation
Package repository
Yocto Features
Command line build
Bitbake commands
Build times
Using Hob
Fixing existing applications
Yocto's Kernel Tree
Kernel customization
Kernel patching
Freescale's Yocto kernel
The meta-fsl-arm layer
Kernel configuration
Installing the Yocto build tree
1. Development host machine setup
2. Yocto installation:
Downloading all sources is time consuming so you probably only what to do it once. To use a local mirror, after a
complete build move the sources and edit your local.conf file to include:
SOURCE_MIRROR_URL ?= "file://path_to_local_mirror"
INHERIT += "own-mirrors"
BB_GENERATE_MIRROR_TARBALLS = "1"
To make sure you can build without network access you can add:
BB_NO_NETWORK = "1"
Yocto build system
Yocto configuration
Local user defined:
build/conf/local.conf
MACHINE
BB_NUMBER_THREADS
PARALLEL_MAKE
DL_DIR
Policy
meta-yocto/conf/distro/poky.conf
Machine specific
meta-bsp/conf/machine/imx51evk.conf
System development workflow
Overview
Image creation
Adding existing packages to image
Adding a Yocto feature
Creating a custom image
Adding new packages to Yocto
Fixing existing applications workflow
Kernel development
Source modifications
Configuration changes
Shared state caching (Or using checksum information during the build)
Bitbake uses a per-task state caching system and not per recipe. It checksums the tasks inputs and rerun the
task if they have changed. This is called the basehash. A master checksum add the basehash and the
hashes of the task's dependencies.
The shared state code looks in SSTATE_DIR (local) and SSTATE_MIRRORS (network) for shared state
files. The state validity is detected looking at its name as the task checksum is there. If it's valid, it downloads
it and uses it to accelerate the task.
System development workflow
Image creation DESCRIPTION = "My Custom Tasks"
PACKAGES = "\
Images can be customized in the build/local.conf file: task-custom-apps \
task-custom-apps-dbg \
Adding packages to the image: task-custom-apps-dev \
task-custom-tools \
IMAGE_INSTALL = "task-core-x11-base package1 package2" task-custom-tools-dbg \
inherit core-image task-custom-tools-dev \
IMAGE_INSTALL_append = " sysfsutils" [note the leading space] "
RDEPENDS_task-custom-apps = "\
Or by adding a new task (see right box), using meta/recipes-core/tasks/task- dropbear \
core-boot.bb as an example. portmap \
psplash"
And then adding it to the image : RDEPENDS_task-custom-tools = "\
oprofile \
IMAGE_INSTALL_append " task-custom-apps task-custom-tools" oprofileui-server \
lttng-control \
lttng-viewer"
RRECOMMENDS_task-custom-tools = "\
kernel-module-oprofile"
System development workflow
Package repository
DISTRO_FEATURES
MACHINE_FEATURES
Some distribution feature example are alsa, bluetooth, ext2, usbgadget, usbhost, wifi, nfs, ipv6 ,
toucshcreen etc
IMAGE_FEATURES
EXTRA_IMAGE_FEATURES
Build configuration
Build, no clean
Total time: 1min 30secs
build/local.conf
BB_NUMBER_THREADS = "4"
Clean, then rebuild
PARALLEL_MAKE = "-j 4"
Remove build directory
MACHINE ??= "qemuarm"
Same as first build above.
Remove only build output /tmp (keeps
Download source first downloaded sources and state)
bitbake -c fetchall core-image- Total time: 8 mins.
minimal
Then build
bitbake core-image-minimal
Using Hob
Hob is a GUI for bitbake.
Adding layers
Choose image type
Add/remove individual recipes and
tasks
Select output image types, packaging
format, etc
System development workflow
Fixing existing applications
Find the path to the temporary source code for your Generate the patch
package.
git format-patch HEAD~1
bitbake -e <target> | grep ^S=
Copy the patch to a "files" folder in the same directory
Change to that path and create a local git repo as the recipe.
git init Add it to Yocto:
git add * SRC_URI += "file://my_changes.patch"
git commit Increment the Package revision number (PR)
Clean:
Edit files
Test your changes bitbake -c clean -f <pkgname>
bitbake -c compile -f <pkg_name> bitbake -c cleanall -f <pkgname>
Commit your changes
git status
git add file1.c file2.c file3.c
git commit
Yocto's Kernel Tree
The Yocto kernel team has its own set of processes and tools. The Yocto
kernel tree is structured as follows:
Add it to bblayers.conf
The meta-fsl-arm kernel does not yet use the same .cfg and .scc
files, and does not use the Yocto kernel project tool.
Yocto's kernel tree
Kernel patching
Kernel patches can be manually added/removed.
Or we can use the yocto-kernel command line tool.
So bitbake will look for the most recent "linux-imx" recipe from:
linux-imx_2.6.35.3.bb
linux-imx_2.6.38.bb
linux-imx_3.0.15.bb