Reply
Thread Tools
Posts: 53 | Thanked: 51 times | Joined on Feb 2010
#1
EDIT:: Tested on latest Nokia SDK released on 23 June 2010

Hi.

I just thought I would create a quick guide to getting started in Maemo including setting up the environment, creating a "HelloWorld" program and running it on the Nokia N900.

Please free to add comments and I will edit this post to reflect all your comments and criticisms!

Tested on 32 bit Linux Mint 9 running on a Intel P4.

0. Remove Old SDK
Just in case there are no issues with two SDKs, remove the old SDK by running the SDKMaintenanceTool tool. This should be located as a menu item.

If you don't have it on your menu bar, you can find it in the install directory.

Once it has loaded, simply select the tab "Package Manager", select the option "Remove all components", then click "Next".

Now simply click "Uninstall" and Nokia SDK will be removed completely, and then click "Finish" to close the tool.


1. Installing QT SDK

Download the current Nokia QT SDK (released on 23 June 2010) from:

PHP Code:
http://www.forum.nokia.com/info/sw.nokia.com/id/e920da1a-5b18-42df-82c3-907413e525fb/Nokia_Qt_SDK.html 
Then set permissions to execute by opening up a terminal window and typing:

Code:
chmod u+x Nokia_Qt_SDK_Lin32_offline_v1_0_en
Then execute by typing:
Code:
./Nokia_Qt_SDK_Lin32_offline_v1_0_en
If you get any errors, you may need to execute the file with root permissions. Simply type:
Code:
sudo ./Nokia_Qt_SDK_Lin32_offline_v1_0_en
Follow all the prompts and for simplicity sake, please select full install. You can remove old QT settings if you wish.

This make take a while... be patient!


2. Rebuild Qt Debugging Helper

Now Qt is installed, there is one important thing we need to do before we create a sample code.

We need to ensure that the debugging helpers are built.

Load Qt and go to:
Code:
Tools -> Options -> Qt4
Click on Qt for Fremantle PR1.2 Devices (Nokia Qt SDK) and then click on Rebuild.

You will find that the red cross is now a green tick.

Do the same for Simulator Qt for GCC (Nokia Qt SDK). Click OK to exit.

Next we need to configure the N900.

3. N900 setup

To make your life easier, you can add the Nokia N900 to Qt and use one click testing and deployment on the device itself.

You can visit http://wiki.maemo.org/MADDE/QtCreato...tion_for_linux for the USB method of connection, but as I dislike wires, I will be using the Wifi method.

First we need to prepare the device:

Make sure you have the latest firmware installed. To check the latest firmware, please go to:
Code:
Menu -> Settings -> About Product
Ensure you have:
HTML Code:
Version: 10.2010.19-1.203.1
Make sure you have the extras repository setup.

Load up the App Manager:
Code:
Menu -> App Manager
Select the Application Manager title and select Application Catalogues, check to ensure you have maemo.org or maemo Extras.
If you have both, then select maemo Extras and disable it.

Open up maemo.org, ensure it has the following:

Code:
Catalog name: maemo.org
Web address: http://repository.maemo.org/extras/
Distribution: fremantle-1.2
Components: free non-free
Now select Download -> Development -> mad-developer

This will talk to Qt and allow it to deploy code to the N900.

Install the client. Note, you will be asked for a new root password, PLEASE DO NOT FORGET THIS!

4. Add the N900 to Qt

If Mad Developer is not loaded, load it up.

It should display your IP address on wlan0.

In Qt, goto:
Code:
Tools -> Options -> Projects -> Maemo Device Configurations
Click the Add button

To add the N900, populate the following fields:

Code:
Name: Nokia N900
Device Type: Select Remote device
Authentication Type: Select Password
Host Name: Enter the IP address as shown on the N900
Username: developer
Password: Click on the "Developer Password" on the N900 and enter this here
Now click on "Test" to see if everything works.

You should be presented with the following:

PHP Code:
Device configuration successful.
Hardware architecturearmv7l
Kernel version
2.6.28-omap1
List of installed Qt packages:
    
libqt4-core 4.6.2
    libqt4
-dbus 4.6.2
    libqt4
-gui 4.6.2
    libqt4
-maemo5 4.6.2
    libqt4
-maemo5-core 4.6.2
    libqt4
-maemo5-dbus 4.6.2
    libqt4
-maemo5-gui 4.6.2
    libqt4
-maemo5-maemo5 4.6.2
    libqt4
-maemo5-xml 4.6.2
    libqt4
-multimedia 4.6.2
    libqt4
-network 4.6.2
    libqt4
-opengl 4.6.2
    libqt4
-phonon 4.6.2
    libqt4
-sql 4.6.2
    libqt4
-sql-sqlite 4.6.2
    libqt4
-svg 4.6.2
    libqt4
-webkit 4.6.2
    libqt4
-xml 4.6.2
    libqt4
-xmlpatterns 4.6.2 

Click close to close the message box. You will need to enter a new password each time you load Mad-Developer.

Therefore, we should deploy a key to ensure we can simply load Mad-Developer on the N900 and start using it.

Note: Encrypted keys are not supported.

Click on Generate SSH Key.

A new box will open. Select Key Size 4096 and then click Generate SSH Key.

Once the key has been generated, click on Save Public Key and then click on Save Private Key.

Ensure you save them somewhere safe. Click Close to go back to the Maemo Device Configuration Screen.

If you need to change the [/B]Private Key file[/B] location, change the "Authentication Type" to Key, then click Browse button at the bottom next to Private Key and select the private key you just generated.

Now change the Authentication Type back to Password and click on "Deploy Public Key". A box will appear asking you to select the public key. Select the one you just saved and click Open.

You should revieve the message "Key was successfully deployed"

Now change the Authentication Type to "Key" and click Test to ensure it connects successfully.

Click Ok to close that screen and open the main screen up.

Now we can create out first "Hello World Program"

5. Hello World

Let create a push button when pressed will pop up a message on the screen saying "Hello World!"

First ensure you are on the Welcome screen of Qt.

Click on Create Project.

Select Mobile Qt Application, then click on Choose

Set the name as HelloWorld and click Next.

In the next screen, ensure you select both Qt for Fremantle PR1.2 Devices (Nokia QT SDK) and Simulator QT for GCC (Nokia Qt SDK) and then click Next.

Click Next again on the Class Information screen and then click on Finish.

Now by default, you should be in Design mode.

Drag a "Push Button" to the main window.

Right-Click on the Button and click "Go to slot...". Select the Clicked() and then click on OK.

You may receive an error about not being able to find/add a slot.

I believe this may be a bug. Rebuilding will not help. To solve this, simply click OK to close the error box.

On the bottom left hand side, there should be button labelled Debug, click this once and then Select the Top one, Maemo. Wait for a few seconds so that the scanning/parsing finished.

Then click back on the Qt Simulator.

Now you should be able to right click on the new button and select Go to slot... and then Clicked() and then OK.

No add the following to the MainWindow::on_pushButton_clicked() section so that it looks like the following:

Code:
void MainWindow::on_pushButton_clicked()
{
    QMessageBox msgBox;
        msgBox.setText("Hello World!");
        msgBox.exec();
}
Ensure you only paste the bold items into the section.

Now we simply need to add the header, so go right to the top of the editor and add the following bold line:

Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
That is all we need to do.

To run on the Desktop simulator, simply click on the Run button (the first big green arrow on the left. You will be prompted to save, simply click Save All.

After a few seconds, you should receive a nice image of the N900 with a button. Click the button and it should say Hello World!.

To run it on the N900, simply click the Debug button and then select the Maemo option. Now click the green run button or hold CTRL+R.

The application should now be running on your Nokia N900.

Last edited by TheAccountant; 2010-07-03 at 16:42.
 

The Following 24 Users Say Thank You to TheAccountant For This Useful Post:
Posts: 53 | Thanked: 51 times | Joined on Feb 2010
#2
Some people may prefer to use Scratchbox, so the following will help you setup Scratchbox and create a "Hello World" program.

1. Install Scratchbox

Scratchbox is, taken from the scrachbox website:
Scratchbox is a cross-compilation toolkit designed to make embedded Linux application development easier. It also provides a full set of tools to integrate and cross-compile an entire Linux distribution.
First, you will need to ensure that xserver-xephyr is installed on your system. Xephyr is an X server that can be run inside another X server. Xephyr will create a window that scratchbox can populate with the N900 emulator or "Window".

Use your package manager or control panel or what ever you use to manage installed programs to install Xephyr. For example, in Linux Mint, I can use the "Package Manager".

Once installed, download the SDK python script and install it. Note, if the script fails to run, it is because you do not have Python installed. Again, go to your package manager and install Python. However, on Linux Mint, when I ran the script, it installed Python on its own.

Download from http://repository.maemo.org/stable/5...-wizard_5.0.py

Open up a new terminal and run the following:

First we make it executable:
Code:
chmod a+x maemo-sdk-install-wizard_5.0.py
Then run as root:
If you use Ubuntu:
Code:
sudo ./maemo-sdk-install-wizard_5.0.py
or if you use Debian:
Code:
su -c ./maemo-sdk-install-wizard_5.0.py
or if the above does not work, try:
Code:
su
enter your root password and then
Code:
./maemo-sdk-install-wizard_5.0.py
A Scratchbox install window should appear, follow the options untill you get to the installing now part.

Note, this will take a long time as you need to download a lot of data ~600mb. You best grab a coffee!

If Scratchbox fails to install due to "too many errors", the following should work. There is a known bug in the installer so this is a quick workaround:

Open up a terminal window and edit the following file:
Code:
/etc/sysctl.conf
Add the line to the bottom of the file:
Code:
vm.mmap_min_addr = 0
Save and exit

Then run:
Code:
sudo sysctl -p
No try running scratchbox again:
Code:
sudo ./maemo-sdk-install-wizard_5.0.py
It should continue from where it left off.

2. Update Scratchbox

Hopefully Scratchbox installed successfully. Now we just need to update Scratchbox and add all the Qt libraries so we can run Qt apps.

Open up a terminal window and login to Scratchbox:
login to scratchbox:
Code:
/scratchbox/login
Hopefully you will get the following prompt:
PHP Code:
user@linuxmint ~/Desktop $ /scratchbox/login

Welcome to Scratchbox
the cross-compilation toolkit!

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

[
sbox-FREMANTLE_X86: ~] > 

First, we need to add the extras repositories:
Code:
vim /etc/apt/sources.list
Now use the arrow keys to get to am empty spot, press the i key which will turn the mode to insert and type out the following:

Code:
#Extras
deb http://repository.maemo.org/extras/ fremantle free non-free
deb-src http://repository.maemo.org/extras/ fremantle free
If you make a mistake, hit the Escape key and type :q! and hit enter and vim will quit without saving. Once your happy you have typed everything correctly, hit Escape and :w and enter to save the file. Then to quick, press Escape and then type :q

You can now go ahead an update apt’s local cache:
Code:
fakeroot apt-get update
Now we want to check we have the latest distribution. Type:
Code:
fakeroot apt-get dist-upgrade
Now Scratchbox is updated, so we need to add the Qt libraries, type:
Code:
fakeroot apt-get install libqt4-gui libqt4-dev
Exit Scratchbox by typing exit and close your terminal.

We are now ready to try out Scratchbox to see if it run the N900 "emulator".

By default the SDK requires a Xephyr window, simply double clicking on the Desktop icon will not work.

So lets edit that script so it creates the window for us so we only have one icon we need to double click.

Edit the /usr/local/bin/start_xephyr.sh file and add code to run a window. This should be a single line only, sorry but the forum wraps the line:
Code:
(Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -keybd ephyr,,,xkbmodel=evdev) &
So the file becomes:
Code:
#!/bin/sh
# Automatically created by Maemo 5.0 SDK Installer
(Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -keybd ephyr,,,xkbmodel=evdev) &
(Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb; newgrp sbox <<'END'
/scratchbox/login af-sb-init.sh stop
END
) &
newgrp sbox <<'END'
sleep 3
/scratchbox/login sb-conf select FREMANTLE_X86
/scratchbox/login af-sb-init.sh restart
END
Save and double click the SDK icon and you should now have working window.

Now you are ready to to try your hello world program!. Close any windows that are still open.

3. Hello world

The Nokia SDK will create a windows which will show us a N900 window. We will still need to use a separate terminal to "inject" our code.

So lets begin by creating the basic hello world program. On your desktop, you should find a sbhome icon. Double clicking this will take you to the /scratchbox/users/username/home/username

Essentially, /scratchbox contains all of maemo so it is the "root" of the phone.

Anyway, enter the sbhome and create a new directory called "HelloWorld". I believe in most linux window managers, you can right click and then Create Folder.

Now open an editor of some sort, example, GEdit and paste the following code:
PHP Code:
#include <QApplication>
#include <QLabel>
int main(int argcchar *argv[])
{
QApplication app(argcargv);
QLabel *label = new QLabel("Hello World");
label->show();
return 
app.exec();

You will need to pay special attention to the quotes. It needs to be ASCII quotes. If you have an option, select ASCII as the encoding format. Also, make sure there is no extra spacing left at the end of the code. Save it in the HelloWorld folder as HelloWorld.cpp

Now lets compile this.

First, double click the Maemo5 SDK icon to load up an emulator.

Then open up a terminal and login to scratchbox:
Code:
/scratchbox/login
By default,, you should be in the same directory as sbhome, so if you type
Code:
ls
and enter, you should see the following:

Code:
[sbox-FREMANTLE_X86: ~] > ls
HelloWorld  maemo-sdk-rootstrap_5.0_10.2010.19-1_armel.tgz
MyDocs      maemo-sdk-rootstrap_5.0_10.2010.19-1_i386.tgz
[sbox-FREMANTLE_X86: ~] >
Now change to HellowWorld directory:
Code:
cd HelloWorld
Check to see your HellowWorld.cpp file is there:
Code:
[sbox-FREMANTLE_X86: ~] > cd HelloWorld
[sbox-FREMANTLE_X86: ~/HelloWorld] > ls
HelloWorld.cpp
[sbox-FREMANTLE_X86: ~/HelloWorld] >
Now to compile, simply type the following:
Code:
qmake -project
Then:
Code:
qmake
Then finally:
Code:
make
The output should be something like the following:
Code:
[sbox-FREMANTLE_X86: ~/HelloWorld] > qmake -project
QFileInfo::absolutePath: Constructed with empty filename
[sbox-FREMANTLE_X86: ~/HelloWorld] > qmake
[sbox-FREMANTLE_X86: ~/HelloWorld] > make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/targets/FREMANTLE_X86/usr/share/qt4/mkspecs/linux-g++ -I. -I/targets/FREMANTLE_X86/usr/include/QtCore -I/targets/FREMANTLE_X86/usr/include/QtGui -I/targets/FREMANTLE_X86/usr/include -I. -I. -o HelloWorld.o HelloWorld.cpp
g++ -Wl,-O1 -Wl,-rpath,/usr/lib -o HelloWorld HelloWorld.o    -L/usr/lib -lQtGui -L/usr/lib -L/usr/X11R6/lib -lQtCore -lpthread 
[sbox-FREMANTLE_X86: ~/HelloWorld] >
To load our new program up, type the following and hit enter:
Code:
run-standalone.sh ./HelloWorld
Now click on the emulator window, which should show the Hello World program.
 

The Following 16 Users Say Thank You to TheAccountant For This Useful Post:
Posts: 53 | Thanked: 51 times | Joined on Feb 2010
#3
Make your life easier for developing:

Wifi Switcher
This little plug-in will allow you to quickly switch on/off your wifi connection. A must have to save battery.
Goto http://maemo.org/downloads/product/M...wifi-switcher/ on your N900 and click the Install link.


Backlight time-out
Increase your backlight time-out when developing which will stop you from constantly having to use the slider.

Code:
Menu -> Settings -> Display -> Backlight time-out
Warning: Once you are done developing, make sure you turn this down or you will drain the battery!

Also, you can check "Display stays lit when charging" which will keep the backlight on when plugged in to wall or USB.


Add Mad Developer to your "Desktop"
Add an icon to main screen for quick access to the Mad-Developer software. Simply press and hold on anywhere on the screen. Then:

Code:
Desktop Menu -> Add Shortcut -> Mad Developer



Reserved to add packing information...

Last edited by TheAccountant; 2010-07-03 at 17:03.
 
Posts: 455 | Thanked: 278 times | Joined on Dec 2009 @ Oregon, USA
#4
excellent! is there a good single resource for gui design specs in qt creator that is specific to the n900? i know there is some info sprinkled around the forums, but it's difficult to find, and is required to insure that buttons, etc are the correct dimensions to display correctly on the device.
 
Posts: 53 | Thanked: 51 times | Joined on Feb 2010
#5
The screen resolution is 800 by 600 so there is the size you could use?

However, try http://maemotalk.com/2009/09/18/offi...nterface-docs/

There are three links on the main screen, Hildon 2.2 UI Style Guide, Hildon 2.2 Widget UI Specification and Fremantle Master Layout Guide.

They all link to Nokia spec sheets.

You also have a thread: http://talk.maemo.org/showthread.php?t=31832

Hope that helps.
 

The Following User Says Thank You to TheAccountant For This Useful Post:
Posts: 61 | Thanked: 43 times | Joined on Aug 2008
#6
Originally Posted by TheAccountant View Post
The screen resolution is 800 by 600 so there is the size you could use?
It's 800*480 and application area only 800*424.

Last edited by harriva; 2010-06-20 at 17:45.
 

The Following 2 Users Say Thank You to harriva For This Useful Post:
Posts: 53 | Thanked: 51 times | Joined on Feb 2010
#7
Sorry.

My bad, I did a quick google, saw it was 800 by 480 but my hands typed 600!
 
Posts: 52 | Thanked: 8 times | Joined on Apr 2010
#8
Originally Posted by harriva View Post
It's 800*480 and application area only 800*424.
Unless you make the window fullscreen, you can use the whole resolution then. Gotta make sure to put a close button in the window manually though.
 
Posts: 190 | Thanked: 129 times | Joined on Mar 2010 @ Bavaria, Germany
#9
Better don't teach people to use the autoconnection slots like "on_myButton_clicked()". They only cause errors you won't find if you ever rename something.
Hand-made connect()ions at least output an error on your commandline.
 
Posts: 1,141 | Thanked: 781 times | Joined on Dec 2009 @ Magical Unicorn Land
#10
Great guide, thanks. It makes me interested in programming on my N900, I got tired of waiting for PR1.2 and never regained the motivation after it finally came out...

One question, though. The simulator part does not work for me, it fails every time with a build error (ui_mainwindow.h error 127) but deploying to N900 works fine. Strange...

Edit: Oops, I didn't mention I was trying that on MS Windows. On Linux it does not work either, though. Same thing, simulator fails but deploying to N900 works. In Linux I get this:

Code:
Starting /home/paul/NokiaQtSDK/Projects/HelloWorld-build-maemo/HelloWorld...
/scratchbox/tools/bin/misc_runner: /targets/links/scratchbox.config: No such file or directory
/home/paul/NokiaQtSDK/Projects/HelloWorld-build-maemo/HelloWorld exited with code 126

Last edited by stlpaul; 2010-06-21 at 23:59.
 
Reply


 
Forum Jump


All times are GMT. The time now is 15:39.