07 March 2007

Developing with the Nokia N800

I decided to begin some simple development with the Nokia N800. Nothing particularly original -- just an attempt to port a few useful programs onto the platform, so I decided to blog the progress (and problems) I encounter along the way, in case anyone else wants to give it a go. Feel free to learn from my mistakes!

The first challenge I encountered is that the development environment for Maemo.org requires Linux, but I'm running OSX on a MacBookPro. No problem really -- I also run Parallels, so I have created a new virtual machine, in which I am installing Ubuntu 6.06.
It may be possible to port the development tools to the underlying Free BSD on which OSX is based, but I don't want to bite off more than I can chew at present, and I have more development experience with Linux than OSX anyway.
  1. First step: start Parallels, then use "File|New" from the menu to create a new virtual machine. I selected "Typical", OS Type "Linux" and OS Version "Debian Linux," which I expect should work fine for Ubuntu. I accepted the defaults of 256 Mb of RAM, and 32 Gb of disk, which I can always increase later if necessary.
  2. Next step is to insert the Ubuntu 6.06 CD-ROM, which is bootable as a Live CD. After starting, it goes into a desktop, with an icon saying "Install." I double-click this, and go through a standard install sequence, for which I take all the sensible defaults. This takes about 30 minutes, to copy all the files from the CD-ROM with the emulation running in the background.
  3. After rebooting the Ubuntu VM (with the CD-ROM ejected), I then start an online Ubuntu upgrade, to ensure a clean environment. I may have to add some of the GNU tool chain, which probably doesn't come standard with the Ubuntu.
  4. Next, I take a look at some of the prerequisites. I know that the Nokia N800 uses Maemo, so I visit ed there to find that I should use the latest release, known as Bora. This in turn points me to Scratchbox Apophis, which seems to be a cross-compilation toolkit. The Scratchbox installation instructions tell me that I need root access, particularly if I want to set up the Debian repository for apt-get.
  5. On my Ubuntu system, I edit the file /etc/apt/sources.list, and add the line
    deb http://scratchbox.org/debian ./
    Personally, I use vi (being very much old-school UNIX). Don't forget to "sudo su -" first to get root access. Then I run "apt-get update", to update my repository list.
  6. After the update, from the command line I can begin to install the packages, using these command:
    $ apt-get install scratchbox-core scratchbox-libs
    This is around 215 Mb of disk space.
  7. Belatedly, I read the instructions for installation of Maemo's Bora, and found the recommendation to use the installer script. Naturally, this doesn't tolerate an existing install, therefore I had to remove the one I just installed.
    $ apt-get remove scratchbox-core scratchbox-libs
  8. Next, I download the correct installation script, e.g.:
    $ wget http://repository.maemo.org/stable/bora/maemo-scratchbox-install_3.0.sh
    $ sh ./maemo-scratchbox-install_3.0.sh -d
  9. The script does a number of checks, then downloads and installs the necessary packages, including scratchbox.
  10. First problem found: the install script is expecting a utility called "GNU ar" (an archiver), which is missing in the default Ubuntu install. Therefore, I interrupted the installation script, and installed the "binutils" packages to satisfy this dependency:
    # apt-get install bin-utils     
  11. After the script downloads all the files it needs, it runs an installation script, and terminates.
  12. The next step is to create a scratchbox user with the command "/scratchbox/sbin/sbox_adduser paul yes", then login with the command "/scratchbox/login". This means exiting from the "sudo su -" with Control-D. The script recommends logging out then back in again as your regular user, but I just used the command "newgrp sbox", and permissions were correct.
  13. Now we get to the installation of the Maemo Bora, which can be done by downloading and running this script:
    $ wget http://repository.maemo.org/stable/bora/maemo-sdk-install_3.0.sh
    $ sh ./maemo-sdk-install_3.0.sh
  14. Now I have the next problem. The SDK seemed to install just fine, but we have an issue with the installation of the Nokia components. Apparently, this needs need to be done for two different environments: the X86 and the ARMEL. By default, the SDK seems to begin in the X86 environment, e.g.:
    sbox-SDK_X86: ~] > fakeroot apt-get install maemo-explicit
    The above command runs just fine. The problem I had was when I tried to switch to the ARMEL environment. I did this with the command "sb-menu", then chose SELECT to activate the target "SDK_ARMEL". Fine so far, but when I try the command:
    [sbox-SDK_ARMEL ~] > fakeroot apt-get install maemo-explicit
  15. This is the error message:
    SBOX_CPUTRANSPARENCY_METHOD not set
    I am guessing I messed up the sb-menu, by accidentally going into the SETUP menu. There seems to be a setting there for CPU_TRANSPARENCY, but it's not clear how to fix it. I experimented for a bit by using the sb_menu to reset targets, but realized I have no idea what I'm doing (which is very typical for me, being a "bear of very little brain.") Therefore, I was pleased when I exited from the scratchbox, and ran the installer again with the -y option to reset the existing targets, which seemed to do the trick. It downloads the rootstraps again, but it's only time and bandwidth.
  16. Again, I logged in to the scratchbox, then selected each target, and ran the install for maemo-explicit, as well as the update. This seemed to run just fine, for both targets.
  17. Step 4 of the installation process talks about Xephyr. This needs to be installed outside of the development scratchbox, on the host system. Unfortunately, I am running a stable version of Ubuntu, and the command proposed: "apt-get install xserver-xephyr" simply doesn't work, presumably because it's part of the unstable distribution of Debian.
  18. To correct this problem, I had to edit /etc/apt/sources.list, and uncomment the "universe" repositories, run "apt-get update", then was able to run the above command successfully to install Xephyr.
  19. To test Xephyr, I used the command line which starts up the X Windows display, naturally in the correct size for the Nokia N800:
    Xephyr :2 -host-cursor -screen 800x480x16 -dpi -ac &
  20. Now everything should be working as expected, so to test this I logged into the scratchbox, set my terminal environment, and ran the test environment:
    $ /scratchbox/login
    [sbox-SDK_X86:~] > export DISPLAY=:2
    [sbox-SDK_X86:~] > af-sb-init.sh start
And here is the result:


No comments: