Building an Eclipse target platform for the Raspberry Pi

It’s now been a bit over a year since a wrote about running Eclipse RCP projects on a Raspberry Pi. Since then something really exiting has taken place. Tim Webb and Jed Anderson of Genuitec has published PiPlug; a runtime and deployment tool for hosting SWT applications on Raspberry Pi. As you might have guessed PiPlug uses a small subset of the Eclipse platform, about 5.2MiB. This includes the Equinox launcher compiled for ARM. Incidentally that is the same binary I created when writing my blog post. Anyway, the reason I’m exited is that this is a really neat way of running Java UI code on the Raspberry Pi. It is very simple: Start the PiPlug agent on the target, write your code in Eclipse and use the deployment view to push your stuff. It does not get easier than that!

However, not everything is straight out of the box. I have a tiny resistive touch LCD screen that I want to use. And I want PiPlug to adapt to the small resolution (320×240 pixels). Currently it is mostly suited to much larger resulutions. So I need to amend the PiPlug code to support this screen, then rebuild it. In order to do that I must have an Eclipse target platform with all the bits in place so that I can build my forked version of PiPlug. This gave me a reason to revisit my previous work. The instructions I wrote last year no longer works due to changes in the base repositories and the build process. So I’ve done a recap and simplified everything. The source code has been updated to the latest from Eclipse 4.4 (aka Luna) and the changes I’ve done have been squashed to exactly one commit for each repository, making it easier to follow. I’ve also created patches for these repositories. So when you run the script it will clone Eclipse from the source proper, then apply the patches before building – very straightforward. Note that the script is written for Bash.

Running the script will as before create a target platform with the ARMv6 little endian binaries to use for PiPlug or another Eclipse RCP application on the Raspberry Pi. The git repo with all the code is at But in order to save you the time it takes to build, I’ve already created the repository which you can use. You’ll find it in the release section of the above mentioned project page. Simply download and set as target platform.

The SWT and Equinox binary bundles you want all contain the segment “armv6l”. So you should add these to the feature or product definition. Note that the export product command in Eclipse PDE is a bit limited and will not work. You should probably set up a Tycho build for you project in order to create a Raspberry Pi distribution of it.

That’s it. Now I’m off to play around with PiPlug and the Sensiron SHT15 I have attached to my RPi 🙂

Scanning woes revisited: A Raspberry Pi scanning machine

I‘ve decided to go paperless (as much as I can anyway). Nearly 20 years worth of various documents must be scanned – then saved to a safe place and the unimportant papers shredded. This pile of documents is pretty tall and I don’t really want to feed the scanner for days, so some ingenuity is required. As any decent software developer I hate doing the same thing over and over again so here was a chance to let the geek in me take over.

One of my old scanners, still waiting to be recycled, actually does have a document feeder. Even though I still would have to feed it, using it could make the job bearable. Or maybe not. The scanning software is not very good. So from the computer I would have to manually operate the program, handle each document and place the file in the destination folder.

Four years ago I wrote a bash script to automate scanning to PDF. It would handle a multi page document, which is nice. But the number of pages in each document had to be typed in. In this case most documents would have one page and some would have multiple. So this script would have to be elaborated upon. The basic idea was to do something like this:

  • Keep on scanning while there are sheets in the ADF.
  • One sheet of paper equals one page. Sheets are not turned.
  • Somehow detect that pages belong in the same document.
  • Convert each document to PDF.

The pixma_scan application that I used the previous time would have to be amended in order to be able to detect whether or not there are sheets in the ADF without actually scanning. So I did a minor tweak to the program allowing it to be used in this way. The code is available on GitHub. I also had to change the Bash script a bit to take advantage of this feature.

Raspberry Pi to the rescue

The Automatic Document Feeder (ADF) of the Pixma MP780 does not hold a lot of paper but it would still take quite some time to scan and convert a full ADF. I also don’t want to keep my laptop busy doing this work so I decided to utilize a Raspberry Pi. It runs Linux, so the scanning application would probably work. The same goes for the utilities the script calls for image manipulation. I had to change this script a bit and the initial test showed that this could work.

Detecting multi-page documents

Another good thing about using the Rapberry Pi is that I could make use of the camera module to detect whether or not a page should be in the same document as the current. I figured it would be possible to some degree of accuracy to analyze a portion of the image and detect whether or not it contains a marker. The images below show two documents with the marker placed in the bottom right corner of the sheet and one without.


Using the convert utility of Imagemagick I was able to detect whether or not the image was mostly black or white. If it was mostly black the document belongs to the current document and should be appended. The problem that blocked progress was that the ADF could not be trusted to place the sheet of paper in the same position every time. I could probaly get it working if I put black separator sheets in between documents. However I did not continue down this path; as I it would take some time to tune and I am still able to merge PDF files after they have been scanned if need be.


This set-up has proved to be quite useful. It has so far scanned 68 documents in about one hour and half, which would take far longer to do manually. I still have to sort all the document files and place them where they belong. But at least I have a digital copy.

Now I’ll drop a stack at the ADF and get some Battlefield 4 quality time 🙂

Running Eclipse RCP applications on a Raspberry Pi

My previous Raspberry Pi related blog post was about running the Eclipse Orion server. This time I wanted to run a more demanding Eclipse RCP (Rich Client Platform) application and decided to use the better performing hard float “Wheezy” distribution of Raspbian.

As Java 7 is not available in the required flavour I also have to use the early access version of Java 8. The procedure of installing both of these is pretty identical to what I described in my previous post, so I’m not wasting time on documenting it. You’re probably able to figure it out.

Now, Eclipse RCP applications are, as I think you already know; Java GUI applications with native widgets, OSGi and what not. So JNI binaries for the platform have to be present. In this case binaries for 32-bit ARM (v6 little endian) Linux using the GTK windowing system. The crux of this experiment is that these binaries are not readily available. The source code must possibly be ported and at least compiled for the architecture in question before it can be used in an RCP application. Also, for the sake of sanity, it would be better if everything was available in a Equinox p2 repository to use as target platform.

Building SWT native libraries

This part describes how to build the native libraries for Raspberry Pi. However there is no real reason why everyone should have to do this – so you may just jump to the last section if you want to get started on writing applications.

Now, the Common Build Infrastructure (CBI) does offer an option to build natives on preconfigured hosts – I did not explore that option. I suspect that it should be fairly straightforward once one figure out where to do the configuration. Meanwhile this part is done manually.

Follow the instructions for using SWT from Git. Import the org.eclipse.swt project, make sure you change the .classpath_gtk to .classpath and built it. This should result in a new bin folder which contains source code for the SWT native libraries.

I grasped from the SWT documentation that the SWT JNI libraries are not simply cross compiled, so we would probably be better off just building them on the Raspberry Pi. Easy does it. In order to do so we must install a few required development packages:

This will just give you the minimum of SWT libraries – there are more that can be built.

Now, copy the entire org.eclipse.swt project from your host to the Raspberry Pi. Then on the Pi execute:

This will compile the SWT JNI libraries for the ARM v6 little endian architecture. After a while we should have a few static libraries available:

These are the files that are used by Java to render Gtk widgets when running SWT on a Raspberry Pi. You could create a new fragment bundle in eclipse.platform.swt.binaries named org.eclipse.swt.gtk.linux.armv6l, place the binaries in there and rig it all up.

Building the Equinox launcher

The Equinox launcher is not really required for this experiment. However it does make launching Eclipse based applications much easier as we get a proper native executable to use. The problem is that CBI appears to expect a launcher to be present for all architectures when building. So let’s indulge it.

Like the SWT there appears to be some rigging in place to do the native building on preconfigured hosts. However this part is even more straightforward than for SWT.

I’ve already done the work with adding the armv6l bundle so the only thing that must be done is to build the native code.

You should now have one eclipse executable and one that must be placed in certain locations in the rt.equinox.binaries project. Again – I’ve already done that. You’ll find everything over at GitHub.

Building Eclipse

Now we need to build the Eclipse Platform in order to get a p2 repository to use as target repository. You’ll also get the Eclipse SDK product builds for various platforms. I’ve written a script that will do just that. It uses a customized version of eclipse.platform.releng.aggregator, with the addition of a few other bundles with the ARMv6 support. (The wonders of git submodule is at play here).

Execute this script and after a few hours you should now have an Eclipse SDK in eclipse.platform.releng.aggregator/eclipse.platform.releng.tychoeclipsebuilder/sdk/target/products you should now find org.eclipse.sdk.ide-linux.gtk.armv6l.tar.gz. The target platform is at eclipse.platform.releng.aggregator/eclipse.platform.releng.tychoeclipsebuilder/rcp.sdk/target/repository.

I decided to try it all out by running the one RCP application I have ready, the Eclipse SDK. It is actually barely usable – but you could do small projects. I would not recommend doing your development in this way though, but a far less demanding RCP application would probably work OK. That’s what the target platform repository is for.

Have fun!

Running Eclipse Orion on a Raspberry Pi

Last week I joined the company of about a million others and became the proud owner of a Raspberry Pi. I got it just for fun; write some software and maybe make use of the GPIO ports.

I already knew I wanted to do something Eclipse related with this quite capable device, so why not run Eclipse Orion (Tools for the web, on the web) on it? During my research I discovered that someone already did that. Ken Walker of IBM Canada/Orion Project even demonstrated such a set-up as a teaser for a talk at last year´s EclipseCon Europe. Now he used the Node.js port of Orion – I had in mind to use the full package. Note that Ken also has a talk on the subject at this year’s EclipseCon in Boston.

Installing Linux

Support for software floating point is required for Java; so we have to pick a Linux distribution that provides this. The Soft-float Debian “wheezy” is a good choice. Note that I had trouble getting the image downloaded from the torrent to work. The direct download of the zip file was OK. Compare the SHA1 hashes to make sure.

Now we need to write the disk image to the SD card. First you must figure out where the card is mounted. On my MBP this is /dev/disk2. We must first unmount it. Note that these instructions are for OS X, if you’re on Linux there are some differences. If you’re on Windows you’re on your own. Sorry about that.

We can now write the image. Execute the command below and be prepared to wait for quite a while. All depending on the performance of your SD-card.

When done, insert the SD-card, connect the Ethernet cable and USB power. The green LED should start blinking and after a while all LEDs should be on. This means you should be able to log into a shell on the device. First you need to figure out it’s IP-address. You can do this from the terminal if you have a screen and keyboard hooked up. I used the nifty iNet iOS application for that and found

Enter the default password (“raspberry”) and you should be greeted with a welcome message. The shell prompt will also change, indicating that you’re now logged in as pi on raspberrypi. We should start with some initial setting up.

Install mDNS

Now, would it not be nice if we could access the Raspberry Pi without having to remember it’s IP-address (and without having to set up a DNS server)? We can do this by making use of multicast DNS (mDNS).

Now the Raspberry Pi can be accessed using it’s name. Try it:

Upgrade software and kernel

Things move fast in the open source world so the software that comes with the Raspberry Pi is unlikely to be up to date. Hence we should upgrade to the latest version of both the software and the kernel.

Expand root partition

In order to make more room we can make the root partition expand to fill the entire SD-card, start raspi-config. Select expand_rootfs then exit and reboot.

Wait a bit and log in again. The root partition should be much larger than the 1.8GB default.

Configure RAM

If you got your Raspberry Pi recently you probably have one with 512MB RAM, but all of that memory is not necessarily available. Check the memory chip to see which type you have and run free -h to see if the memory is there. My Raspberry Pi is a 512MB variant, but reported only 231MB available. In order to fix this we need to update the firmware. Thankfully we can make use of a nice script to do this.

As we’re going to use the Raspberry Pi without a graphical user interface it may be a good idea to limit the GPU memory to 16MB, this will allow applications to use more. Edit /boot/config.txt and add gpu_mem=16 to the bottom of the file. Now we need to restart again. After the device has booted we should see a lot more memory.

Install Java

At this point we’re ready to start installing the additional stuff. The Oracle download pages have been cleverly designed so that they are pretty impossible to use with a command line client. Hence you’ll have to pick the archive using your favourite web browser and transfer it to your Raspberry using SSH. Download the Java SE Embedded 7 , EABI, VFP, SoftFB ABI, Little Endian version and transfer it.

You should know how to log into the Raspberry Pi by now. Do that again (unless you’ve cleverly kept the terminal window open) and execute the following:

The last command should reveal something like this:


Installing Eclipse Orion

Eclipse Orion can be found at the projects website. I picked the 1.0 release for 32-bit Linux and downloaded it to my workstation. Use scp again to copy it to your home folder on the Raspberry Pi.

Eclipse Orion can launch stand-alone websites, which is quite useful for testing your work. However we need to use virtiual host names for these sites. This is done by setting the property in the server configuration file. Create a file named orion.confand add the following:

All sites will now be created on the form .raspberrypi.local. We’re going to start the “Hello World” example project so we’ll need a CNAME alias for this:

Now we’re ready to start Eclipse Orion

It will take some time to start. When everything looks good, open your web browser and enter the address to the running Eclipse Orion instance. It’s running on port 8080 (http://raspberrypi.local:8080/). You should be greeted by a welcome page. Create an account and log in.

Click Sample HTML5 Site and leave the defaults as they are. Simply click Submit in the dialog that pops up. Now go to Sites and create a new site. Name this one “hello” and add the “Hello World” project to it. You can now start the site and view the example project using http://hello.raspberrypi.local:8080/index.html.

That was fun! Now it’s time to read getting started with Orion