This blog was last updated on 4/13/2017. The process for generating the Siemens IOT2000 Yocto image may have changed.
The newly released Siemens IOT2000 series of controllers offer the flexibility of hobbyist Linux or Arduino platforms with the ruggedization necessary for industrial environments. The Siemens boards make use of the Yocto build tool for image creation. A sample image can be downloaded from the Siemens website (after logging in). However, for more involved projects it can be useful to modify the image to fit your application.
The README.md file in the Siemens IOT2000 example repository provides brief descriptions for what is required to build the image, but it can be confusing if you aren't familiar with the Yocto build process. This guide is intended to clarify the process.
Getting Started
Before getting into the Siemens instructions, you'll need to set up a build host. The Yocto Quick Start Guide has a detailed explanation of system requirements including available memory, Linux distribution, and available packages.
One of the layers required by the Siemens instructions has an additional dependency on the build host. You'll need to install g++-multilib
. On Debian based systems the command for this is:
dmc@dmc:/$ sudo apt-get install g++-multilib
Prepare
Once your system is set up, you'll need to clone the poky
Git repository. The current user's home directory is usually a good place for this.
dmc@dmc:/$ cd ~
dmc@dmc:~$ git clone -b krogoth git://git.yoctoproject.org/poky poky
You'll then want to move into the poky
directory that was created to clone the additional Yocto layers we will be using.
dmc@dmc:~/poky$ cd poky
dmc@dmc:~/poky$ git clone -b krogoth git://git.openembedded.org/meta-openembedded
dmc@dmc:~/poky$ git clone -b krogoth git://git.yoctoproject.org/meta-intel
dmc@dmc:~/poky$ git clone git://git.yoctoproject.org/meta-java
dmc@dmc:~/poky$ git clone git://git.yoctoproject.org/meta-intel-iot-middleware
dmc@dmc:~/poky$ git clone git://github.com/siemens/meta-iot2000
dmc@dmc:~/poky$ git clone -b krogoth git://github.com/imyller/meta-nodejs.git
The Siemens Git repository README.md recommends checking out specific commits of a few of these repositories:
dmc@dmc:~/poky$ git checkout yocto-2.1
dmc@dmc:~/poky$ git -C meta-intel checkout 9a06fc5bce05
dmc@dmc:~/poky$ git -C meta-openembedded checkout 247b1267bbe9
dmc@dmc:~/poky$ git -C meta-java checkout 9edf7d5aa5bd
dmc@dmc:~/poky$ git -C meta-intel-iot-middleware checkout 821cf14c8304
Configure
source poky/oe-init-build-env siemens-build
The following commands will create a directory called siemens-build
and move you into that directory. It will also set up some configuration files in that directory. The next few steps will be editing those configuration files.
dmc@dmc:~/poky$ cd ~
dmc@dmc:~$ source poky/oe-init-build-env siemens-build
Add needed layer to bblayers.conf
The bblayers.conf
file tells the Yocto tools where to find all of the repositories you checked out. If you used the commands in the instructions above, you just need to modify the file at ~/siemens-build/conf/bblayers.conf
to look like the following (changes highlighted). Make sure to replace /path/to/
with the path to your user home directory.
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/path/to/poky/meta \
/path/to/poky/meta-poky \
/path/to/poky/meta-yocto-bsp \
/path/to/poky/meta-openembedded/meta-oe \
/path/to/poky/meta-intel \
/path/to/poky/meta-java \
/path/to/poky/meta-intel-iot-middleware \
/path/to/poky/meta-iot2000/meta-iot2000-bsp \
/path/to/poky/meta-iot2000/meta-iot2000-example \
/path/to/poky/meta-nodejs \
"
Set MACHINE
variable in local.conf
The instructions for this step are in the README.md for the Siemens IoT2000 BSP (Board Support Package) repository. The local.conf
files sets parameters for any image that is built on your computer. Add the following line anywhere in the file at ~/siemens-build/conf/local.conf
MACHINE = "iot2000"
Create example image
The bitbake command must be run from the ~/siemens-build directory with all of the environment that were set by the oe-init-build-env script. To be safe, I typically re-run the eo-init-build-env script before running bitbake. It will not overwrite your configuration changes.
dmc@dmc:~/siemens-build$ cd ~
dmc@dmc:~$ source poky/oe-init-build-env siemens-build
dmc@dmc:~/siemens-build$ bitbake iot2000-example-image
This command will take up to an hour the first time it runs.
Booting the image
If the bitbake command finishes without errors, it will generate a file at ~/siemens-build/tmp/deploy/images/iot2000/iot2000-example-image-iot2000.wic
This file contains the image created by bitbake. It is packaged in a way that it can be copied to an SD card and inserted into a Siemens IoT2000 device. You'll need to insert an SD card into your computer and find where you can access it. The lsblk command is useful for this. Run the command before inserting the SD card. After the command has been run, insert the SD card and run the command again. The new device that shows up should be your SD card.
dmc@dmc:~/siemens-build$ lsblk
Now that you know where the SD card, use the dd command to copy the contents of the .wic file to the SD card. In the following example, the SD card was enumerated as /dev/sdb.
dmc@dmc:~/siemens-build$ sudo dd if=~/siemens-build/tmp/deploy/images/iot2000/iot2000-example-image-iot2000.wic of=/dev/sdb
This command can take a few minutes to execute and won't generate any output while it is executing. Once the command is complete, you can eject the SD card and insert it into the Siemens IoT2000 device. Power on the device and connect over SSH.
Common Errors
In a previous version of this post, executing bitbake the first time would return with the following error. The issue has since been resolved in the meta-iot2000 repository.
ERROR: file-native-5.25-r0 do_fetch: Fetcher failure: Unable to find revision f45db89ddc91692b662fffbabbdafc7bc4c00f5e in branch master even from upstream
Yocto needs to know where to download source files for everything it builds. One of the locations defined in the meta-openembedded layer is no longer correct. The Krogoth release that the IoT2000 build process uses is from early 2016, so some of the references are out of date. The revision identified by f45db89ddc91692b662fffbabbdafc7bc4c00f5e
is no longer valid and needs to be replaced with 789cfc7d727cee1c7cfb7d29c09162e2399285c5
. We could make the change at the file ~/poky/meta/recipes-devtools/file/file_5.25.bb
where this reference is defined. The Yocto reference documents recommend instead to create your own layer that overlays the existing layer, so the changes are more traceable. This procedure is as follows:
Create a new layer using the Yocto-layer tool:
dmc@dmc:~/siemens-build$ cd ~/poky
dmc@yocto:~/poky$ yocto-layer create mylayer
You will be prompted with the following line. Just hit enter to accept the default layer priority of 6.
Please enter the layer priority you'd like to use for the layer: [default: 6]
Hit enter again at the second line to skip creating an example recipe.
Would you like to have an example recipe created? (y/n) [default: n]
We would like to create an example bbappend file. So, at the following prompt, type y
and hit enter.
Would you like to have an example bbappend file created? (y/n) [default: n] y
We want the new file to match the naming of the recipe file_5.25.bb we are fixing. So, at the next prompt, type file
and hit enter.
Please enter the name you'd like to use for your bbappend file: [default: example] file
At the next prompt, type the version number as 5.25
and hit enter.
Please enter the version number you'd like to use for your bbappend file (this should match the recipe you're appending to): [default: 0.1] 5.25
The final prompt reminds us to add this new layer to the bblayers.conf file.
New layer created in meta-dmc.
Don't forget to add it to your BBLAYERS (for details see meta-mylayer/README).
So, once again edit the file at ~/siemens-build/conf/bblayers.conf, adding the highlighted line:
/path/to/poky/meta-intel-iot-middleware \
/path/to/poky/meta-iot2000/meta-iot2000-bsp \
/path/to/poky/meta-iot2000/meta-iot2000-example \
/path/to/poky/meta-mylayer \
"
To make the changes that will fix the Error above, edit the file at ~/poky/meta-mylayer/recipes-example-bbappend/example-bbappend/file_5.25.bbappend
Delete the commented lines:
#
# This .bbappend doesn't yet do anything - replace this text with
# modifications to the example_0.1.bb recipe, or whatever recipe it is
# that you want to modify with this .bbappend (make sure you change
# the recipe name (PN) and version (PV) to match).
#
Add the line:
SRCREV = "789cfc7d727cee1c7cfb7d29c09162e2399285c5"
Now the build should complete without errors.