...making Linux just a little more fun!

Software Development on the Nokia Internet Tablets

By Bruce Forsberg

Introduction

About 6 years ago, I wrote an article on Software Development for a Sharp Zaurus SL-5500 PDA. Since that time, this device has fallen out of use, and I've searched for a new device to take its place. As with the previous project, I had several criteria: It had to be based on Linux, portable, and work for the audio program that I would write. I settled on Nokia's Linux-based Internet tablets. These are Wi-Fi enabled devices (not cellular phones) that are ideal for monitoring the Internet while you are on the go. More and more places are offering free Internet access, now. In my area, both Panera Bread and Burger King restaurants offer free Wi-Fi access. They are also ideal for travel and not having to lug a heavy laptop around. mplayer has been ported, and, if you scale down a movie, you can play it on your Nokia Tablet on an airplane, for instance. (All devices have a kill switch, to disable all transmissions such as Bluetooth and Wi-Fi.) Three models are currently available, either new or used; the N770, N800, and N810. Even though the N810 is the latest device, some people still prefer the N800. Currently, as this article is being written, the N800 goes for about $100 used and $150 new, and the N810 for $150 used and $225 new on eBay. The N770 is an older device and is no longer supported by the software developers, and thus should be avoided. It also uses the RS-MMC memory cards, which have lower capacity then the miniSD and microSD cards that the others support. I will give a brief overview of the N800 and N810 devices. For more detailed hardware information, see the Wikipedia pages for these three devices.

Wikipedia page for the Nokia N800: http://en.wikipedia.org/wiki/N800

Wikipedia Page for the Nokia N810: http://en.wikipedia.org/wiki/N810

Nokia Internet Tablet N800

Nokia Internet Tablet N810

The N800 and N810 are similar, with a few differences. The N810 has a slide out keyboard and built-in GPS, where the N800 does not. The N800 has two memory card slots: an internal one and an external one. The N810 has one external memory slot with a built-in 2GB card. The N810 has another nice feature that allows one to lock the touchscreen and keys, so, when you place it in your pocket, the keys and screen do not accidentally register a press event. The N800 has the same feature, but requires multiple events to activate and deactivate. The N800 has a mini-USB Type B connector, where the N810 has a micro USB connector. The same operating system and applications work on both. The latest OS is called OS2008, or Maemo 4.X (which is code-named Diablo). If you would like to see the tablets in action, listed below are 2 YouTube videos that go over the capabilities of the devices.

YouTube video of N800: http://www.youtube.com/watch?v=lPCQuiAi4yg

You Tube video of N810: http://www.youtube.com/watch?v=wDe1gd-pBRo

Setup for Development

For development, there are two basic APIs available. The native API is the GTK+ and GDK libraries, used in the GNOME desktop. But Qt 4.5, used in the KDE desktop, has also been ported to the Maemo platform, and is available as well as the Qt 3 compatibility library. To assist developers with software development, there are several Web sites that are helpful. One is a place to host new projects just for the Nokia tablets, called garage.maemo.org. This will allow you to have a source code repository, as well as perform bug tracking, news items, and mailing lists, as well as other functions needed for software development and for collaboration. Another Web site that is useful is a wiki-based help system at wiki.maemo.org. When you go to this Web site, you will find a developers section that will be very useful for assisting you with certain tasks. For anything related to Maemo, you would go to maemo.org.

In order to setup development, you will need to follow the steps below. I will go over them briefly. More detailed information is available at maemo.org. Click on the Development tab, and, when there, go to the Documentation->Tutorials section. You should see a Diablo reference manual available. Download this, and follow the directions. This will go over in detail how to setup and develop for Diablo. Note, by the time you read this article Fremantle might be the latest Stable OS. If so, then look for a reference for Fremantle, and substitute Fremantle for Diablo everywhere in this article. Here are the steps to follow:

  1. Install Scratchbox
  2. Install targets for X86 and ARM for Diablo in Scratchbox
  3. Make sure your device is updated with corresponding OS
  4. Outside Scratchbox, install the Xephyr X server tool. You will need to search your distribution for this. This allows you to open a window on your Linux box that can emulate a Nokia display.

When you first develop for this platform, you will do this on your PC instead of the device. This is done using a piece of software called Scratchbox. This allows you to run different Linux environments in one. The current OS software used, as of the writing of this document, is called Diablo. There is a new one coming called Fremantle, but it is still in beta. You begin by installing Scratchbox on your PC. This requires a Linux OS. Since Scratchbox is Debian-based, it installs most easily on a Debian-based system. I personally run it on an OpenSUSE 10.3 system. The advantage to Scratchbox is that you can create targets, such as X86 Diablo, and install software packages in this target and this is all you will see. It provides a sterile environment from your Linux PC. With the Diablo ARM target, you can compile packages for the Nokia devices. It is important to note that, depending on how many targets you install, this area can become large. My Scratchbox is over 1 GB. To start, you need to install the Maemo Diablo SDK on your PC. Your best bet is to follow the detailed instructions at maemo.org. Click on the Developer tab, and go to the SDK Releases section. As of this article date, you would select Maemo 4.1.2 Diablo. Read the Release notes and the INSTALL.txt documents, and follow these directions. You will want to install both the X86 and ARMEL targets. If you are using the Diablo 4.1.2, you will want to make sure your device has the corresponding OS installed on it. For detailed directions on updating your OS, go to wiki.maemo.org, and in the Users section, there will be a document titled "Update the tablet firmware". Follow these directions. Last, look for Xephyr. This is most likely part of your distribution, and is probably already installed. If not, check your media to see if this exists, and install it.

Development

You are now ready to start development. You will need to login to Scratchbox. If you installed this on a non-Debian Linux system, then you might need to perform the following step first. In another shell:

sudo <scratchbox install path>/sbin/sbox_ctl start

Now, you can login. This can be done with:

<scratchbox install path>/login

Now, select the target you wish to operate in. For instance, to be in the X86 target for Diablo, you would type:

sb-conf select DIABLO_X86

You are now in an environment setup for Maemo development for the Diablo release and for the X86 environment. You will only see header files and libraries for this environment. The standard Debian commands will work for adding or removing packages that you might need. You would now develop your application just like on a normal Linux-based system. When you get your first program to compile, you can display the program in the environment by performing the following:

Start Xephyr outside Scratchbox.

Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -extension Composite

A window the size of the Maemo display should appear. Now, we need to display the Maemo framework within the Xephyr window. From scratchbox type:

export DISPLAY=:2 af-sb-init.sh start

You should now see the application framework displayed in the Xephyr window. You now need to display your application in the window:

run-standalone.sh ./<your app name>

If everything has gone correctly, you should now see your application in the application framework window. From here you can use gdb, Valgrind, and other tools to perform your main application development. When you get your application working well, you are ready to port it to ARMEL, and try it on your tablet.

Porting to the ARMEL platform is easier than you might think. We will use the Scratchbox environment to do most of the dirty work for us. First, we need to switch targets:

sb-conf killall sb-conf select DIABLO_ARMEL

The Maemo environment is a Debian-based system. Therefore, you will need to build your application as a Debian-type package. Once you have this setup, you can try in on your tablet.

Create a binary package to try on your device:

dpkg-buildpackage -rfakeroot -b -d

You can then transfer your .deb package to the tablet via the USB connection. You will mount one of the file systems in your tablet on your Linux PC, and transfer the .deb file. Once on the tablet, you will start the file manager application, and locate the uploaded .deb package. You will double-click on it, and it will load the Application Manager application and prompt you to install your application. If you get an error installing your application, it is most likely a result of missing packages. Check the dialog for any missing packages. There is also a log menu item on the Application Manager application that you can check for errors. You will need to install these other packages first, before it will install yours.

Once you have it working on your tablet, you are ready to test the software distribution system. Most user-developed applications go into a repository called "extras". This is most likely where yours will end up. There is a test play area repository called Extras-Devel. This is what we will use first. You will need to make sure this is enabled on your tablet. Go to the Application Manager and select the Tools menu, and select the Application Catalog item. If there is an Extras-Devel entry, then verify that it is enabled. If there is not one, then create a new one. Use a name of "maemo Extras-Devel". Use URL "http://repository.maemo.org/extras-devel/". Distribution can remain blank. For Components, put in "free non-free". Make sure Disabled is not checked. For your convenience, a link is in the resource section of this article: Click on it from your tablet, to add this repository for you.

You will now need to package the source for your application, from the DIABLO_ARMEL target. In this target, enter the following to build the source:

dpkg-buildpackage -rfakeroot -sa -S -I.svn

For the -I, use whatever the version control directories are. I was using SVN, but you might be using another. This should have built 3 packages: a .dsc file, a .tar.gz file, and a .changes file. With these files, we will now need to submit these packages to an autobuilder that will build the packages in a sterile environment. You will be emailed back later (10 minutes or more) when it is done and whether it is successful or not.

In a browser go to the extras assistant to submit the packages. If you have never been approved for uploading, then you will need to create a new account first. Follow the directions at this site. Once you are approved for uploading then submit the source files using the Web interface.

Once it has compiled successfully a short time later, it will be placed into the Extras-Devel repository. You can then remove the copy on your tablet that you had installed by hand with the Application Manager. Then, using the Application Manager, click Check for Updates. Once done, click on Browse Installable Applications. Click All, and search for your application. Once you have found your application, install it. You have now made available your first application to the Maemo community. Only a limited subset of users will see your application, though, mostly developers that have the Extra-Devel repository enabled. One of the advantages to making your application available, this way, is that when someone wants to download your application, it will automatically determine what other packages are needed and download them while downloading yours as well. The last step is to make it available to a wider audience, by submitting it to the Extras repository. This is called promotion. You will need to promote your application to the Extras repository. This can be done by again going to the extras assistant. On the right side, there should be a link called the Extras Promoter Diablo. Click on the link and login. You will see a long list of application packages. Find yours, select them, and then select to have them promoted. This can take over a hour to accomplish, so be patient. Wait a couple of hours, and then delete and load your application again using the Application Manager. You should disable the Extras-Devel repository, just to make sure. You, and everybody else, should now be able to download the application from the Extras repository.

One last optional step is to publish your new application. This can be done at the maemo.org Web site by going to the Downloads section. Once there, find the Add New Application link, and click and follow the directions for submitting this new application.

Resources

There are plenty of resources to help you. By far the most useful is the Maemo Reference Manual for what ever release you are on. In our case, the Maemo Diablo Reference Manual. This contains step-by-step instructions for developing on Maemo. This document explains the above in over 500 pages, and goes into detail what I have just skimmed over. The second most useful are the wiki pages. In the development section, there are numerous wiki pages addressing specific issues with development. If you are still facing a problem that you can't solve, you can submit a question to the developers user group mailing list. You can sign up for this at maemo.org, under the community section. Look for the Mailing Lists link below.

Maemo Main Site: http://maemo.org

Maemo Garage: http://garage.maemo.org

Maemo WIKI Developers Pages: http://wiki.maemo.org/Category:Development

Maemo Diablo SDK: http://maemo.org/development/sdks/maemo_4-1-2_diablo

Maemo Diablo Reference Manual: http://maemo.org/development/documentation/tutorials

Maemo Mail Lists: http://wiki.maemo.org/Community_mailing_lists

My Car Mileage Calculator Home Page: http://mileage.garage.maemo.org

My OTR Audio Player Home Page: http://otrplayer.garage.maemo.org

Latest Downloads for Maemo: http://maemo.org/downloads/OS2008

Maemo Extras Assistant: https://garage.maemo.org/extras-assistant/index.php

Click this link on your tablet to add the Extras repository: https://garage.maemo.org/extras-assistant/install/extras.install

Click this link on your tablet to add the Extras-devel repository: https://garage.maemo.org/extras-assistant/install/extras-devel.install

Talkback: Discuss this article with The Answer Gang


Bio picture Bruce is just an average guy having fun with Linux. He is the founder of the Open Source Audio Library Project. He got his start programing freeware on windows 3.1. When he realized that all one had to do was to not return from a message and it would hang the entire operating system, he knew there had to be a better way. Linux was the answer.

Copyright © 2009, Bruce Forsberg. Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 165 of Linux Gazette, August 2009

Tux