Running OSGi on the Nokia N800

Roll up your sleeves ...

Right now, Java on the N800 is purely a command line affair, i.e. no Maemo GUI integration exists as yet. Prepare your N800 first by doing these steps

  • Set your N800 up for ssh access by installing openssh.
  • Install wget and unzip.
  • For easier typing, from a PC using your preferred ssh client, ssh into N800 as root (factory default password is 'rootme')
  • If you have issues with installing these with the N800 Application Manager, try enabling its Red Pill Mode.

Setup Java CDC/FP 1.1 VM

Get OSGi core

For simplicity and consistency of the instructions below, let's assume you've installed the Java CDC/FP vm into /cdc and will install your OSGi bits into /osgi .

There are lots of open-source and commercial OSGi implementations. I chose Equinox but I've had no problem using others like Knopflerfish as well. Because OSGi can load bundles directly from the web URLs, you can start OSGi in a minimal mode locally on the N800 and work from there. So to get started download the latest Equinox OSGi core into /osgi . The current stable Equinox OSGi core at the time of writing the page is this one.

Nokia-N800-11:/# cd /osgi
Nokia-N800-11:/osgi# wget
=> `org.eclipse.osgi_3.2.2.R32x_v20070118.jar'
Connecting to||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 873,526 (853K) [text/plain]
100%[================================================================>] 873,526 233.97K/s ETA 00:00
18:39:14 (222.75 KB/s) - `org.eclipse.osgi_3.2.2.R32x_v20070118.jar' saved [873526/873526]<

Start OSGi Core

Just like it is described in the Equinox Quickstart guide only now with the cvm command instead of java, as root run

Nokia-N800-11:/# cd /osgi
Nokia-N800-11:/osgi/# /cdc/bin/cvm -jar ./org.eclipse.osgi_3.2.2.R32x_v20070118.jar -console

You should now see the osgi console


Run 'ss' to get a short status

osgi> ss
Framework is launched.
id State Bundle
0 ACTIVE system.bundle_3.2.2.R32x_v20070118

Load your bundles

Now you can start loading your bundles. We are going to specifically install

directly via these URLs above. For example:

osgi> install
Bundle id is 2
If for some reason you need to load your bundles from locally stored files, you can use the install command with a URL in the form 'file:path_to_bundle' as well.

Resolve and start the bundles

When all bundles are loaded in this manner, do a refresh and another ss.

id State Bundle
0 ACTIVE system.bundle_3.2.2.R32x_v20070118
1 RESOLVED org.eclipse.osgi.services_3.1.100.v20060601
4 RESOLVED javax.servlet_2.4.0.v200704241052
5 RESOLVED org.eclipse.equinox.http_1.0.2.R32x_v20061218

Now start the resolved bundles in this order (it matters due to bundle dependencies)

osgi> start 1 4 5 2
** New test servlet created: org.ungoverned.osgi.bundle.httptest.MyTestServlet@3d15e8ec
** New test servlet created: org.ungoverned.osgi.bundle.httptest.MyTestServlet@a16f0370
** Servlet init called:My Test Servlet
** Servlet init called:My Test Servlet
** New test servlet created: org.ungoverned.osgi.bundle.httptest.MyTestServlet@e1e49430
Duplicate alias generated Exception properly:org.osgi.service.http.NamespaceException: Alias /servlet1/MyMusicCollection is already registered
Re-used servlet generated Exception properly:javax.servlet.ServletException: This servlet object has already been registered under a different alias
osgi> ss

Framework is launched.

id State Bundle
0 ACTIVE system.bundle_3.2.2.R32x_v20070118
1 ACTIVE org.eclipse.osgi.services_3.1.100.v20060601
2 ACTIVE [2]
4 ACTIVE javax.servlet_2.4.0.v200704241052
5 ACTIVE org.eclipse.equinox.http_1.0.2.R32x_v20061218

Notice above the informational lines from the httptest.jar bundle, and how the short status now shows all bundles as ACTIVE.

Test the application

You can now try out the httptest OSGi servlet bundle, On your N800, browse to or browse to it from a PC using N800's network IP address. You should see a page like this:

Shutdown of the OSGi framework

You can quit the OSGi console immediately using the console command 'exit', or more gracefully using the command 'shutdown' followed by an 'exit'. Equinox normally remembers which bundles it had running previously, and should reload and restart the same bundles that were last installed and/or active when the OSGi console is next invoked with the Java runtime.

Help and Further Exploration

There's lots of good OSGi references and tutorials on the Web. Some good starting points include the OSGi WikiPedia Page and the OSGi Alliance Homepage.

And be sure to check out the OSGi Bundle Repository to explore the growing stock of 100+ bundles one can mix, match and mashup for many new potential applications.