N900 development Part 2

Before you continue on reading, understand that a prerequisite is for you to start with part 1 and especially Maemo’s Getting Started guide.

For this guide, I’ll be showing how to create multiple widgets in one window. The code from Maemo provides you one window with one widget (the button). You cannot add on more widgets to the example just like that. Adding >1 widget to a HildonWindow will still allow the program to compile, however if you run it you will have to expect an error message that looks something like “… as a GtkBin subclass a HildonWindow can only contain one widget at a time; it already contains a widget of type …”

So the alternative is to create one vBox (or hBox) and pack all other widgets (including other hBox and vBox) inside of it. The end result from the sample should be an applicati
on with an interface that looks like this

3-button hello world app on N900 emulator

3-button hello world app on N900 emulator

The blog formatting makes it a bitch to paste my code here, so just download the code into scratchbox environment with something like this:

wget http://dartarrow.net/wp-content/uploads/2010/03/hworld.c

You should now be able to compile the program with the following line:

gcc hworld.c `pkg-config hildon-1 --cflags  --libs` -o hworld 

Execute the programe


And voila.

Take note of how the hbox is prepared and then packed into the vbox. Understanding the interaction is key to your own gui development with C, GTK, and Hildon.

Credit where credit’s due, I stole and modified the code from Maemo’s Wiki

N900 Development Part 1

This section shows you how to get started (Your baby steps in N900 development starts by starting up the environment. And gettin some sample codes from the community).

Development for Maemo currently utilizes GTK, so if you’re planning on developing something for Maemo devices I’d recommend you start here and then proceed to the Maemo Wiki.

Step 1 in development is setting up the SDK which can be done by following the guide here or here

If you’ve already done that, then start up Xephyr (and here’s how). From a terminal first startup the SDK

sudo sh -c 'echo 0 > /proc/sys/vm/vdso_enabled' 
Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb & 

Go into scratchbox


Switch to the x86 environment

sb-conf se FREMANTLE_X86 

export the display and start up

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

You will get a screen that looks like this
xephy-n900. Remember to click, click + drag and just play with it as much as possible to just make sure you get familiar with the interface :)

You can then look through this pseudo-maemo-emulator for applications you can install. You can start with the sample widget – the process of which is nicely documented here. Or better yet, write (and compile) your own obligatory Hello World program as documented here

Maemo SDK installation on Linux

There are 3 Options on how to install the Maemo 5 SDK,
1. The GUI Installer (recommended)
2. Script based installer.
Instruction for both can be found here
3. Manual installation

This is a Manual Installation instruction, covering the installation of Scratchbox, Nokia + Maemo binaries and Xephyr X server – which are the prerequisites for development. The host machine here is Debian based machine. so k/ubuntu will work. I’ve tried this on Kubuntu 9.10 with a 32-bit architecture and can confirmt that it works. I can’t guarantee you it will work on a 64-bit machine.

  1. Install Xephyr
  2. sudo aptitude install xserver-xephyr

  3. Download / Install scratchbox
  4. Note: before you start, take note that scratchbox installs by default in “/scratchbox” so make sure you have about 4GB’s in your “/” partition.
    sudo sh -c 'echo "deb http://scratchbox.org/debian/ maemo5-sdk main" > /etc/apt/sources.list.d/scratchbox.list'
    sudo aptitude update
    sudo aptitude install scratchbox-core scratchbox-libs scratchbox-devkit-qemu scratchbox-devkit-debian scratchbox-devkit-doctools scratchbox-devkit-perl scratchbox-toolchain-host-gcc scratchbox-toolchain-cs2007q3-glibc2.5-arm7 scratchbox-toolchain-cs2007q3-glibc2.5-i486 scratchbox-devkit-svn scratchbox-devkit-git scratchbox-devkit-apt-https

  5. Setup Scratchbox
  6. in the terminal, first make user you are logged in as your default user. Not the root user. And type:
    sudo /scratchbox/sbin/sbox_adduser $USER yes
    sudo ln -s /scratchbox/users/$USER/home/$USER /scratchbox/users/$USER/home/user
    This is optional, But I’d do it anyway just in case : sudo sh -c 'echo "nameserver" >> /scratchbox/etc/resolv.conf'
    sudo sh -c 'echo "nameserver" >> /scratchbox/etc/resolv.conf'

  7. Setup Mamemo Packages
  8. You will need to ensure:
    1. your group membership is registered in the current terminal
    2. VDSO support is disabled,
    to do so run these in the terminal: newgrp sbox
    sudo sh -c 'echo 0 > /proc/sys/vm/vdso_enabled'

  9. Log into scratchbox environment
  10. /scratchbox/login If this works, you will be inside of the scratchbox environment; and you will see something this in the terminal: [sbox->:~]>

  11. Configure the scratchbox x86 and armel target as such:
  12. sb-conf st FREMANTLE_X86 -c cs2007q3-glibc2.5-i486 -d perl:debian-etch:doctools:svn:git -t none
    sb-conf st FREMANTLE_ARMEL -c cs2007q3-glibc2.5-arm7 -d qemu:perl:debian-etch:doctools:svn:git -t qemu-arm-sb
    it is safe to ignore the warnings here.

  13. Now download the rootstraps:
  14. wget http://repository.maemo.org/stable/5.0/armel/maemo-sdk-rootstrap_5.0_armel.tgz http://repository.maemo.org/stable/5.0/i386/maemo-sdk-rootstrap_5.0_i386.tgz
    If networking doesn’t work inside of scratchbox, check your DNS server settings. Unfortunately there’s no `ping` inside of scratchbox so the only way to do this is to edit /scratchbox/etc/resolv.conf from OUTSIDE of scratchbox and paste the following:
    From inside scratchbox, paste the same lines to “/etc/resolv.conf”

  15. Now switch to the x86 target and install the binaries,
  16. sb-conf se FREMANTLE_X86
    sb-conf rs maemo-sdk-rootstrap_5.0_i386.tgz
    sb-conf in -edFL

  17. Add the nokia repos
  18. You’ll need to do some apt trickery here for maemo related items. So first accept the EULA here and copy the URL, paste the it into /etc/apt/sources.list (inside scratchbox) and then:
    apt-get update
    fakeroot apt-get install maemo-sdk-debug nokia-binaries nokia-apps
    Keep the url, you will need it later on in this installation

  19. fix the scratchbox symlinks
  20. According to the instructions from maemo you will need to remove a symlink and replace it with a folder so do this in the terminal: rm /targets/FREMANTLE_X86/opt
    mkdir /targets/FREMANTLE_X86/opt

  21. repeat the same for armel architecture
  22. At this point the x86 target is setup, you will need to do the same for the armel target.
    edit the file /etc/apt/sources.list and paste the URL that you got previously after agreeing to the EULA
    sb-conf se FREMANTLE_ARMEL
    sb-conf rs maemo-sdk-rootstrap_5.0_armel.tgz
    sb-conf in -edFL
    apt-get update
    fakeroot apt-get install maemo-sdk-debug nokia-binaries nokia-apps
    rm /targets/FREMANTLE_ARMEL/opt
    mkdir /targets/FREMANTLE_ARMEL/opt

  23. Startup Xephyr, with the x86 targets pointing the output to it
  24. export DISPLAY=:2
    af-sb-init.sh start
    And from OUTSIDE the scratchbox environment: Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb & And you will be greeted with a very reassuring emulator-like environment emulating the Maemo 5 on a Nokia N900 😀

What you need to know about the Nokia N900

Alright my full post on this is really long so here’s a minified version with links to the full text. I never wanted this to be a simple list, because I don’t feel it does justice to the product. So if something mentioned here is new to you, find time to read the full text.

1. the Nokia N900 is not a smartphone read more…
2. It’s not meant to give you “web-like” experience read more…
3. It is not sexay read more…
4. It uses a resistive screen read more…
5. The display is almost entirely landscape read more…
6. The Hardware Keyboard is pretty small read more…
7. Choices of available apps are small and scattered read more…
8. Social Media integration isn’t quite there yet read more…
9. TFT LCD and not AMOLED read more…
10. OGG support is not default read more…
11. The MyDocs partition is on vfat read more…
12. Pluging in the N900 to your laptop will unmount ‘MyDocs’ read more…
13. The Battery life is just as expected (approx 6 hours). read more…
14. It runs on the `armel` architecture and not `arm` read more…
15. Multitasking is awesome read more…
16. The peripherals included are of pretty high quality read more…
17. The hardware is deceptively great read more…
18. Almost anything from linux – now at your palm read more…
19. Yes a terminal comes preinstalled read more…
20. You really own your phone read more…

20 things to know about the N900 before buying one

Buyer Beware – What you should know about the n900 before buying one.

I’m writing this after a whole week of playing with my new toy (courtesy of WOMworld/Nokia). Most of what’s here are gotchas, which any new owner will learn within an hour. Some others by the end of the day. And some almost never until/unless you actually try it out. Hopefully this will ease any frustrations of a new user, but mostly I’m writing this down to manage expectations. Know what you’re buying before you get one. Most of what I’m writing is (for one reason or another) not provided by the Marketing Guys at Nokia anyway. 😉

  1. The Nokia N900 is not a smartphone
  2. Unlike a lot of the other N series or the Androids or the iPhone, the N900 is not a Smart Phone. Nokia themselves call it a Mobile Computer, some call it a tablet. I’ll call it a PDA – that runs on GNU/Linux and has the capabilities of a mobile phone. So don’t expect a phone with the capabilities of a micromini computer, it’s a (pretty powerful) micromini computer with the capabilities of a phone. That said, there really is nothing else like it in the market, the iPhone is a sexy phone which fits in well with the Mac Lifestyle. The Nexus One is a good phone with a good amount of processing power available, but they are both primarily intended to be a phone. I will however include some comparison to both the iPhone and the Nexus One throughout this page as a benchmark.

  3. It’s not meant to give you web-like experience ..but…
  4. The N900 isn’t meant to give you web-like experience with desktop apps, it is meant to give you the full-fledged web experience in your 3.7″ screen. The jury’s out on how good an idea that actually is; but for now i have no real reason to complain – except for the fact that Flash (macromedia) is a bitch to deal with.

  5. It is not sexay.
  6. There’s no streamlined sides as per the iPhone. Protruding hardware buttons are all over the place. It is about twice as bulky as the iPhone or the Nexus One. The camera protrudes a tiny bit which is enough to make one side look thicker than the other when placed on a flat surface. The glossy black housing is appealing to me, but that’s about it.

  7. It uses a resistive screen.
  8. Most other smartphones (Nexus, iPhone) you will know uses Capacitive Screens. Capacitive screens require a Human Touch. Specifically from your fingers. Not your fingernails, not your thumbnails, not a stylus. Resistive screens are generally the exact opposite. In addition you will need to use a little more force. Resistive screens are not known to have multi-touch, so don’t expect one anytime soon. However as far as resistive screens are concerned, this one is pretty responsive. Plus I actually enjoy using the stylus sometimes. The resistive screen allows for things like these

  9. The display is almost entirely landscape.
  10. This is hardly a hardware issue. Running Everything in portrait mode tops the wishlist, so I expect a patch to be available for Maemo 5 soon enough, but as of now the only thing you can actually run in both modes seems to be the Phone application as well as the Web Browser (hidden feature as off now). Even the Virtual Keyboard doesn’t work in portrait mode.

  11. The Hardware Keyboard is pretty small.
  12. I can’t imagine being able to effectively use the keyboard without nails. The keys are really close to each other. This is something that cannot be fixed via a software upgrade (duh) so you’re pretty much stuck with it. There is a Virtual Keyboard available on the N900 which works way better for me as opposed to the hardware keyboard. The hardware keyboard and its layout is something that Nokia can learn from the HTC Dream (or HTC G1 depending on where you are).

  13. Choices of available apps are small and scattered.
  14. You may find and install applications from 3 different locations:
    1. Ovi Store – browse it from the web.
    2. Application Manager – Basically some apt-like app with icons of the application, you can add different catalogs to access more application.
    3. The Web – There are 3rd party independent app providers that allows you to install their applications, this includes Mozilla which provides Firefox for the N900
    This is nothing compared to the 60 Trillion apps for iPhone, but it’s currently lean, and constantly growing. Also with more and more linux applications being ported – or rather recompiled – for the Maemo, brace yourself with the Linux problem of Too Many Application.

  15. Social Media integration isn’t quite there yet.
  16. The Facebook app / widget only shows your your contacts status, if you want to comment you will need to browse to facebook.com. The only thing that works well is sharing pictures. I Haven’t found a good enough twitter widget although the Application Mauku is pretty good. I don’t see whats great about witter despite the ravings. The Twitter application is alright – read about it here. The application Hermes seems to have some great potential. But none of these comes default. Neither does the Yahoo or MSN IM Plugins. All these will have to be installed from the extras-devel repository which is relatively easy to install but not something I’d recommend to just any non-techie user.

  17. TFT LCD and not AMOLED
  18. Which makes the screen itself almost as thick as an iPhone. However I dare say I prefer TFT over AMOLED on a phone (based solely on what I see from a Nexus One). The Nexus screen is amazingly reflective and the colours look surreal, almost fake. The bulk that comes with a TFT however – thats a different story.

  19. OGG support is not default.
  20. OK fine, so everybody uses MP3’s; but its plain rude to use a Debian derivative without including the defacto Free / Open Source standard for encoding music. Sure you can install the OGG support, but I take this as a sign of Nokia ignoring the FOSS crowd who are (IMHO) the first to jump at the chance to own and contribute to the N900

  21. The MyDocs partition is on vfat
  22. I don’t know why this was done this way; perhaps to simplify the process of using the phone as a Mass Storage device?. But this is 1. another sign of Nokia ignoring the FOSS crowd and 2. Just makes it that much more difficult to hack. It may be possible to reformat the partition to ext2 but I sure as hell ain’t gonna try. So to those of you who intend to install debian, take note of this gotcha first.

  23. Pluging in the N900 to your laptop will unmount ‘MyDocs’
  24. If you’re connecting the Phone as a Mass Storage device, the phone itself will unmount the partition /home/user/MyDocs which is where your 20 plus gigs of storage is. This is probably done to eliminate problems with 2 machines mounting the same device. But it (in all likelihood) will cause a problem when you try to install Debian. I can’t confirm this, it’s probably just a gotcha to take note of.

  25. The Battery life is just as expected.
  26. Normal usage (3G internet always on, some surfing, some widgets running, some maps, some chatting) gives you about 6 hours. Thats not really much difference from a Nexus or an iPhone with the same amount of productivity. While that is nowhere near my existing phone (Nokia 3110 or something) which gives me 3 days of normal usage, it is within current expectations – relative to the other options at least.

  27. It runs on the `armel` architecture and not `arm`
  28. What this means is that you will need to look in debian’s armel repos instead or arm. If you don’t get what this means then it probably doesn’t concern you so don’t worry about it.

  29. Multitasking is awesome
  30. Thats right, no more rebooting the phone just because you accidentally turned on 3 *gasp* applications. Flash is a memory hog, so is Firefox (well whats new) but running about 5 different appilcations at the same time, and some widgets in the background and still being able to use Firefox is amazing enough to me.

  31. The peripherals included are awesome
  32. Nokia definitely did not skimp on this one. The earpugs blocks out all sounds and there’s 3 cover sizes to choose from. The charger comes with an adapter which allows you to use any(?) existing Nokia charger. The data cable looks great. The composite TV cables (and all the cables in fact) are high quality material. Enough to make any iPhone or Nexus One owner red with envy.

  33. The hardware is deceptively great.
  34. Reading through the specifications does not do it justice. Make no mistake – there’s no Snapdragon (the current Holy Grail of ARMs) here, the CPU runs at about 600MHz as opposed to the 1GHz of a Snapadragon. The internal 0.3MP camera is horrible but I suppose good enough for video calls. Here’s where the fun start: there seems to be a dedicated GPU which supports OpenGL and a Digital Signal Processor both running at approx 450MHz which offloads the 600MHz Coretex from anything besides the OS and the Applications. There is 256MB of Dedicated RAM and 768MB Virtual Memory which seems to handle about 6 apps simultaneously pretty well. The resolution is the best I’ve seen so far – 267 PPI (Pixels Per Inch). Nexus One’s has 251 PPI which is really close; both make the iPhone’s 163 look pathetic. The 5MP camera with a Carl Zeiss lenses takes awesome pictures. And 32GB Internal Storage? That almost fits all my pr0n. Can’t argue with the TV out either.

  35. Almost anything on linux – now at your palm
  36. I’ve installed aircrack-ng, nmap, openssh-server (yes. server.) and a shitload of other applications that I’m used to having on a regular Linux Desktop. You also have the ability to install Debian on a chroot environment and apt-get install everything. I haven’t actually tried this, but STFG and you’re bound to find someone who did. Just remember the vfat.

  37. Sure a terminal comes preinstalled
  38. The shell is ash and runs BusyBox. There’s a few flaws though, like the fact that /usr/sbin is not a part of the $PATH which means simply typing `ifconfig` will not work – you will need to specify the full path. Also the virtual keyboard will not work because there’s no bloody [enter] button. That’s probably an oversight on Nokia’s part – or mine. I kinda doubt it’s mine. A virtual [tab] key is always available which allows for autocomplete. Sweet.

  39. You really own your phone
  40. Rooting the n900 is Really Easy. This is admittedly not the first thing most people look at, nor is it that much simpler than rooting a Nexus One; but for those who want root, it takes 3 very easy steps to get there. This is not something you can say about the iPhone; the Android phones lie somewhere in between in this aspect. Also, there’s a debian chroot app in the store, all of which ensures you own the phone, and not the phone pwns you.

What you really need to know however is that Maemo as a platform is most likely every geeks wet dream. It’s a tinker toy with all the (barely realised) potential in the world. If you want a smartphone that works out of the box get a iPhone or a BlackBerry, if your life revolves around Google and specifically Google Apps, get the Nexus One.

If however – you want a gadget and the opportunity to contribute to the direction and the evolution of a new platform – this is for you.
If you want a tinkertoy that does almost anything you want, this is for you.
If you want the best hardware in a mini package, this is for you.
If you are a GNU/Linux user and are addicted to the power and freedom of FOSS, this is for you.
If you don’t mind putting in some effort and later feeling the rush of success, and having just as many ‘Eureka!!’ moments as ‘OMGWTF What were they THINKING’ moments, then this is for you.
If you want port scanners, vulnerability scanners and (almost) everything else you find on a Linux desktop on a mobile device then this is for you.

Most important – I have listed in full glory all the downsides of the phone. If you are still reading this, and still considering the n900, then this is for you.

I only hope that Nokia listens to its users (and developers)- especially the unpaid FOSS developers without whom Maemo will not even exist. There are small lil issues mentioned that will concern Linux hackers that needs to be fixed. @Nokia – you’re in FOSS grounds now, you can’t turn your backs on us.