Yocto Project Application Developer's Guide Is for the 1.4.3 Release of the Yocto Project
Total Page:16
File Type:pdf, Size:1020Kb
Jessica Zhang, Intel Corporation <[email protected]> by Jessica Zhang Copyright © 2010-2014 Linux Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales [http://creativecommons.org/licenses/by-sa/2.0/uk/] as published by Creative Commons. Manual Notes • This version of the Yocto Project Application Developer's Guide is for the 1.4.3 release of the Yocto Project. To be sure you have the latest version of the manual for this release, go to the Yocto Project documentation page [http://www.yoctoproject.org/documentation] and select the manual from that site. Manuals from the site are more up-to-date than manuals derived from the Yocto Project released TAR files. • If you located this manual through a web search, the version of the manual might not be the one you want (e.g. the search might have returned a manual much older than the Yocto Project version with which you are working). You can see all Yocto Project major releases by visiting the Releases [https://wiki.yoctoproject.org/wiki/Releases] page. If you need a version of this manual for a different Yocto Project release, visit the Yocto Project documentation page [http://www.yoctoproject.org/ documentation] and select the manual set by using the "ACTIVE RELEASES DOCUMENTATION" or "DOCUMENTS ARCHIVE" pull-down menus. • To report any inaccuracies or problems with this manual, send an email to the Yocto Project discussion group at [email protected] or log into the freenode #yocto channel. Table of Contents 1. Introduction ............................................................................................................................ 1 1.1. The Application Development Toolkit (ADT) .................................................................. 1 1.1.1. The Cross-Development Toolchain ..................................................................... 1 1.1.2. Sysroot ............................................................................................................. 1 1.1.3. Eclipse Yocto Plug-in ......................................................................................... 1 1.1.4. The QEMU Emulator ......................................................................................... 2 1.1.5. User-Space Tools ............................................................................................... 2 2. Preparing for Application Development ................................................................................... 3 2.1. Installing the ADT and Toolchains ................................................................................ 3 2.1.1. Using the ADT Installer ..................................................................................... 3 2.1.2. Using a Cross-Toolchain Tarball .......................................................................... 5 2.1.3. Using BitBake and the Build Directory ............................................................... 6 2.2. Setting Up the Cross-Development Environment .......................................................... 7 2.3. Securing Kernel and Filesystem Images ....................................................................... 7 2.3.1. Getting the Images ........................................................................................... 7 2.3.2. Extracting the Root Filesystem .......................................................................... 8 3. Optionally Customizing the Development Packages Installation ............................................... 9 3.1. Package Management Systems .................................................................................... 9 3.2. Configuring the PMS .................................................................................................... 9 4. Using the Command Line ..................................................................................................... 11 4.1. Autotools-Based Projects ............................................................................................ 11 4.1.1. Creating and Running a Project Based on GNU Autotools ................................. 11 4.1.2. Passing Host Options ...................................................................................... 13 4.2. Makefile-Based Projects ............................................................................................. 13 iii Chapter 1. Introduction Welcome to the Yocto Project Application Developer's Guide. This manual provides information that lets you begin developing applications using the Yocto Project. The Yocto Project provides an application development environment based on an Application Development Toolkit (ADT) and the availability of stand-alone cross-development toolchains and other tools. This manual describes the ADT and how you can configure and install it, how to access and use the cross-development toolchains, how to customize the development packages installation, how to use command line development for both Autotools-based and Makefile-based projects, and an introduction to the Eclipse™ IDE Yocto Plug-in. Note The ADT is distribution-neutral and does not require the Yocto Project reference distribution, which is called Poky. This manual, however, uses examples that use the Poky distribution. 1.1. The Application Development Toolkit (ADT) Part of the Yocto Project development solution is an Application Development Toolkit (ADT). The ADT provides you with a custom-built, cross-development platform suited for developing a user-targeted product application. Fundamentally, the ADT consists of the following: • An architecture-specific cross-toolchain and matching sysroot both built by the OpenEmbedded build system. The toolchain and sysroot are based on a Metadata [http://www.yoctoproject.org/ docs/1.4.3/dev-manual/dev-manual.html#metadata] configuration and extensions, which allows you to cross-develop on the host machine for the target hardware. • The Eclipse IDE Yocto Plug-in. • The Quick EMUlator (QEMU), which lets you simulate target hardware. • Various user-space tools that greatly enhance your application development experience. 1.1.1. The Cross-Development Toolchain The Cross-Development Toolchain [http://www.yoctoproject.org/docs/1.4.3/dev-manual/dev- manual.html#cross-development-toolchain] consists of a cross-compiler, cross-linker, and cross- debugger that are used to develop user-space applications for targeted hardware. This toolchain is created either by running the ADT Installer script, a toolchain installer script, or through a Build Directory [http://www.yoctoproject.org/docs/1.4.3/dev-manual/dev- manual.html#build-directory] that is based on your Metadata configuration or extension for your targeted device. The cross-toolchain works with a matching target sysroot. 1.1.2. Sysroot The matching target sysroot contains needed headers and libraries for generating binaries that run on the target architecture. The sysroot is based on the target root filesystem image that is built by the OpenEmbedded build system and uses the same Metadata configuration used to build the cross- toolchain. 1.1.3. Eclipse Yocto Plug-in The Eclipse IDE is a popular development environment and it fully supports development using the Yocto Project. When you install and configure the Eclipse Yocto Project Plug-in into the Eclipse IDE, you maximize your Yocto Project experience. Installing and configuring the Plug-in results in an environment that has extensions specifically designed to let you more easily develop software. These extensions allow for cross-compilation, deployment, and execution of your output into a QEMU emulation session. You can also perform cross-debugging and profiling. The environment also supports a suite of tools that allows you to perform remote profiling, tracing, collection of power data, collection of latency data, and collection of performance data. 1 Introduction For information about the application development workflow that uses the Eclipse IDE and for a detailed example of how to install and configure the Eclipse Yocto Project Plug-in, see the "Working Within Eclipse [http://www.yoctoproject.org/docs/1.4.3/dev-manual/dev-manual.html#adt- eclipse]" section of the Yocto Project Development Manual. 1.1.4. The QEMU Emulator The QEMU emulator allows you to simulate your hardware while running your application or image. QEMU is made available a number of ways: • If you use the ADT Installer script to install ADT, you can specify whether or not to install QEMU. • If you have downloaded a Yocto Project release and unpacked it to create a Source Directory [http://www.yoctoproject.org/docs/1.4.3/dev-manual/dev-manual.html#source-directory] and you have sourced the environment setup script, QEMU is installed and automatically available. • If you have installed the cross-toolchain tarball and you have sourced the toolchain's setup environment script, QEMU is also installed and automatically available. 1.1.5. User-Space Tools User-space tools are included as part of the distribution. You will find these tools helpful during development. The tools include LatencyTOP, PowerTOP, OProfile, Perf, SystemTap, and Lttng-ust. These tools are common development tools for the Linux platform. • LatencyTOP: LatencyTOP focuses on latency that causes skips in audio, stutters in your desktop experience, or situations that overload your server even when you have plenty of CPU power left. You can find out more about LatencyTOP at https://latencytop.org/.