Click here to Skip to main content
15,881,248 members
Articles / Internet of Things
Article

Some hints on Yocto builds for IoT devkit - example: adding Java JRE

17 Oct 2014CPOL4 min read 15K   3  
Recently someone asked me on more documentation about Yocto builds. In particular the person mentioned facing difficulties adding Java to an own IoT Yocto build.

This article is in the Product Showcase section for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

Recently someone asked me on more documentation about Yocto builds. In particular the person mentioned facing difficulties adding Java to an own IoT Yocto build. This conversation triggered the following post:

Why you don't need Yocto builds on your own

First of all: in order to work with the IoT devkit you don't in general have to touch the Yocto build. The devkit provides a prebuilt SD card boot image to put on your Intel(R) Galileo board. And off you go. Additionally there is a package repository from where you can install further packages to your image, i.e. after adding following lines

# cat >> /etc/opkg/iotdk.conf <<EOF

src/gz all http://iotdk.intel.com/ipk/all

src/gz i586 http://iotdk.intel.com/ipk/i586

src/gz clanton http://iotdk.intel.com/ipk/clanton

EOF

to your /etc/opkg/iotdk.conf file as described in http://software.intel.com/sites/default/files/managed/f1/49/building_yocto_and__ipks.pdf (Section "Using the Repository with IOTDL builds") you are ready to use opkg to add further packages from that repository with

# opkg install <package name>

To get the list of packages you can use

# opkg list

Apart from that there is a live image on http://software.intel.com/en-us/iotdevkit including all setup to compile your own binaries for the Galileo target.

How you can do Yocto builds on your own

However, there might be cases where the before mentioned ways don't fully fit your needs and you might want to customize the image or easily build own ipk packages ...

That's where you might want to run Yocto builds on your own. For Yocto starters I'd like to refer to the online documentation on the Yocto project (currently http://www.yoctoproject.org/docs/1.5.1/dev-manual/dev-manual.html). It's not the place here to teach the Yocto concepts. But what I try to achieve is to share some hints to get you started.

Initial Yocto build

If you want to build an image you should have at least 40 GB of disk space available. You need to have installed various development tools like git in order to start using Yocto. To start with the intel-iot-devkit go to http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-iot-devkit/ where you can find the git details for a git clone. On my system I do have the Yocto build root on

YBR = /Quark/meta-intel-iot-devkit/

Note

Apart from the master there are other branches.

You may follow the steps down below to build an image:

  1. check ${YBR}/build/conf/local.conf configuration. You might have to modify the settings for parallel builds
  2. setup the Yocto build environment by sourcing
    source ${YBR}/iot-devkit-init-build-env
    
  3. This will directly change your pwd to ${YBR}/build. There you can now use bitbake to start building e.g.
    bitbake iot-devkit
    
  4. now take a brief (and maybe a coffee) - if there are no issues you will find your ready image in ${YBR}/build/tmp/deploy/images, and the ipk packages in ${YBR}/build/tmp/deploy/ipk resp. Depending on your build system this may take a couple of hours.

 

Check available layers

Yocto uses various so called layers to organize the packages. Various layers you can find available at http://layers.openembedded.org/layerindex/branch/master/layers/.

In our case you can find a meta-oracle-java layer which is a good starting point for the Java package we are going to build. We will use and modify this layer using the steps below. For writing your own layers pls check the Yocto manual.

  1. git clone the layer into ${YBR}.
  2. add the layer to the BBLAYERS variable in ${YBR}/build/conf/bblayers.conf
  3. as Oracle Java comes with a proprietary license you have to whitelist the license in ${YBR}/build/conf/local.conf by adding LICENSE_FLAGS_WHITELIST += "oracle_java"
  4. unfortunately the meta-oracle-java layer seems slightly dated - in particular the direct download link for the JRE doesn't work any longer. It seems you need to accept a license first before you can download the JRE from Oracle. Hence I downloaded the tgz and put it on a local folder. Obviously the URI entry in meta-oracle-java/recipes-devtools/oracle-java/oracle-jse-jre-i586_1.7.0.bb needs to be modified accordingly (In my case SRC_URI = "file:///Quark/meta-intel-iot-devkit/meta-oracle-java/jre-7u51-linux-i586.tgz"). Also the md5 checksums and the LIC_FILES_CHKSUM license hash in meta-oracle-java/recipes-devtools/oracle-java/oracle-jse.inc need to be modified accordingly. Easiest to first leave it unchanged and bitbake will print an error message including the correct new hashs.

After that you should see something like

$ bitbake-layers show-layers

layer                 path                                      priority

==========================================================================

meta                  /Quark/meta-intel-iot-devkit/meta         5

meta-oe               /Quark/meta-intel-iot-devkit/meta-oe      6

meta-iot-devkit       /Quark/meta-intel-iot-devkit/meta-iot-devkit  6

meta-yocto            /Quark/meta-intel-iot-devkit/meta-yocto   5

meta-intel            /Quark/meta-intel-iot-devkit/meta-intel   5

meta-clanton-bsp      /Quark/meta-intel-iot-devkit/meta-clanton-bsp  6

meta-galileo          /Quark/meta-intel-iot-devkit/meta-galileo  9

meta-hob              /Quark/meta-intel-iot-devkit/meta-hob     1

meta-oracle-java      /Quark/meta-intel-iot-devkit/meta-oracle-java  6

And you should be fine to go with

$ ${YBR}/bitbake oracle-jse-jre-i586

On success you will find the new package in ${YBR}/build/tmp/deploy/ipk. You can copy over this package to your system and opkg install it.

After successful installation we now can run Java on the target - here using the mandatory starting point Java classes:

# /usr/jre1.7.0_51/bin/java hello

Hello World

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --