Chapter contents:


Introduction

Software development for the maemo is possible using many different programming languages. This chapter describes the process and common practices of developing software for the maemo platform. It also introduces the tools that form the maemo SDK environment.


Overview of the software development process using the maemo SDK environment

The development environment used in the process is called maemo SDK which is freely downloadable from the maemo community website http://www.maemo.org. The maemo SDK utilizes Scratchbox, which is a cross-compilation toolkit and a "sandbox", designed for embedded Linux application development. Scratchbox is downloadable from its' website http://www.scratchbox.org/.

The maemo SDK provides a development environment for creating software to Internet Tablets using a Linux desktop computer. The SDK runs inside the Scratchbox and contains all necessary compilers, tools, libraries and headers to develop software for the two target hardware architectures, Intel (x86) and ARMEL. Application development and preliminary testing of the software is done in x86 environment, which also includes the Hildon Desktop for running the applications on the desktop computer (using virtual X server, such as Xephyr) like they would run on the actual Internet Tablet. Using desktop computer for development makes the application development quite similar to normal Linux application development. Maemo SDK also has a support-plugin for Eclipse, Integrated Development Environment (IDE) which speeds up and helps the development process radically.

After the preliminary testing on desktop computer is finished, the next phase is to cross-compile and package the application for the ARMEL architecture using the ARMEL target of the Scratchbox, and the application is ready to be run and tested on the Internet Tablet. Testing-phase using the actual Internet Tablet is important even when the application runs fine on the desktop environment as the SDK is not exactly 100% identical to the device.

Development tools and resources used in maemo application development process:

Phases of software development process using C or C++ language:

  1. Create project (possibly using templates) for the application
  2. Create or update the source code and needed resources
  3. Create or update the UI schema (possibly using UI builder)
  4. Build the application with x86 rootstrap
  5. Launch and test the application on x86 rootstrap
  6. Debug the application on x86 rootstrap
  7. Cross-compile the application with ARMEL rootstrap
  8. Launch and test the application on the Internet Tablet
  9. Debug application on Internet Tablet
  10. Create ARMEL installation package for the Internet Tablet
  11. Install ARMEL application package to the Internet Tablet

Phases of software development process using Python (and other script-languages):

  1. Create project (possibly using templates) for the application
  2. Create or update the source code and needed resources
  3. Launch and test the application on x86 rootstrap
  4. Debug the application on x86 rootstrap
  5. Launch and test the application on the Internet Tablet
  6. Debug application on the Internet Tablet
  7. Create ARMEL installation package for the Internet Tablet
  8. Install ARMEL application package to the Internet Tablet

Following chapters take a deeper look into the phases of the development process.


Creating project for application

Creating the project for an application can be done either from scratch, or by using several examples available from maemo web site as templates. Source files can be edited using your favorite text editor. Scratchbox creates a "sandbox", a separate filesystem (called rootstrap) under your normal filesystem, so it is adviseable to create a symbolic link to Scratchbox folders for easier access of files from your desktop environment. Of course, using a console-based text editor (such as nano) inside Scratchbox shell is also possible.

As maemo uses Debian-based package management system for applications, it is a good practice to take that into account already when creating a project and create necessary files for packaging or use helper-applications for creating them, such as GNU Autotools.

Notice, the Hildon Desktop must be started before running the maemo applications inside the SDK.

The official programming language for maemo application development is C, but several other languages can be used with maemo also, for example C++ and Python.

There exists several UI-builder applications to speed up the creation of UI schema, most commonly used are Gazpacho and Glade.

Complete guide of setting up and using the development environment can be found from maemo Getting Started and maemo Application Development materials.


Building and running applications

When source code has been created with necessary resource-files, the application is ready for compiling and testing. The SDK provides all the usual Linux development tools inside the Scratchbox as well as the maemo application framework so the applications look and behave like they would on the Internet Tablet.

List of the most commonly used development tools provided by the maemo rootstrap:

Process:


Debugging on x86 rootstrap

Debugging the application in x86 target can be done with regular Linux development and debugging tools, like GNU Debugger (gdb), valgring, ltrace and strace. Some tools also provide a graphical user interface to be used for debugging.

Notice also that the valgrind tool is not available in ARMEL target, only in x86 target. Valgrind is a really powerful tool for memory leak detection, profiling etc.

If the debugging tool of your choise is missing, as the Scratchbox is practically a full Linux system, it is also possible to add a tool into it by compiling the tool for Scratchbox from the source code.

Other possibility is to run the application on Internet Tablet and debug remotely using gdbserver on Internet Tablet and gdb on PC environment, using either cable or wireless connection.

For more information about debugging, there is a comprehensive debugging guide on maemo.org website.


Cross-compiling for ARMEL

Cross-compiling the application for the Internet Tablet is really straightforward. Activate ARMEL target of Scratchbox and re-compile the application. There is no difference in the process of compiling the application to x86 or ARMEL targets. After compiling, your application binary is ready for the Internet Tablet architecture.

The ARMEL target should only be used for cross-compiling and packaging the applications for the Internet Tablet device, not for running and testing as the ARM CPU emulation of Qemu may not provide accurate enough emulation to finalise testing only on PC.


Running, testing and debugging applications on the Internet Tablet

Even though the SDK is quite accurately identical to the target environment of the Internet Tablet, it isn't 100% identical. Especially if your application is using some special hardware of the Internet Tablet, the application can behave differently in SDK than on the device.

Fortunately, testing the cross-compiled binary transparently on the Internet Tablet has been made possible from Scratchbox, using either SSH or a CPU transparency tool called sbrsh (Scratchbox Remote Shell). Connection to the Internet Tablet can be handled either by USB cable or wirelessly.

CPU transparency is a technique where ARMEL binaries are copied from the Linux PC side over the connection to the device where the binary is then executed natively by the Internet Tablets own ARM CPU. This is a handy way to test your ARMEL-binaries in a native ARM CPU instead of running them in Linux PC under the QEMU emulator. The QEMU emulator may not be identical with the real ARM device so using CPU transparency with the real device is a convenient way to test drive your ARMEL application. The graphical environment is still the Scratchbox (and virtual X server, Xephyr) environment.

Check the maemo.org HOW-TOs section for more information about CPU transparency.

It is possible to use gdb debugger remotely with a gdbserver running in the Internet Tablet. The application to be debugged is then ran in the Internet Tablet, which makes debugging results 100% accurate. This makes remote debugging the application using desktop PC possible, again the same connectivity as with the CPU transparency is needed when remotely debugging.

For more information about debugging, there is a comprehensive debugging guide on maemo.org website.


Application Packaging and Installing

Maemo uses the Debian package management system for installing and managing application packages and their dependencies. For end-user the actual package management is invisible and the application installation and removal in the Internet Tablet is done by Application Manager. The Debian package management system uses packages which consists of application binaries, optional libraries, meta data describing the package, dependencies to other packages and optional pre-install and post-install scripts. Packaging the applications is done with standard Debian packaging tools.

After creating the Debian package (creation is identical to the desktop Linux environment) the application is ready to be installed to Internet Tablet. Application is either copied to the device and installed using Application manager, or by placing the package into the package repository (essentially a web or FTP site containing application packages) and creating a single-click install-file. The single-click install-file eliminates the need for user to manually configure repositories into the Application manager, providing an easy-to-use way for end-user to install the application.

The site download.maemo.org contains a vast amount of applications, ready to be installed to Internet Tablet, and utilizes the single-click install method.

The maemo Application Development course material contains more information how to create Debian installation packages for Internet Tablets.


Copyright © 2007-2008 Nokia Corporation. All rights reserved.