I bought an iPAQ h3765 in 2002, which I ran Familiar Linux on. It used Matchbox 0.5, X11, gtk 1.2, etc. I wrote apps for it that used gtk and that used X11 directly. It tracks a personal database, and financial spreadsheet. It has limited media playback capabilities. It has a decent book reader and a painfully obnoxious alarm clock.
It has lasted well, and it still works. But its battery is old (like half an hour), it has no memory expansion (so is useless for media playback), and there is no incentive to carry it out of the house with me.
Since buying the iPAQ, I have begun carrying around a cellphone everywhere I go. I want a cellphone PDA now. I want OpenMoko, except that the project was an abysmal failure due to poor/non-existant leadership. I want an iPhone, except that I don't want to waste my time fighting with an intentionally-closed OS. Plus I want to just write for X11 without effort, so I can port my old applications over and not be tying myself to a single ridiculous platform. I want an Android phone except, you know, it's exactly the same as iPhone....for every time Google has said the word "open" in connection with Android, there has been an instance of Google telling a blatant lie [update 2012: I was just impatient].
So here comes Maemo! It is not dissimilar from Familiar (my old iPAQ distro) brought into the 21st century. It uses debian packages and X11 and Matchbox 1.2 and GTK 2.0, etc. All of the pie-in-the-sky design documents I saw for OpenMoko roughly describe fully-fleshed out systems that actually exist in Maemo. It is great. "Soon" there will be a cellphone (Nokia N900) running this OS. But while I'm waiting for the cost of the phone and the plan to decrease, I have purchased a Nokia N810. They're like an iPAQ, except they have more of everything, have this great Linux installed at the factory, wireless, GPS, memory expansion, keyboard, and webcam. But no cellular.
I am very impressed that this device remains running in its powered down state. When it is idle (battery life of like 4-8 days), it still maintains a WiFi connection (listening for voip calls, for example).
Anyways, now I am going to document my struggles with this device. I hope that this information may prove useful to someone else who wishes to develop for Maemo.
So my first struggle is setting up an SDK for this thing. I didn't really want to run a bunch of blind scripts from Nokia that were designed to set up an SDK with Scratchbox 1. I looked for a Scratchbox 2 setup and found "Maemo SDK+" but their repository appears to have experienced an epic fail.
So here's what I did:
~/n810/sdk/binutils-build$ ../binutils-2.19.1/configure --target=arm-linux-gnueabi --prefix=/home/greg/n810/sdk --with-build-sysroot=/home/greg/n810/sysroot --program-prefix=arm-linux-gnueabi- --with-sysroot
~/n810/sdk/gcc-build$ export CC=/usr/bin/gcc
~/n810/sdk/gcc-build$ export CC=/usr/bin/gcc --enable-languages=c,c++ --target=arm-linux-gnueabi --prefix=/home/greg/n810/sdk --with-build-sysroot=/home/greg/n810/sysroot --with-sysroot=/home/greg/n810/sysroot --program-prefix=arm-linux-gnueabi-- In the process, I discovered that the rootstrap is missing some development features, like symlinks from libc.so to libc.so.6 and so on. So I copied the /usr/lib/libc.so script from my maemo (a symlink doesn't not suffice for libc), and I ran (as well as making other symlinks as they presented themselves):
~/n810/sysroot/usr/lib$ ln -s ../../lib/libm.so.6 libm.so
- Then I downloaded a ton of packages by hand from http://repository.maemo.org/pool/maemo4.1.2/free/. I used "ar x" to get inside the .debs and then in my sysroot I ran "tar xzvf ../data.tar.gz" to extract them. So I installed in this fashion libx11-dev and everything else needed to build gtk programs. In theory apt-get will work under sb2 somehow, but I didn't make it that far.
- I set up scratchbox2, which helped a lot in building nvi. Scratchbox2 was mostly self-explanatory, with "sb2-init maemo /home/greg/n810/sdk/bin/arm-linux-gnueabi-gcc" performing mostly as desired. There were some gotchas. One is that I had to fix the path by adding a "SBOX_MODE_PATH=..." to the end of ~/.scratchbox2/maemo/sb2.config. Debian had moved some files from /sb2 to /usr/share/scratchbox2. Also, I needed to manually specify that the path in which "gcc" pointed at the arm-linux-gnueabi-gcc variant came first. For some reason, this gcc really needed to be a symlink rather than the copy which gcc had installed in ~/n810/sdk/arm-linux-gnueabi/bin/gcc, so I deleted the copy and made a symlink. *shrug*
But I do not really use Scratchbox2, except to deal with programs with broken autoconf.
So now I'm building my GTK applications for iPAQ. I can add them to the application launcher thingy menu by creating a file /usr/share/applications/myapp.desktop:
[Desktop Entry] Encoding=UTF-8 Version=1.0 Name=myapp Comment=my app is mine Exec=/usr/bin/myapp Icon=terminal Type=Application X-HildonDesk-ShowInToolbar=true X-Osso-Type=application/x-executable
My apps do not respond to fullscreen requests. That is a problem.
I want page up/page down to work in xterm. There's a way to get at the functionality using a "toolbar" but that wastes screen real estate for keys. For every other key I need, I was able to use xmodmap (see this thread for details). That was so easy, I figured it had to be capable of taking this on. Indeed, I added the following definitions:
keycode 104 = Return Escape Escape Escape Escape keycode 111 = Up Prior keycode 113 = Left Home keycode 114 = Right End keycode 116 = Down Next
So I can do Fn+D-pad center and get escape, plus I have page up/page down/home/end by holding down shift with the d-pad directions.
However, this was totally useless, as the Maemo xterm gobbles these keys and turns them into scrollbar ops! I investigated some and this is not your typical overeager xterm configuration, this is a specialized app called osso_xterm. osso_xterm is advantageous for a variety of reasons, I'm sure, and the extensions (easy font control, use of the maemo menu system, good response to fullscreen) all work so easily that I do not want to give it up. But it uses something called "VTE", which is basically a GTK widget that provides a terminal. Very slick, and so on, but it has this flaw. It hardcodes certain _useful_ keys to useless functionality. The most moronic part is it contained remappings for both Prior and KP_Prior. It could have trapped just one of them and let us bypass it but nooOO!! Well, plus at least one of the guys to hack on it was kind of a moron, but I digress (and aren't we all, at moments, anyways?). Anyways, it's open source software sooooooo...
Now, I am not good at unraveling what to do when configure fails. It didn't want to build under scratchbox2 effortlessly because it wanted some more of a gnome environment than I had provided. So be it. I threw together a Makefile and config.h manually and was eventually able to compile it in the hackiest fashion possible. Then I modified it. I fixed what I perceive to be a bug applying shift to special keys (if the key says it doesn't care about modifiers, it shouldn't care about modifiers), and I also removed these hardcoded scrollbar operations. Problem solved, osso_xterm is now totally usable.
So this is a little lesson in open source. The things I am up against are unwieldy behemoths, just as in any closed platform (such as windows) or semi-closed platform (such as OS X). But unlike OS X, my enemy is autoconf/automake, which are very easy to bypass. My enemy is a short-sighted open source hacker, and I am his equal (he grants me this right, I love him for it). And so on. Result = victory. Anyways if anyone also wants page up to work in osso_xterm,
Oh, discovery! That useless key below the "home" key is escape!
I figured out fullscreen. Apps have to handle it independently. There is a key "HILDON_HARDKEY_FULLSCREEN" (GDK_F6) that you receive KeyPress events for, and on those you can call gtk_window_fullscreen()/gtk_window_unfullscreen(). Easy enough. The wm doesn't handle it (neither does HildonWindow) because so many apps have specialized fullscreen behavior. The gtk_window_*fullscreen() functions just (I think) generate the WM events to tell the WM to do it. So it should be easy to do outside of GTK as well.
It is exactly this easy to generate outside of GTK:
static void toggle_fullscreen(Window win) { XClientMessageEvent xclient; memset (&xclient, 0, sizeof (xclient)); xclient.type = ClientMessage; xclient.window = win; xclient.message_type = XInternAtom(ggl_x_display, "_NET_WM_STATE", 0); xclient.format = 32; xclient.data.l[0] = 2; /* _NET_WM_STATE_TOGGLE */ xclient.data.l[1] = XInternAtom(ggl_x_display, "_NET_WM_STATE_FULLSCREEN ", 0); xclient.data.l[2] = 0; xclient.data.l[3] = 0; xclient.data.l[4] = 0; XSendEvent (ggl_x_display, x_root_win, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient); }
I know this is off-topic for Maemo, because Maemo is a piece of software. But the fact of the matter is that the only reason anyone gives a shit about cellphone operating systems is that they run on cellphone hardware. In fact, the OS is usually so customized that there is a roughly one-to-one correspondence between hardware and OS. That's why it's so important that it be open from the start -- because you won't have the opportunity to replace it with an open OS later. (yeah, I know, this isn't 100% true, but it's pretty close in practice)
So the quality of the hardware that runs Maemo is very important. I have a Nokia n810. The n900 -- the modern cellphone variant of the n810 -- looks about the same and likely has similar characteristics.
The biggest problem is durability. I've dropped my n810 twice in the 8 months that I've owned it, which is far fewer times than I've dropped my cellphone in that time span. This sucker only leaves the house about once a month, it really doesn't see much abuse. Yet one of the corners of its cheap plastic casing is demolished. The slide mechanism for the keyboard is failing. The keyboard no longer slides smoothly in and out and needs to be futzed with each time to get it past a catch. It never 100% closes anymore. The keyboard-open sensor is constantly sending false alarms. In addition, the keyboard just isn't that great. The control key is nearly impossible to use for some reason. I suspect that the action of pressing the second key causes a momentary and nearly unavoidable loss of contact on the control key.
Another big problem is the lock implementation. To unlock the device requires a herculean effort focused on a small obnoxious spring-loaded switch. But sliding the keyboard out also unlocks it. Even before I dropped it, the keyboard would slide out enough in my pocket to unlock it from time to time. So here we have the worst combination: it is difficult to intentionally unlock it and easy to accidentally unlock it. Top it off with the fact that it relocks after a timeout even when the keyboard is out, a physical configuration in which it is even harder to toggle the little unlock switch.
Plus the GPS barely works (though this may be because gpsd crashes easily), it gets hot when you use the CPU (which is kind of neat just because it doesn't get hot if you don't use the CPU, but I think better could be done), and it is bigger and heavier than most of its competitors. And the battery is a little subpar when the device is in actual use (even light usage).
I cringed when I was shopping for this device because I did not want to buy a shitty piece of hardware that would fall apart in less than a year (such as one with a hinge or sliding keyboard), but I said to myself "Nokia makes millions of cellphones that survive millions of hours in millions of pockets, surely have overcome the limitations of hinges and sliders." Maybe they did, but they didn't bother with this one. It's a piece of crap unworthy of sitting in your pocket no matter how great the software may be.
Keep in mind, their chief competition in reality is the iPhone, which started out at least 10x better than the n900, and has been improving dramatically ever since.
And while I'm dishing on Nokia, let me say that Maemo is overall a disappointment too. It is awesome for me because it uses X11, and because I do not hate its UI (in fact, it is based on Matchbox which is my favorite palmtop window manager). However, the custom parts of their code (such as their task manager) are very fragile, poorly documented, and unsourced. Their source distribution is actively frustrating, as they will provide source for most of the process you are inspecting, but not all of it. And the crucial part that you need to work around or conform to -- the part you are interested in -- is always missing. In other words, it's basically the same experience as Apple's OS X. I know this road too well: I could own this thing for five years and it will still have the nuissance failings that I discovered in the first week of owning it. Major bummer! If I use a true open source system for five years then I always overcome the vast majority of its software shortcomings over time (for example my newish Lenovo IdeaPad has already had most of its kinks worked out after only 4 months).
Honestly, I find myself wishing they'd written their crap in Java simply because there are a number of decent Java decompilers out there. I can't wait until Android makes me eat those words!