Application Development with Extensible SDK: Difference between revisions

From Yocto Project
Jump to navigationJump to search
No edit summary
Line 6: Line 6:
[https://drive.google.com/a/linaro.org/file/d/0B3KGzY5fW7laTDVxUXo3UDRvd2s/view Yocto Project Developer Workflow Tutorial].)
[https://drive.google.com/a/linaro.org/file/d/0B3KGzY5fW7laTDVxUXo3UDRvd2s/view Yocto Project Developer Workflow Tutorial].)


== How to get devtool? ==
== 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 download an [http://hbruce-desk3.jf.intel.com/iot/files/qemux86/poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-2.1+snapshot.sh qemux86 extensible SDK installer] '''NEED TO FIX THIS LINK''' and install as per [http://www.yoctoproject.org/docs/latest/sdk-manual/sdk-manual.html#sdk-extensible eSDK manual].
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. These come in two flavors; "minimal" and "full". The "minimal" SDK is the preferred option as it comes as a 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" SDK has all the xpmonents prebuit
 
download an [http://hbruce-desk3.jf.intel.com/iot/files/qemux86/poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-2.1+snapshot.sh qemux86 extensible SDK installer] '''NEED TO FIX THIS LINK''' and install as per [http://www.yoctoproject.org/docs/latest/sdk-manual/sdk-manual.html#sdk-extensible eSDK manual].


== Creating a recipe from existing source ==
== Creating a recipe from existing source ==

Revision as of 21:22, 20 May 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. These come in two flavors; "minimal" and "full". The "minimal" SDK is the preferred option as it comes as a 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" SDK has all the xpmonents prebuit

download an qemux86 extensible SDK installer NEED TO FIX THIS LINK and install as per eSDK manual.

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

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. Bug?
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!)

Deploy

[WORK IN PROGRESS]


Back to the Cookbook home page.