04 February 2007

Installing Maemo SDK for Nokia 770

Introduction

Maemo is an opensource development platform for Linux based devices. Actually is the base of the operating system installed on Nokia 770 and 800, but it could be adopted, with few changes, even by other similar devices.

The SDK is not only a set of libraries and compiler, it gives you a real environment that emulates the Nokia device, so the developer can write applications, debug them and test them. Both command line and gui application are supported in emulator.

Graphical environment is based on a real X server, a window manager and on GTK libraries, with a particular extension called Hildon.

With Maemo SDK you can:

  • Test Maemo applications using a normal PC with Linux.
  • Write and debug applications written by you.
  • Port existing applications written for Linux/GTK and verify if they work correctly.
  • Compile and build ARMEL package so you can install them in the device.

Requirements

These are the minimum requirements to work with Maemo SDK:

  • Intel compatible processor (x86), at least 500 Mhz
  • 256 Mb RAM
  • 2 Gb space on hard disk
  • A Linux distribution (I suggest Debian or Ubuntu)

You need the following software packages:

The whole toolchain has been tested with particular versions of those two software, so you're suggested to use these packages:

Installing Scratchbox

Before you begin to install the SDK you need to become root on your machine and change the working directory to / before extracting files. To install Scratchbox you need to extract in / these packages:

su -
cd /
tar xfvz scratchbox-core-1.0.7-i386.tar.gz
tar xfvz scratchbox-devkit-debian-1.0.6-i386.tar.gz
tar xfvz scratchbox-libs-1.0.7-i386.tar.gz
tar xfvz scratchbox-toolchain-cs2005q3.2-glibc-arm-1.0.5-i386.tar.gz
tar xfvz scratchbox-toolchain-cs2005q3.2-glibc-i386-1.0.5-i386.tar.gz
tar xfvz scratchbox-devkit-cputransp-1.0.1-i386.tar.gz

Note: you don't have to extract the two Maemo_Dev* files. It will be explained later how to install them.

First of all you have to execute the initialization script:

root@notebuntu:/# /scratchbox/run_me_first.sh
Do you want to use sudo mode? [yes/no] (no):
Give the name of the scratchbox group (sbox):
The group 'sbox' does not seem to exist!
Would you like me to create the group 'sbox' for you? [yes/no] (yes):
Creating group "sbox"...
Stopping Scratchbox: umount, binfmt_misc.
Starting Scratchbox: binfmt_misc, mount.

Now you should add one or more users with /scratchbox/sbin/sbox_adduser

At this point you have to add your own user to Scratchbox, using this command:

/scratchbox/sbin/sbox_adduser username

where username is your user on Linux machine. It's ok if you leave the default values:

root@blackbull:/# /scratchbox/sbin/sbox_adduser andy80
Add user andy80 to group 'sbox'? [yes/no] (yes):
Adding user `andy80' to group `sbox' ...
Done.
Scratchbox user account for user andy80 added

Note: it's possible you have to logout from the current session and login again after you modify permissions/groups to make changes effective.

Scratchbox installation is complete. Open a terminal window on your Linux machine using your user and login inside Scratchbox with this command:

andy80@notebuntu:~$ /scratchbox/login

You dont have active target in scratchbox chroot.
Please create one by running "sb-menu" before continuing


Welcome to Scratchbox, the cross-compilation toolkit!

Use 'sb-menu' to change your compilation target.
See /scratchbox/doc/ for documentation.

sb-conf: No current target
[sbox-: ~] >

After you have logged into Scratchbox you have to create the file .bash_profile using vim and entering these lines:

export LANGUAGE=en_GB
export PAGER=less

Logout from Scratchbox and create this symbolic link that will initialize Scratchbox when your machine starts:

ln -s /scratchbox/sbin/sbox_ctl /etc/rc2.d/S20scratchbox

Installing Maemo SDK

First of all you have to copy the rootstrap files into the /scratchbox/packages/ folder:

cp Maemo_Dev_Platform_v2.2_i386-rootstrap.tgz /scratchbox/packages/
cp Maemo_Dev_Platform_v2.2_armel-rootstrap.tgz /scratchbox/packages/

You have to do this outside from Scratchbox, without being logged into it. After you have copied these two files you have to login again into Scratchbox.

Configuring Scratchbox

Latest version of Scratchbox has and utility called sb-menu that permits you to configure the available toolchains in a very easy way. These are the main functions available once you execute this utility:

  • Setup: create a new toolchain or modify an existing one.
  • Install: install other packages into an existing toolchain.
  • Rootstrap: extract and install a new rootstrap inside a toolchain.
  • Select: select the active toolchain.
  • Reset: reset the active toolchain.
  • Remove: remove an existing toolchain. Note: you cannot remove an active toolchain. First you have to select another toolchain, then you can remove the previous one.
  • Show: show informations about the active toolchain.
  • KillAll: kill all processes in the active toolchain.

Configuring i386 toolchain

To configure the i386 toolchain you need to do these simple steps:

  • Select the function Setup
  • Select Create a new target
  • Set the name to: SDK_PC
  • Choose this as compiler: cs2005q3.2-glibc-i386
  • Choose debian as devkits, then select DONE
  • CPU Trasparency: select none
  • You're now prompted to extract the rootstrap for the current target, choose Yes and write the absolute path of the Maemo rootstrap 2.2 for i386. Note: the sb-menu version I tested has a bug that doesn't permit you to select the rootstrap browsing folders on your PC, so you have to type the complete path or copy-paste it.
  • At the end you're asked to install other files: choose Yes, then select all checkboxes available and confirm to complete the installation.

Configuring armel toolchain

To configure the armel toolchain you need to do these simple steps:

  • Select the function Setup
  • Select Create a new target
  • Set the name to: SDK_ARMEL
  • Choose this as compiler: cs2005q3.2-glibc-arm
  • Choose debian and cputrans as devkits, then select DONE
  • CPU Trasparency: select qemu-arm-0.8.1-sb2
  • You're now prompted to extract the rootstrap for the current target, choose Yes and write the absolute path of the Maemo rootstrap 2.2 for armel. Note: the sb-menu version I tested has a bug that doesn't permit you to select the rootstrap browsing folders on your PC, so you have to type the complete path or copy-paste it.
  • At the end you're asked to install other files: choose Yes, then select all checkboxes available and confirm to complete the installation.

Installing Xephyr

To run graphical applications written for Maemo you need to start a graphical interface and a mini X server that works as a box for our applications. We need Xephir to perform this job and it's already installed into Maemo rootstrap.

Per eseguirlo, occorre creare un file dall'esterno della Scratchbox, ovvero senza esserci loggati dentro. Il file deve chiamarsi start-xephyr.sh ed all'interno dobbiamo scriverci:

You need to create a script outside from Scratchbox called start-xephyr.sh, without being logged into it, and write these lines inside:

#!/bin/sh -e
prefix=/scratchbox/users/${LOGNAME}/targets/SDK_PC/usr
export LD_LIBRARY_PATH=${prefix}/lib; export LD_LIBRARY_PATH
exec ${prefix}/bin/Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac

Create this file inside the /scratchbox/ directory.

Give it the executable permission:

chmod +x start-xephyr.sh

To start it you have to execute this command outside from Scratchbox, without using your normal user:

/scratchbox/start-xephyr.sh &

you should see the Xephir window at this point.

Once Xephir is started, you have to start the Maemo graphical interface. Log into Scratchbox and execute these commands:

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

Maemo graphical interface should start. Now you can run graphical application and see them inside the Xephir window.

Note: first time you run it you could get errors about "Maemo Launcher". Restarting your PC these problems should disappear.

References

Here you can find a list of website where I took information from to write this guide: