5710723, 501 PM Yosto~ hands on -technolnchpin
October 7,.2015January 13,2016
Yocto — hands on
This is a continuation to my previous post on adopting Yocto driven package management solution. This
is a brief consolidation of the terminologies and steps involved while configuring the Yocto to setup to
gain a basic understanding and to refresh the steps quickly while you attempt to setup and build any
new packages.
To introduce the Yocto Project well in this page, in reality I would have to replicate almost everything ex-
plained in theYocto refernece manual and Starting with Yocto project in FOSDEM is very helpful for any-
one to quickly refresh the concepts though there are quite a lot of very good usage notes and learning
from many users who are well experienced and contributing to the yocto project.
Yocto Project incorporates many different pieces of the development process. These pieces are referred to
as projects within the overall Yocto Project, and they include build tools, build instruction metadata
called recipes, libraries, utilities, and graphical user interfaces (GUIs).
To get a hands on experience one can get Poky, the reference build system For this poky includes
© the build engine Bitbake which is basically a scheduler and task executor component
© The base layer is termed as OpenEmbedded-core or oe-core is included in the Poky which has a col-
lection of meta datatypes like classes (templates) ,recipes (set of instructions ) and conf ( configuration
of builds/packages) which are common for all the builds. The layered topology allows customization
of builds by modifying or adding layers on top of oe-core
More on Yocto Terminology - recipes and packages
The following section try to brief on basic terminologies and elements that one should know be aware of
bitbake
the build tasks scheduler ,a relatively easy to use tool with a handy set of options to work on recipies and
image creation Bitbake can produce a complete SDK including cross compiler and tools. Images for many
kinds of devices can be generated,
Recipe Basics
A recipe is a set of instructions that is read and processed by the build engine called BitBake (identified
by the bb extension). In its most basic form a recipe is a single file with some lines in it describing the
software to be built. They have source urls (http https, ftp, cvs, svn, git, local file system) of the package,
dependencies and compile or install options. During the build process they are used to track dependen-
cies, performing native or cross-compilation of the package and package it so that it is suitable for instal-
lation on the local or a target device
Each package, like busybox, i2c-tools commonly used by embedded developers, etc, have an associated
‘recipe’ that describes the build process (where to get the source code, how to build, how to deploy to the
root file system image). Yocto comes with a large set of recipes, located under the folder named ‘meta’. The
rips: ]technolinchpin.wordpress.com/2015/10/07iyacto-hands-on 16syr079, 501 Px oct ~ hands on —echnolincin
ecosystem partners release their own compatible version of meta layers . For example silicon vendors and
IVI distro providers contribute their meta layers with the recipes for the software /package they support
Setting up build environment and configurations
Customize the conf files
The
-init-build-env script when sourced for the first time will generate some generic
configuration files in the build/conf directory.
‘You need to source this script everytime to perform the build from a new shell.
This script will augment your path and set several env variables useful for cross-compiling:
© PKG_CONFIG_SYSROOT_DIR PKG_CONFIG_PATH (for pkg-config)
© CCCXX CPP AS LD GDB STRIP RANLIB OBJCOPY OBJDUMP AR NM CFLAGS CXXFLAGS
LDFLAGS CPPFLAGS ARCH CROSS_COMPILE (for make and cmdline use)
© Md CONFIGURE_FLAGS (for aclocal/autoconf/autoheader/automake/autoreconf/autoupdate use)
‘Once you have them you want to replace those with the conf-samples in the meta-
/conf directory.
helpayocto:~/ebb/builds cp ~/bbb/meta-your-project/conf/local.conf-sample conf/local.conf
helpayocto:~/bbb/builds cp ~/bbb/meta-your-project/coni/bblayers.conf-sample conf/bblayers.cont
You generally only have to edit these files once.
Edit bblayers.conf
In bblayers.conf file replace $(HOME} with the appropriate path to the meta-layer repositories on your
system if you modified any of the above instructions when cloning.
Edit local.conf
The variables you may want to customize are the following:
© TMPDIR
© DL_DIR
© SSTATE_DIR
‘The defaults for all of these work fine. Adjustments are optional
TMPDIR
This is where temporary build files and the final build binaries will end up. Expect to use at least 35GB.
You probably want at least 50GB available.
ritps:/technolinchpin.wordpress.com/2015/10/07iyacto-hands-on 218syr079, 501 Px oct ~ hands on —echnolincin
Leave it as the default location is in the build directory, in this example ~/yourproject/build/tmp.
If you specify an alternate location as I do in the example conf file make sure the directory is writable by
the user running the build.
DL_DIR
This is where the downloaded source files will be stored. You can share this among configurations and
build files so I created a general location for this outside my home directory. Make sure the build user has
write permission to the directory you decide on.
The default location is in the build directory, ~/yourproject/build/sources.
SSTATE_DIR
This is another Yocto build directory that can get pretty big, greater then 5GB. The default location is in
the build directory, ~/yourproject/build/sstate-cache.
Package Basics
A package is an archive that most typically contains binary artifacts from a build. The OE based distribu-
tion use the .ipk packaging based on the opkg tools (http://code.google.com/p/opkg.)
By default, a recipe produces at a minimum, 4 packages.
© the binary package populated in root file system with the artifacts from that recipes’ build output.
© (dev) package — header files and libraries for development
© (-doc) package - mostly empty for many packages!,
© debug (-dbg) package , binaries and libraries compiled with debug symbols,
You should be able to get the packages searching the included package recipes using bitbake Once you
get them you have to build the packages and include them in your target image.
Run the bitbake with -¢ option and use grep to filter out the packages that the given recipe will produce
$ bitbake -e lua | grep ‘PACKAGES=
Run the build
You need to source the environment every time you want to run a build. The -init-build-
eno script ;when run a second time will not overwrite your customized cont files.
Creating target image including selected packages
Poky provides several predesigned image recipes that we can use to build our own binary image. We can
check the list of available images running the following command from the poky directory:
$: 1s meta*/recipes*images/*.bb
All the recipes provide images which are, in essence, a set of unpacked and configured packages
generating filesystem for the hardware platform.
rpsRechnotnepn wordpess.com2015/7iyacto ‘hands-on a65110723, 501 PM Yoeto ~ hands on —technoinchpin
This is most confusing when trying to add new packages to your root file system image. The packages
can be added by modifyign the IMAGE_INTALL definition in the conf file.
IMAGE_INSTALL += “package-names”
Look at the packages produced by the net-snmp recipe, using BitBake's -e switch, we have:
$ bitbake -e net-snmp | grep “PACKAG
PACKAGES="net-snmp-dbg net-snmp-doc net-snmp-dev net-snmp-staticdev net-snmp-static net-snmp-
libs net-snmp-mibs net-snmp-server net-snmp-client”
Looking at this output, it becomes clear that the packages desired for installation on the root file system
are net-snmp-server, net-snmp-client, and possibly the supporting packages such as the -libs and -mibs.
So your image must be modified to have these packages installed. In summary, the correct way to
specify this is as follows:
IMAGE_INSTALL += “net-snmp-server net-snmp-client net-snmp-libs net-snmp-mibs”
bitbake -¢ is your friend. Use it often — it can really help you understand what's going on when things
don’t work out as you expect.
Build
As example to build the ‘console-image’ , run the following command upon the console-mage.bb file
help@yocto:~/bbb/builds bitbake console-image
In case of any errors ,try to clean the package for which build failed and rerun the image build
For instance if the build for zip failed for some reason, re- run this
helpwyocto:~/bbb/builds bitbake -c cleansstate zip
help@yocto:~/bbb/build$ bitbake zip
Once finished, all images should be generated in ~/build/tmp/deploylimages.
Managing disk space
Bitbake will keep copies of all workdirs for old packages, so over time if you update recipes (or ‘repo
syne’ which may update recipes) your disk usage will grow. ‘bitbake -cclean to clean specific
recipes (note that ‘bitbake -cclean ’ will only clean the current preferred version, not old
packages).
Also care to be taken to clean up the file system images from the pre
new one with a timestamp in build/tmp/deploy/images/
us builds as bitbake will create a
rm -rf build/tmp/deploy/images/* ;# remove old images we don't ca
bitbake prev-image-blah ;# build a new one
hitps:/technolinchpin.wordpress.com/2015/10/07iyacto-hands-on is,5110728, 501 PM
Yoeto ~ hands on —technoinchpin
For Yocto, all temporary files will be in build/tmp so if you want to clear out everything and start over
you can:
rm -rf build/tmp
Tool chain and SDK
See Yocto/SDK for information about a pre-built downloadable SDK
You can use bitbake to create a toolchain (cross-compiler) or an Software Development Kit (SDK) com-
prised of a cross-toolchain and libs.
Toolchain:
bitbake meta-toolchain
SDK (contains meta-toolchain as well as -dev and -dbg packages with headers and libs):
bitbake -cpopulate_sdk
© The produced SDK will be a self-extracting shell-script in tmp/deploy/sdk that contains all the include
headers and libs for the packages in the image - you can build an SDK for any image with any other
buildable
system image.
Happy bitbaking!!!!
Sponsored Content
Gadget-Lovers: Check Out the
New Tech in These Luxury
Homes Mansion Global | Sponso
red
Take A Look - Designer's Corner
Mansion Global | Sponsored
Comparing Dynamic Routing
Protocols Network Computing |
Sponsored
“The Marvelous Mrs. Maisel”
Star Tony Shalhoub Lists
Manhattan Apartment for
Nearly $4.5 Million Mansion Glo
bal | Sponsored
Fewer students spell trouble for
women's universities in Japan N
ikkei Asia | Sponsored
Five CDN Trends for
Enterprises to Track Network Co
mputing | Sponsored
Posted in Opensource driven Product development.
ritps:/technolinchpin.wordpress.com/2015/10/07iyacto-hands-on
‘Terraces That Pop: Try a Refresh
With Bold Colors This Spring M
ansion Global | Sponsored
Ukraine latest: Putin lauds 'sa-
cred’ fight at scaled-down
Victory Day Nikkei Asia | Spons
ored
Japanese chip-tester makers bet
big on 3D, EV devices Nikkei Asi
a | Sponsored
585110723, 501 PM Yoeto ~ hands on —technoinchpin
Create a free website or blog at WordPress.com. technolinchpin
hitps:/technolinchpin.wordpress.com/2015/10/07iyacto-hands-on
as