![]() |
Linux Maemo Development Guide
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:
Code:
chmod u+x Nokia_Qt_SDK_Lin32_offline_v1_0_en Code:
./Nokia_Qt_SDK_Lin32_offline_v1_0_en Code:
sudo ./Nokia_Qt_SDK_Lin32_offline_v1_0_en 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 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 HTML Code:
Version: 10.2010.19-1.203.1 Load up the App Manager: Code:
Menu -> App Manager 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 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 To add the N900, populate the following fields: Code:
Name: Nokia N900 You should be presented with the following: PHP Code:
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() 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" 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. |
Linux Maemo Development Guide (Scratchbox)
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: Quote:
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 If you use Ubuntu: Code:
sudo ./maemo-sdk-install-wizard_5.0.py Code:
su -c ./maemo-sdk-install-wizard_5.0.py Code:
su Code:
./maemo-sdk-install-wizard_5.0.py 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 Code:
vm.mmap_min_addr = 0 Then run: Code:
sudo sysctl -p Code:
sudo ./maemo-sdk-install-wizard_5.0.py 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 PHP Code:
First, we need to add the extras repositories: Code:
vim /etc/apt/sources.list Code:
#Extras You can now go ahead an update apt’s local cache: Code:
fakeroot apt-get update Code:
fakeroot apt-get dist-upgrade Code:
fakeroot apt-get install libqt4-gui libqt4-dev 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) & Code:
#!/bin/sh 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:
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 Code:
ls Code:
[sbox-FREMANTLE_X86: ~] > ls Code:
cd HelloWorld Code:
[sbox-FREMANTLE_X86: ~] > cd HelloWorld Code:
qmake -project Code:
qmake Code:
make Code:
[sbox-FREMANTLE_X86: ~/HelloWorld] > qmake -project Code:
run-standalone.sh ./HelloWorld |
Re: Linux Maemo Development Guide
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 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... |
Re: Linux Maemo Development Guide
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.
|
Re: Linux Maemo Development Guide
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. |
Re: Linux Maemo Development Guide
Quote:
|
Re: Linux Maemo Development Guide
Sorry.
My bad, I did a quick google, saw it was 800 by 480 but my hands typed 600! |
Re: Linux Maemo Development Guide
Quote:
|
Re: Linux Maemo Development Guide
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. |
Re: Linux Maemo Development Guide
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... |
All times are GMT. The time now is 07:15. |
vBulletin® Version 3.8.8