For a while, I've had in my possession this interesting little SBC.
It's reasonably well-specced, with a dual-core Cortex-A7 CPU, 512MB of RAM and built-in 4GB flash. It even has a built-in Lipo battery charge controller.
It was actually sent to me by mistake in place of a cheaper model, but the Olimex guys were super cool about it and told me to keep the more expensive model :) .
My two main gripes with it are:
- The very tiny GPIO pins, of which there are many, are somewhat hard to work with.
- The somewhat brittle onboard flash; I really wouldn't recommend running a normal filesystem on here, even with the wear-levelling. I could use a slightly better filesystem like JFFS2 or F2FS, but it's not a priority as I have a fairly large MicroSD card in there which I use for everything.
The lack of native Bluetooth and Wifi is a shame, though this isn't too annoying as I have some adapters for that.
Kura is an OSGi-based application container and service stack for IoT edge devices. Out of the box, it includes services to take care of deployment, configuration and networking, along with more interesting parts for things like Bluetooth and also a neat Web GUI.
The deployed unit (think 'App') is an OSGi 'bundle'. This takes the form of a Jar file with some important properties in its MANIFEST.MF file and as usual, contains Java classes.
The OSGi framework's job is loading bundles, resolving and injecting dependencies and managing the bundles' lifecycle.
Ultimately, I want to get Kura running nicely on the OLinuXino stock debian image, network management and all. I'm short on time today however, so for now we'll just acquaint ourselves with the build system by building an image for the already-supported Raspberry Pi 2.
The vast majority of Kura is written in Java and is reasonably platform-independent, so there shouldn't be too much work involved in getting it running on the new board. I'm guessing It'll mostly involve playing with Maven and ant/bash scripts until we get something which builds and installs correctly.
The dev environment:
- Linux Mint 17 (any modern Ubuntu derivative 'should' work)
- Maven 3
- Java 7 JDK
First, I'll clone Kura from its github repository:
lee@terra:~$ mkdir olinuxino-kura lee@terra:~$ cd olinuxino-kura lee@terra:~/olinuxino-kura$ git clone https://github.com/eclipse/kura Cloning into 'kura'...
After a while, we should have our copy of the Kura repo.
Following the official build guide, we start by building the target platform; this is a collection of library jars which Kura considers to be the 'platform', rather than normal services. Things like slf4j, usb4java and Paho MQTT client which will always be there.
lee@terra:~/olinuxino-kura/kura/target-platform$ mvn -Dmaven.test.skip=true clean install [INFO] Scanning for projects...
After the typical flurry of noise generated by maven while doing its thing, we read 'BUILD SUCCESS' and breathe a sigh of relief.
What this actually did was build a couple of maven repositories, 'p2-repo-common' and 'p2-repo-equinox_3.8.1'. You can also see the built repositories were copied to somewhere inside the 'kura' directory of the repository, as part of the process:
[mkdir] Created dir: /home/lee/olinuxino-kura/kura/kura/target-definition/common/repository [copy] Copying 28 files to /home/lee/olinuxino-kura/kura/kura/target-definition/common/repository ... ... [mkdir] Created dir: /home/lee/olinuxino-kura/kura/kura/target-definition/equinox_3.8.1/repository [copy] Copying 38 files to /home/lee/olinuxino-kura/kura/kura/target-definition/equinox_3.8.1/repository
We can now forget about the target-platform directory for the time being, and build the guts of kura:
lee@terra:~/olinuxino-kura/kura/target-platform$ cd ../kura/ lee@terra:~/olinuxino-kura/kura/kura$ ls distrib org.eclipse.kura.core.status org.eclipse.kura.net.admin emulator org.eclipse.kura.core.test org.eclipse.kura.protocol.can ... ...
These org.eclipse.* directories are all Java bundles waiting to be built. There's also the target-platform directory which isn't a bundle, but is still important. You'll also notice there appear to be two POMs,
manifest_pom.xml builds almost all of the bundles under 'kura', whereas
pom_pom.xml builds the kura web interface, CAN service bundle and also the 'distrib' module, which represents the installer. First we build the
lee@terra:~/olinuxino-kura/kura/kura$ mvn -Dmaven.test.skip=true -f manifest_pom.xml clean install [INFO] Scanning for projects...
After much more maven output, this completed in just under 2 minutes on my laptop.
Now we do the same for
pom_pom.xml, requesting the web, raspberry-pi-2 and dev-env profiles be activated:
lee@terra:~/olinuxino-kura/kura/kura$ mvn -Dmaven.test.skip=true -f pom_pom.xml -Pweb,raspberry-pi-2,dev-env clean install [INFO] Scanning for projects...
The Web UI accounts for a sizeable chunk of kura and takes a bit more work. I actually got out-of-memory errors the first time I ran this process, and had to shut down some programs. Almost 3 minutes for the whole build in my machine.
Assuming everything went well, we now have a bunch of interesting files in the 'distrib/target' directory:
lee@terra:~/olinuxino-kura/kura/kura$ cd distrib/target/ lee@terra:~/olinuxino-kura/kura/kura/distrib/target$ ls -l *.sh *.zip *.deb -rw-r--r-- 1 lee lee 5768 May 14 20:06 extract_upgrade.sh -rw-r--r-- 1 lee lee 48921482 May 14 20:06 kura_2.0.0-SNAPSHOT_raspberry-pi-2_installer.deb -rwxr-xr-x 1 lee lee 48915146 May 14 20:06 kura_2.0.0-SNAPSHOT_raspberry-pi-2_installer.sh -rwxr-xr-x 1 lee lee 37729205 May 14 20:06 kura_2.0.0-SNAPSHOT_raspberry-pi-2_upgrader.sh -rw-r--r-- 1 lee lee 37738544 May 14 20:06 kura_2.0.0-SNAPSHOT_raspberry-pi-2_upgrade.zip -rw-r--r-- 1 lee lee 48932823 May 14 20:05 kura_2.0.0-SNAPSHOT_raspberry-pi-2.zip -rw-r--r-- 1 lee lee 2489264 May 14 20:05 org.tigris.mtoolkit.sdk-3.1.8-20110411-0918.zip -rw-r--r-- 1 lee lee 57216870 May 14 20:05 user_workspace_archive_2.0.0-SNAPSHOT.zip
We have a deb, an installer.sh, an upgrader.sh, and a user workspace archive. The latter is actually the 'dev-env' we asked for earlier, and can be unzipped to provide an eclipse PDE workspace complete with a kura emulator, for developing and debugging kura bundles.
That's it for today. Hopefully this has been an insightful trip through the Kura build system. When we come back to this, we'll need go a bit deeper to create a custom profile for the OLinuXino.