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

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® 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 subtituting the version number for <version>:


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

	src/gz all http://iotdk.intel.com/repos/<version>/ipk/all

	src/gz i586 http://iotdk.intel.com/repos/<version>/ipk/i586

	src/gz quark http://iotdk.intel.com/repos/<version>/ipk/quark

	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

	

 

 

 

 

For more complete information about compiler optimizations, see our Optimization Notice.

4 comments

Top
Matthias H. (Intel)'s picture

Hi Stefano,

I guess you installed the GuestAdditions? I do have 1600x1200, or 1920x1080 display resp and also only get 4:3 by default. But running 1440x1050 is fine for me. You should however be able to modify the xorg.conf. Alternatively you might VNC into your virtual machine and get a higher resolution that way.

On installing vs live image: The idea of providing the live image is to reduce the burden setting up tools, ... but provide a fully setup development environment. Surely you can setup your own development system but you'll have to set up everything on your own then.

Regards,
Matthias
 

Stefano Romano D.'s picture

Matthias,

thank you for the clarity you're bringing to this platform. I believe it was me who asked you at the "Getting started with Intel Galileo" session in Rome. I'm very impressed you remembered the issue and answered here. After a few months of slow uptake, things are really starting to pick up and the repositories and devkit are very very welcome. One question I would like to ask you, since I have followed your advice to run the devkit in a Virtualbox VM. Is it possible to actually install it in the VM rather than firing it up as a live install, so that I can try to solve certain issues? For example, I have a hard time figuring out the correct full-screen resolution (my display is 1920x1080 but all I get is 4:3 options). I suspect that there is a daemon-run configuration when it starts and installing Virtualbox guest-additions doesn't change the situation.

All the best

Stefano

BOB RAPHTONE A.'s picture

wooh this is really helpful  especially to java geeks soon we will just port our code and bring the nice ui

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.