Application Development with Extensible SDK: Difference between revisions

From Yocto Project
Jump to navigationJump to search
Line 134: Line 134:
  devtool modify bbexample
  devtool modify bbexample


 
The edit/build/test cycle is then the same as for adding a recipe.


'''[WORK IN PROGRESS]'''
'''[WORK IN PROGRESS]'''

Revision as of 21:01, 25 August 2016

[WORK IN PROGRESS]

This example describes devtool and how to use it. This tool makes it easier to add new applications and libraries to a Yocto Project image, modify the source for an existing component, test changes on the target hardware, and ease integration into the rest of the OpenEmbedded build system. In short think of devtool as a single point of entry to creating, modifying and testing recipes. Note that devtool cannot add your recipe to a layer nor update your build configuration to include it in a image. These steps will be covered later in the Cookbook. devtool can be used with both the Yocto Project build environment and the Extensible SDK.

(From the Yocto Project documentation: Here's a presentation by Trevor Woerner that, while somewhat dated, provides detailed background information and a complete working Yocto Project Developer Workflow Tutorial.)

How to get devtool

If you have set up the Yocto Project build environment using the Quick Start Guide, you already have access to devtool for qemux86 image.

Alternatively you can install an Extensible SDK (eSDK). These come in two flavors; "minimal" and "full". The "minimal" eSDK is the preferred option as it comes as a small 30Mb installer and downloads the components it needs depending on requirements of application project. The installer contains the URL of an sstate mirror so it does not no need to build all dependencies from source code. The "full" eSDK contains all the components already built so is much larger (similar in size to traditional SDK, i.e. at least 1GB). The Yocto SDK Manual contains more details on installing and using the eSDK.

Currently the Yocto Project autobuilder only builds "full" eSDKs. The qemux86 full eSDK can be found here. There is a feature enhancement request for the autobuilder to create minimal eSDKs.

In the meantime, an experimental minimal qemux86 eSDK can be found here.

Creating a recipe from existing source

Let's say you have a C application that you want to add to your OS image. Assume repo is https://github.com/whbruce/bbexample.git and you want to name recipe (and thus the executable it creates) bbexample.

devtool add bbexample https://github.com/whbruce/bbexample.git

You will see the following output

NOTE: Creating workspace layer in /path/to/build/workspace
NOTE: Enabling workspace layer in bblayers.conf
NOTE: Using default source tree path /path/to/build/workspace/sources/bbexample
NOTE: Recipe /path/to/build/workspace/recipes/bbexample/bbexample_git.bb has been automatically created; further editing may be required to make it fully functional

Key entries here are the location of the source code in /path/to/build/workspace/sources/bbexample. Note that git will create a branch named devtool for your work. The recipe is in /path/to/build/workspace/recipes/bbexample/bbexample_git.bb
You can now look at the generated recipe with

devtool edit-recipe bbexample

We'll take a look at what's in the recipe. Comments and whitespace have been removed for easier reading

LICENSE = "Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=96af5705d6f64a88e035781ef00e98a8"
SRC_URI = "git://github.com/whbruce/bbexample.git;protocol=https"
# Modify these as desired
PV = "0.1+git${SRCPV}"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
inherit autotools
EXTRA_OECONF = ""

Let's go through the bitbake commands and variables in the recipe and explain what they do:

LICENSE
The type of licence. This is set to unknown as devtool cannot recognize the old MIT text.
LIC_FILES_CHKSUM
devtool looks in the root of the source folder for a file called LICENCE and generates a checksum so ensure checkout has been successful.
SRC_URI
The git repo given in the 'devtool add' command. This is where the source will be pulled from.
PV
The package version. Usually taken from recipe filename (e.g. bbexample_0.1.bb would automatically set PV = "0.1")
SRCREV
the git revision to checkout. ${AUTOREV} means HEAD and must be used during app development. It should be set a specific commit before being added to a layer.
S
Where the source can be found after being fetched and unpacked.
inherit autotools
Use a bitbake class that can configure, build and install an autotools project
EXTRA_OECONF
Options to be passed to configure script. In this case it is empty, so is not necessary.

Building

$ devtool build bbexample
Parsing recipes: 100% |#########################################| ETA:  00:00:00
Parsing of 872 .bb files complete (0 cached, 872 parsed). 1302 targets, 47 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies
NOTE: Preparing RunQueue
NOTE: Checking sstate mirror object availability (for 51 objects)
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: bbexample: compiling from external source tree /path/to/esdk/workspace/sources/bbexample
NOTE: Tasks Summary: Attempted 342 tasks of which 336 didn't need to be rerun and all succeeded.

This build command runs bitbake just as in a full Yocto Project OS image build. The key line in the output is Checking sstate mirror object availability (for 51 objects). As the extensible SDK installer gives you a minimal build environment it has to download all the dependencies (e.g. native build tools and necessary target libraries). Here 51 objects have been found and are downloaded in their pre-built state greatly speeding up the build process (i.e. we just run 342 tasks of which 336 didn't need to be rerun). This is the extensible part of the SDK in action.

Deploying

Before deploying, the target must be running have a network connection and an ssh server running. In the case, we'll assume the qemux86 target is running.

$ devtool deploy-target -s bbexample root@192.168.7.2
Parsing recipes..done.
devtool_deploy.list                           100%  167     0.2KB/s   00:00    
devtool_deploy.sh                             100% 1002     1.0KB/s   00:00    
./
./usr/
./usr/bin/
./usr/bin/bbexample
./usr/include/
./usr/include/bbexample.h
./usr/lib/
./usr/lib/libbbexample.so.1
./usr/lib/libbbexample.so
./usr/lib/libbbexample.so.1.0.0
./usr/lib/libbbexample.la
NOTE: Successfully deployed /path/to/esdk/sdk/tmp/work/i586-poky-linux/bbexample/0.1+git999-r0/image

Running

root@qemux86:~# bbexample
Hello Yocto World...
Hello World (from a shared library!)

Build Image

To test the updated OS image that now includes your application, you can build it as follows. If you are in a eSDK environment, devtool will automatically build the image used to create the SDK. If in the standard build environment you must specify an image.

devtool build-image [image-name]

Output will be follows

Parsing recipes..done.
NOTE: Building image core-image-minimal with the following additional packages: bbexample
Loading cache: 100% |###########################################| ETA:  00:00:00
Loaded 1302 entries from dependency cache.
Parsing recipes: 100% |#########################################| Time: 00:00:00
Parsing of 872 .bb files complete (870 cached, 2 parsed). 1302 targets, 49 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.30.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "universal"
TARGET_SYS        = "i586-poky-linux"
MACHINE           = "qemux86"
DISTRO            = "poky"
DISTRO_VERSION    = "2.1"
TUNE_FEATURES     = "m32 i586"
TARGET_FPU        = ""
meta              
meta-poky         
meta-yocto-bsp    = "krogoth:f7b994b75261550faa3ccf9005fc174950c7bee9"
workspace         = "<unknown>:<unknown>"

NOTE: Preparing RunQueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
bbexample-0.1+git999-r0 do_compile: NOTE: bbexample: compiling from external source tree /path/to/build/workspace/sources/bbexample
NOTE: Tasks Summary: Attempted 2062 tasks of which 2046 didn't need to be rerun and all succeeded.
NOTE: Successfully built core-image-minimal. You can find output files in /path/to/build/tmp/deploy/images/qemux86

Publish Recipe

Once application has been tested, you can make the recipe available. It will be in /path/to/build/workspace/recipes/bbexample. Make sure you add a version tothe filename (e.g. bbexample_1.0.bb)


Update Existing Recipe

Updating a recipe is similar to creating one, but instead iof using devtool add we use the modify command.

devtool modify bbexample

The edit/build/test cycle is then the same as for adding a recipe.

[WORK IN PROGRESS]


Back to the Cookbook home page.