<<

Starting a Project with the Build System

Reducing Embedded Risk and Complexity

www.timesys.com ©2015 Timesys Corp About Timesys: Proven Linux Pedigree

. More than 1000 projects, 200+ customers . First to develop and deliver an award-winning, automated, intelligent, embedded Linux build system (LinuxLink 3.0) . Support for 8 architectures, 100+ processors & SoCs . Customers targeting industrial automation, mil/aero, medical, telecom, consumer electronics, and automotive segments . Support for multi-core environments . Member of the Yocto steering committee

First to register First to market open LinuxLink Factory carrier-grade source, commercial- First to deliver an adds 100th supported Real-time First embedded Customized grade Linux product — automated, intelligent build board Linux Eclipse-based Tools Linux Integrate Real-time LinuxLink 1.0 system - Leadership Versions with OS Community LinuxLink 2.0 LinuxLink 3.0

2001 2002 2003 2004 2005 2007 2008 2009 2010 2011 Manual Hosted Support for Multicore Automated Semis adapt Intelligent Customized Build 100% Open Source Build/Test Build system Build system Builds System

www.timesys.com ©2015 Timesys Corp. 3 Timesys – Your Embedded Linux Development Partner

• Direct offices in US, Europe, Asia • Pittsburgh, PA Headquarters • EMEA HQ, Poland • Asia HQ, Chennai, India • Products, commercial support contracts, services and training

North America EMEA APAC JAPAN

www.timesys.com ©2015 Timesys Corp. 4

Getting Ready for Yocto Project Development Environment

www.timesys.com ©2015 Timesys Corp. Your Workstation Setup

Ethernet/Serial

USB

. Development Environment • Cross tools Build System • IDE . Exercises

www.timesys.com ©2015 Timesys Corp. 6 Host Environment

. Depending on the Host System used, make sure that you have installed all required packages to run Yocto . $ sudo -get install gawk wget git-core diffstat unzip texinfo \ build-essential chrpath libsdl1.2-dev xterm curl . For other host OS http://www.yoctoproject.org/docs/current/yocto-project-qs/yocto-project-qs.html . For Virtual Machine setups, set the minimal memory size to 1GB and minimal disk size to 32GB . Install the repo tool from google $ mkdir ~/bin $ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo

www.timesys.com ©2015 Timesys Corp. Embedded Linux Reference Model

Target Host

Application (e.g. Base Station Control) App Features

•Cross-Development Environment (SDK) Third-Party • IDE • Application Debugging Application Application 1 Application 2 Application • Build System (e.g. Factory)

• RFS, Kernel, App Middleware and Application Services •Collaborative Development •Profiling

•Tracing

Software Networking UI Networking

User Space User Hundreds of APIs from •System Management Open Source and

Security Reliability Reliability Proprietary

System

Linux kernel Driver Driver Driver Driver more Kernel Space Kernel

Bootloader Driver Driver Driver Driver more

Board SOC LCD HW accel. SD USB more Hardware Virtualization

www.timesys.com ©2015 Timesys Corp. 8 Build System – Do We Need It?

. Without a build system, each application has to be built manually, or with help from a custom script . We need to find a correct toolchain . We need to configure and build each package and application by hand . For each package/application in the file system, we need to figure out the cross- dependency, which may involve changing configurations for multiple packages . If this does not sound painful enough, the next steps involve building a file system formatted correctly for the chosen form of deployment . Sharing your work with colleagues is also difficult

www.timesys.com ©2015 Timesys Corp. 9

Getting Started with Yocto Project

www.timesys.com ©2015 Timesys Corp. 10 Yocto Project Governance

. Organized under the Linux Foundation . Split governance model . Technical Leadership Team . Advisory Board made up of participating organizations

Member Supporting Member

www.timesys.com ©2015 Timesys Corp. 11 What is Yocto Project?

. An Open source project with a strong community . A collection of embedded tools and projects • Place for Vendors to release BSPs • Application Development Tools (ADT) including Eclipse plug-ins . Support for ARM, x86, MIPS and Power . Layer approach enables re-use of software . Complete build system for Linux OS • Latest kernel (LTSI) • Toolchain Yocto is not a Linux • Packages distribution. Yocto creates • Documentation one for you . Releases every 6 months

www.timesys.com ©2015 Timesys Corp. 12 Yocto Project Releases

. Yocto names its releases, similar to Android

Name Revision Poky Release Date Bernard 1.0 5.0 Apr 5, 2011 Edison 1.1 6.0 Oct 17, 2011 Denzil 1.2 7.0 Apr 30, 2012 Danny 1.3 8.0 Oct 24, 2012 Dylan 1.4 9.0 Apr 26, 2013 Dora 1.5 10.0 Oct 19, 2013 Daisy 1.6 11.0 Apr 24, 2014 Dizzy 1.7 12.0 Oct 31, 2014 Fido 1.8 13.0 April 22, 2015

https://www.yoctoproject.org/documentation/current

www.timesys.com ©2015 Timesys Corp. 13 The Yocto Project Nomenclature

. BitBake • Powerful and flexible build engine • Determines dependencies and schedules tasks . Metadata • A structured collection of “recipes” which tell BitBake what to build • Organized in layers . Poky • The reference system • It is a collection of projects and tools, used to bootstrap a new distribution based on the Yocto Project . Recipes • Describe how to fetch, configure, compile and package an application and images • Have a specific syntax. . Layers • Sets of recipes, matching a common purpose. E.g. Freescale i.MX enabling layer ﰀ .

www.timesys.com ©2015 Timesys Corp. 14 Yocto Project

Open Embedded Yocto Project Poky meta-yocto

Open Embedded Core (oe-core) meta-yocto-bsp

recipes-core recipes-bsp recipes-kernel BitBake

recipes-multimedia recipes-… scripts

meta-fsl meta-qt5 meta-timesys

www.timesys.com ©2015 Timesys Corp. 15 Poky

Open Embedded Yocto Project Poky meta-yocto

Open Embedded Core (oe-core) meta-yocto-bsp

recipes-core recipes-bsp recipes-kernel BitBake

recipes-multimedia recipes-… scripts

meta-fsl meta-qt5 meta-timesys

www.timesys.com ©2015 Timesys Corp. 16 The Yocto Project Workflow

www.timesys.com ©2015 Timesys Corp. 17 Configuration Files

. Most important Global Build Settings are stored in specific *.conf files • Layers are defined in build/conf/bblayers.conf • Each layer definition is stored in /conf/layers.conf • Local, user defined configuration build/conf/local.conf • Board Support Package defined in meta-yocto-bsp/conf/machine/.conf • Distribution Policy can be found in meta-yocto/conf/distro/poky.conf

www.timesys.com ©2015 Timesys Corp. 18 User Configuration

. Most important from the perspective of building a custom distribution . In a local.conf we can define what the distribution is build for. It also allows us to override global default settings: • BB_NUMBER_THREADS • PARALLEL_MAKE • MACHINE • DISTRO • EXTRA_IMAGE_FEATURES . In bblayers.conf we can define which yocto layers we want to use in our distribution • Remember – this is in addition to the reference defined by Poky

www.timesys.com ©2015 Timesys Corp. 20 BitBake’s Operation

Source code

Config fetches builds Packages files parses

BitBake

generates

Recipes parses Images

www.timesys.com ©2015 Timesys Corp. 21

Setting up Yocto

www.timesys.com ©2015 Timesys Corp. 22 Does Yocto = Yocto?

. If you work with processors from different vendors does Yocto for each work the same? • and NO • YES – the build system structure is very similar – Leverage Poky – Bring board specific code via vendor dedicated metalayer – Use Bitbake engine to build • NO – different vendors use different management processes to get sources to your development host . Examples: • Freescale – use the repo tool to manage metalayers for the BSP • Atmel – provides guidance on which metalayers to check out from GIT repositories • TI – similar to Atmel, relies on meta-ti layer – Support for some boards in Poky – no need for separate layer • Intel – integrated into Poky, meta-intel layer used for new platforms before they get in Poky

www.timesys.com ©2015 Timesys Corp. 23 Downloading Sources with Repo (i.MX6)

. Download the BSP source with just installed repo tool $ PATH=${PATH}:~/bin $ mkdir fsl-community-bsp $ cd fsl-community-bsp $ repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b fido $ repo sync . Use the latest Yocto version – code name Fido . At this point we have every metadata necessary to build a BSP for a Freescale board . Remember to reissue the “repo sync” command to stay in sync with the latest code from Freescale

www.timesys.com ©2015 Timesys Corp. 24 Downloading Sources with GIT (Atmel, Intel, TI)

. Download the BSP source with just installed repo tool 1/ Clone yocto/poky git repository git clone git://git.yoctoproject.org/poky

2/ Checkout dizzy branch cd poky git checkout origin/dizzy -b my_branch

3/ Clone meta- git repository git clone git://git.openembedded.org/meta-openembedded

4/ Checkout proper meta-openembedded branch cd meta-openembedded git checkout origin/dizzy -b my_branch

7/ Clone meta-atmel layer git clone git://github.com/linux4sam/meta-atmel.git meta-atmel

www.timesys.com ©2015 Timesys Corp. 25 First Build (Repo)

. Create your local branch $ repo start --all • It will let you keep your code changes independent from head of the code • You will be able to rebase or sync your code • Helps in creating patches for code fixes . Select your board $ source setup-environment build_mx6 • The setup-environment script is a custom script provided by freescale, equivalent of Poky’s oe-init-build-env script. Its role is to setup basic build directory for the BSP • Open the conf/local.conf file with an editor such as vi • The default board (MACHINE) is set to imx6qsabresd, feel free to change it to any other board that’s already supported. • List of boards can be viewed with: $ ls ../sources/meta-fsl-arm/conf/machine/*.conf –l $ ls ../sources/meta-fsl-arm-extra/conf/machine/*.conf -l

www.timesys.com ©2015 Timesys Corp. 26 First Build

. There are several different images that can be built for a Freescale board. . Images range in number of packages from just a few to tens of packages for images that build X11, Qt and GStreamer . Complete list of images can be found with the command: $ find ../sources -name *image* . Lets build a small image to start (you are still in build directory) $ core-image-base

www.timesys.com ©2015 Timesys Corp. 27 Build Output

. Yocto directories . build_mx6 • Contains all build sub-products $ tree -d -L 2 -A • sstate-cache keeps the pre-build . ├── build_mx6 package binary. No need to rebuild if │ ├── conf there are no changes to a package │ ├── sstate-cache when building another image │ └── tmp . downloads downloads ├── • Keeps all the downloaded source │ └── git2 code └── sources ├── base . sources ├── meta-fsl-arm • Yocto build system with metadata ├── meta-fsl-arm-extra ├── meta-fsl-demos ├── meta-openembedded └── poky

www.timesys.com ©2015 Timesys Corp. 28 Build Output

. Built images . tmp/deploy build_mx6$ tree -d -L 2 -A • Images for deployment . ├── conf . tmp/log ├── sstate-cache • Complete build log └── tmp . tmp/work ├── buildstats • , the patches, last build ├── cache ├── deploy ├── log ├── pkgdata ├── sstate-control ├── stamps ├── sysroots ├── work └── work-shared

www.timesys.com ©2015 Timesys Corp. 29

Customizations

www.timesys.com ©2015 Timesys Corp. 30 Kernel

. A typical modification to a is to change its configuration . When using Freescale provided BSP, the default configuration file is fetched from Freescale as described in tree/recipes-kernel/linux/linux-imx.inc file SRC_URI = "git://git.freescale.com/imx/linux-2.6-imx.git \ file://defconfig \ " . Changing the Linux kernel configuration involved then overriding the fetched defconfig. The procedure: Copy the new defconfig to meta-fsl-arm/tree/recipes-kernel/linux/linux-imx-3.0.35/mx6 (or the right folder for your board/kernel) $ bitbake -c cleansstate linux-imx $ bitbake linux-imx (if you want only the kernel image) $ bitbake core-image-base (if you want to generate a complete image using the new kernel) . Reconfigure the Linux kernel with BitBake $ bitbake -c menuconfig linux-imx

www.timesys.com ©2015 Timesys Corp. 31 Changing a Filesystem Definition

. If we want to add a package to our RFS definition we need to: • Find the proper package name as defined in a layer $ bitbake -s | grep strace • Ensure that appropriate layer that provides the needed package is added to bblayers.conf • Include the package name in the image definition file vi recipes-fsl/images/core-image-base.bb IMAGE_INSTALL += ”strace" • Alternatively, I can add the package to my conf/local.conf file CORE_IMAGE_EXTRA_INSTALL += “strace”

www.timesys.com ©2015 Timesys Corp. 32 An SDK to Develop Apps

. Enables the ability to build applications (e.g. Qt) for any market segment . Pre-configured to support functionality offered by specific processor . Integrated with IDEs (e.g. QtCreator, Eclipse ) . Constructed by an advanced build system

Linux Complete SDK • • Linux kernel • System libraries Benefit: Complete cross-dev environment and utilities

Qt API Apps APIs • Libraries • Location GCC Yocto Cross-Toolchain • Headers • Sensors SDK • Qt modules • ... • QML

www.timesys.com ©2015 Timesys Corp. 33 Yocto SDK (Image)

. It can provide a preconfigured cross-toolchain for further development • Generic toolchain build: bitbake meta-toolchain . Various metalayers do provide their own image recipes that also build toolchains • Qt Embedded toolchain build: bitbake meta-toolchain-qte • Qt X11 toolchain build: bitbake meta-toolchain-qt • Qt5 toolchain build: bitbake meta-toolchain-qt5 . The primary task of an image based SDK is to facilitate development of your product applications that execute on your hardware • Use APIs that you add to your custom BSP definition . Yocto provides dedicated task: populate_sdk . To generate an SDK for our custom BSP $bitbake –c populate_sdk custom-use-image . The SDK installation script can be found under tmp/deploy/sdk/poky-eglibc-x86_64-custom-use-image-arm-toolchain-1.8.1.sh

www.timesys.com ©2015 Timesys Corp. 34 Contact Us

. EMEA – Contact Maciej Halasz at: • [email protected] • +48 537 338 080 (direct)

. US – Contact Al Feczko at: • [email protected] Your Trusted Yocto Development Partner • 1.866.392.4897 (toll-free) • +1.412.325.6390 (direct)

. Contact Technical Support at: • https://linuxlink.timesys.com/support

. More Information: • http://www.timesys.com/yocto-project

©2015 Timesys Corp. www.timesys.com