Archive for October, 2007

QPE 4.3.0 plus QEMU

October 28, 2007

Trolltech GPLed and released its Qtopia Phone Edition 4.3.0 distro a couple of weeks ago, at the same time adding Neo1973 as a supported device. I had a look at the “Phone” part of the package and while I was never a fan of Qt, I like a number of things in qtopia design, although I have also tried running Qtopia on my phone and the interface was not terribly nice for a first time user. Like, on one hand I like the fact that they came up with a custom input method, avoiding getting into obscure deals with the popular T9 input method which is patented (which they could easily do). On the other hand though I couldn’t comfortably enter message text using this input method. The cool bit is that it’s now all open-source there’s no way back :)

Having for a short time been involved in the development of gsmd in OpenMoko what I like most in Qtopia and at the same time envy the most is that their phone services have a logical design, quite complete set of documentation and probably work. This last thing I haven’t verified but even if not, the logical design alone would be enough to make me happy, seeing how chaotic is gsmd development process. Gsmd has no documentation and also suffers from lack of maintainership which recently changed status to a presence of a very strange maintainership that makes contributing code very hard and probably leads to less progress than when there was no maintainer. Fortunately there’s recently enough work to be done in the GSM support in OpenMoko that doesn’t involve touching gsmd itself.

Qtopia’s phone part is nicely divided into services each of which supports plugins for adding support for exotic modems. The division is quite grain but no too grain and there are full tutorials for writing each type of plugins. The code is not so amusing but it’s quite complete with all standard features implemented, even those not present in any of the supported devices. I was particularly looking in qtopia for GSM multiplexing code and it was there and surprisingly it was written in C (all the rest of Qtopia being C++, making it not directly reusable in other projects) but it was quite ugly and suboptimal, so only useful for comparing the results. At the moment Qtopia doesn’t do multiplexing when running on the Neo1973, there is probably some reason for this and I’m suspecting it is in the Neo1973 hardware or kernel (the kernel’s not a part of Qtopia, it comes from OpenMoko).

What I found useful is development tools that come with QPE, two in particular. The first one is called phonesim and is used for testing the phone services. The second one is atinterface or “phone emulator”. Both tools idea is to simulate a modem which you can talk to using a standard AT command set, but they do it in different ways. Phonesim is strictly a developer tool, segfaults a lot and is supposed to run on the desktop, or wherever you’re coding, although it can run anywhere. It simulates a dummy GSM modem, you can run Qtopia or other tool that talks to a modem (QEMU, gsmd, gnokii) and make it connect to phonesim. Sometimes it will work and sometimes it won’t because phonesim understands just a minimum subset of standard AT (and some of GreenPhone’s modem’s proprietary commands), but is easily extensible. There’s an optional GUI through which you can simulate incoming calls, messages, data packets and more, but basically the GUI is the only source of events. Atinterface on the other hand runs on Qtopia and it takes events from QPE’s phone subsystem. It’s purpose is exposing a modem interface to a laptop or other devices so that they can send faxes or make data calls through a GreenPhone. The interface is hardware independent, i.e. the virtual modem presented by atinterface to your laptop will not depend on whether the QPE is running on a Neo1973 or GreenPhone or HTC. It’s also more standards compliant than the GSM subset emulated by phonesim, but to use it you will need a running QPE and its phone services.

Now what I wanted was tools for easy testing gsmd and/or OpenMoko running in QEMU. Connecting it all together is not exactly simple so I will explain here how to do that. So, we want to run gsmd or QEMU, and we want to use phonesim or atinterface as a virtual modem, so that we don’t have to use a physical modem because the physical modem is a lot of hassle (for example if it’s the Neo modem, it constantly runs out of battery), if you have one. While we’re at it I will also show how to use the physical modem of Neo1973 with a gsmd running on PC, it’s less hassle than testing gsmd on the phone.

We have two parts: a modem (physical or virtual) and a program (gsmd or QEMU). For the communication channel we choose a network socket because sockets are flexible and already supported in many places. For the modem we have three possibilities: 1. a phonesim virtual modem, 2. atinterface virtual modem, 3. a Neo1973 physical modem.

1. Phonesim supports sockets out of the box, so we just need to build and run it. I hacked up a phonesim version that can build outside a Qtopia tree and I included it in the qemu-neo1973 repo at svn.openmoko.org, to build it you only need to check out a recent qemu-neo1973, configure it with

$ ./configure --disable-system --disable-user --target-list=arm-softmmu --enable-phonesim && make

The command

$ (cd phonesim; LD_LIBRARY_PATH=lib ./phonesim -gui ../openmoko/neo1973.xml) &

runs phonesim. The -gui switch is optional. The GUI will only appear after a first client connects. Phonesim now listens on localhost port 12345 and is ready to accept clients. The neo1973.xml file defines a modem behavior resembling the Neo1973 modem (TI Calypso).

2. Atinterface is part of Qtopia, and requires Qtopia. I will not explain here how to build Qtopia. After you’ve built and installed it (I assume the default paths) you will need to first run QPE and then atinterface. For QPE to run you need a modem, we can use phonesim. You can use the phonesim build that comes with Qtopia, to do that run the following command:

$ bin/phonesim -gui src/tools/phonesim/troll.xml &
$ export QTOPIA_PHONE_DEVICE="sim:localhost"

Next, we’ll need to emulate a framebuffer on which QPE will display and then we can run QPE and atinterface:

$ bin/qvfb &
$ echo [SerialDevices] > etc/default/Trolltech/Phone.conf
$ echo ExternalAccessDevice=/dev/ttyS1:115200 >> etc/default/Trolltech/Phone.conf
$ image/bin/qpe &
$ image/bin/atinterface --test -qws

Ready, now we have atinterface listening on localhost:12350.

Phonesim on an OHand laptop

3. To make the Neo1973 modem accessible to a PC over USB we have several options. The u-boot gsm passthrough support turned out unreliable so we will boot Neo into linux, kill gsmd and run netcat:

# killall gsmd
# nc -l -p 5000 < /dev/ttySAC0 > /dev/ttySAC0

Voila, if the usb ethernet is configured (see OpenMoko wiki) , the modem is now listening at 192.168.0.202:5000.

Now we want to connect to our modem from the other side, gsmd or QEMU programs on the desktop. With QEMU the task is easy because it can connect to a socket directly: just append -serial tcp:localhost:12345 (in the phonesim case, in other cases tcp:localhost:12350 or tcp:192.168.0.202:5000) and you should see the system running inside QEMU connect to a GSM network and be operational. Remember that if you haven’t configured QEMU with –enable-phonesim, it uses a builtin modem emulator based on gnokii (yes, yet another virtual phone), which needs to be disabled.

With gsmd the problem is that it wants a character device to connect to, rather than a socket. We will emulate a character device using a tiny program I uploaded to qemu-neo1973 svn yesterday. It will make a pseudo-terminal pair (pty stands for Pseudo-Terminal. Has anyone wondered, if tty is for Tele-Typewriter, why pty is not Pseudo-Typewriter?) and connect the master to the socket. If you’ve checked out qemu-neo1973 and you’re inside the source directory, do:

$ make pty
gcc-3.3.6 -Wall -O2 -g -fno-strict-aliasing -I. -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -g  pty.c   -o pty
$ ./pty localhost 12345
/dev/pts/12

The pty program connected to the modem (change the hostname/port pair accordingly) and it told us that it created a character device /dev/pts/12 to which gsmd can now connect (qemu can also connect to character devices). The device will exist as long as pty is running.

$ /usr/local/sbin/gsmd -p /dev/pts/12 -s 115200 -v ti -m generic

That should be it. Now you can launch a program like openmoko-dialer that uses gsmd and hack away. Phonesim has a nice GUI (alas Qt…) from which you can observe the AT communication with your program.

Moscow and how to not go there

October 21, 2007

Last Sunday I arrived home from my first trip to the east (not south-east), to the bigger brother, Russia and particularly Moscow.

For getting there I decided for an unusual Warsaw-Moscow route through Kaliningrad to save on time and costs, but ofcourse my implementation of the plan in practice was neither cheap nor quick, although I still think the plan was good (and original) and it could work out if I had reserved slightly more time buffer. I ended up taking four trains to get to Kaliningrad, then a bus to the Khrabovo Airport and a KD-Avia flight to Moscow Domodedovo. Each of the four trains had a delay from the schedule so I missed my bus from Olsztyn to Kaliningrad (would be much cheaper than train) and my Aeroflot flight from there (with an Asian-Vegetarian on-board meal I chose from the list of like twenty types of food that the web-app presented me with when buying the ticket online).

On the Braniewo-Kaliningrad train I was sitting next to a guy from Ghana who spoke neither Polish nor Russian and everyone believed that he speaks English, which was not entirely true, and it turned out I was the only person to understand English on the train so I was automatically assumed to have to help him get through the border. On cheap country-border-crossing routes like this I find that some 90% of the passengers are smugglers who, when you meet them, are making the route for some third time on this day and they form something which I believe you can very well call a community, they treat every other passenger on the train as their co-workers and they see many of the same people a couple of times every day. Crossing the border is the routine for them and talking to the exceptional tourists and the border zone security officers is their diversion. So I was seen obliged to fill in the Dominico’s immigration forms and other documents which he only limited himself to tell me that he couldn’t do because he was too confused. He was speaking something between French and English but this language was evidently not his native one because he couldn’t express many things in it (apart from my understanding or not). Dominico posessed a valid Ghanaian passport, no Russian visa and a Belgium residence card which the officers deemed a fake (as I understand – they were speaking Russian and me Polish) but I’m not sure if that was based on any reasoning or just their guess. In the end for the sake of my own getting through the border I had to invent the purpose of Dominico’s visit in Russia and his legal situation and the story behind it because I was unable to get this information from himself, and the train was already delayed by over three hours at this point. The enterprise succeeded and nobody in the carriage had been forced out.

In Moscow I stayed mainly in a residence hall room of Kate who I had last seen in France and of her roommate Nastya (diminutive for Anastasia..). Most Moscow residence halls employ various techniques to prevent strangers from entering the building so the way I entered and parted the 2nd floor room every day (in Russia floors count from 1st floor which is the ground level) was through the window. Everyday in the evening I would climb up to the window clinging to the tube installations on the wall and the bars on the 1st floor windows and then knock the glass and if it was the right window, the person inside would open it and very quickly let you in. This procedure also had further complications due to issues like room assignment and people in some rooms being out of home this day so actually almost every day you had to use a different room in the morning to get out and in the evening get in but seemingly it is something completely normal for the people of the dormitory, nobody is even mildly surprised when a person knocks at their window, enters the room, says hello and immediately after walks out through the door to the corridor. When there’s a party in a 3rd or 4th floor room the guests will use one of the 2nd floor rooms to leave the building after the party finishes at some 3 am. We spent two nights in a Kate’s friend’s friend’s private flat in the outskirts of Moscow when there were problems with the dorm. In Moscow the university residence halls generally don’t have a free internet service in every room (and there’s no WiFI in range in most places, especially not in a dormitory of a non-technical university like MGOU where Kate studies) which surprised me a lot because I remember that in Warsaw in the 90s when having an internet cable in your private home was still very uncommon and the only way most people could connect was through a 56K dial-up modem, you would usually go to a friend in a univeristy dorm to download the latest movies and get music from P2P. Dorms were one of the first places to have a true cable connection and still today use to have the widest bands.

In consequence a big number of the “cost effective” Moscow tourists go daily to one of the McDonald’s in the centre to use internet. There’s one that offers free WiFi for everyone and when you go there you see at every second table (and even outside in the street when it’s not raining) someone sitting with a laptop surfing away and some people are known to spend hours there. The staff in this particular McDonald’s is extremely tolerant.

I visited most of the main touristic sites in Moscow, and many non-touristic attractions that you don’t find in the guidebooks, thanks to the excelent guidance by my host.

I have seen the dead tovarish Lenin and I take the side of the part of population that thinks the body is genuine and not a plastic replica, but I’m not 100% sure, it might be a fake. Moscow in general was very impressive even despite the very bad weather in which I had to appreciate it.

I was slightly disappointed by the gastronomic offering of Moscow but I didn’t have time to get to know it very well (and in my judgements I only consider the part that has a reasonable economic aspect and I’m very low tolerant to pricing (cf. greedy)). If I was to recommend one place for general eating out it would be the Solecito Italian restaurant (pizza dlya gurmanov!) in Nikolskaya street, and for Russian food the canteens at university departments (but then the access to the buildings is restricted to non-students or those who don’t know the cunning tricks to get in, which is not so difficult).

I went with Kate to some of her classes during this week which was interesting because I speak no Russian and they were all in Russian. I was immediately being noticed also because almost all of linguistics students are females at MGOU so in many clases I was the only male and the only person who had a laptop on during the lectures.

We went to a see a movie in the Moscow’s Iluzyon cinema that plays one French movie in French, no subtitles, every month. It was A nos amours, a 1975 production. Later when Nastya was explaining to us the plot, we learnt that we don’t know French sufficiently for watching movies, yet.

The coming back to Poland was again interesting but this time I decided to take the route that most back-packers take, to really cut down on costs this time, which partially worked out. The plan was to take a Moscow-Brest platskart train, cross the Belarusian – Polish border on a Brest-Terespol bus and take a normal polish train from Terespol on. The Brest-Terespol buses go rarely but there are short elektrichka trains that are only slightly more expensive and carry immensely more colourful adventures involving the said smugglers community. First thing was just when I appeared before the customs clearance office door someone ran up to me and asked if I had any cigarettes in my bag and if not, whether I could traffic one box for her (one big box is a legal quantity). In the black plastic bag that I was assigned by this person I later found out was also a bottle. My conversation with the customs officer was along these lines:

– Do you carry any alcohol?

– Yes, one bottle, Sir.

– What alcohol is it?

– No idea, Sir.

– Cigarettes?

– One box, Sir.

– A paczka [Polish for “box”] or a sztanga? [WTF is a sztanga of cigarettes?]

– A box I suppose, Sir.

I was let in, despite the lack of registration in Moscow, and then on the train I started reading a book. When the train was already running, suddenly a lady climbed one of the tables in the wagon and to my exclusive surprise ripped off a piece of the casing of the ceiling and stuffed a number of big, black, flat packets into the hole. This is when I very carefully produced camera and started recording. While she was doing this three persons of the railway staff were passing through the wagon and again to my surprise, they were completely not interested. Also later, just before stopping for clearance in Terespol I am pretty sure I saw someone run out of a rye field by the rail track and collect some objects that must have been thrown from the train, and immediately run away afterwards.

On a Brest-Terespol train

Note: the registration is a requirement of Russian immigration law that states that if you’re staying three days or longer, you should go to a nearest police office with the owner of the place where you’re staying and have the officer put a stamp with the address in your passport – this procedure takes five days to complete. Hostels, however, will do this for you if you’re staying at a hostel, so many people will go to a hostel before leaving Russia and pay some nights at the hostel to get the required stamp (theoretically you can be asked by police to show the registration stamp any day even if you’re just walking around a city, but the risk is very low). It turns out thought that sometimes you will not be asked for the registration at the border at all, when leaving Russia, and even if you are asked for it, the fine (cf. bribe) is less than the cost of five nights at a hostel so this way is often recommended. (I’m not entitled to give legal advice so don’t take this as an advice.)

So this was my first time in Terespol and while waiting for the train home I had a short walk through the town. I noticed that it is a very little town much smaller than I expected. Later I was wondering why I expected Terespol to not be a little town like this, or why I expected anything from Terespol at all. The answer may be that my expectation came from the board-game Monopoly. In its Polish version, that I played when I was very little, I vaguely remember the main hotels or train stations or whatever it was (say hotels) were named something like Hotel Paris, Hotel Warsaw, Hotel Vilnus and Hotel Terespol. And this is I think particularly the only place I had ever seen the name Terespol before so I imagined it to be something important but it actually has a one main street and a couple smaller streets on its sides, a supermarket and a computer shop next to a church with a tower with a clock with no hands (but otherwise a very nice clock!) on each of the tower’s four sides. I will need to check it.

Pictures from the whole trip here.

Holidays snafu

October 1, 2007

And, I’m back from vacations, (for some time already). To prove that, I have pictures of everywhere I went, finally on the web (so people who were there too and forgot to take a camera can stop chasing me with a fork thank you). The vacations were as always totally messed up and all the very little planning that I did, has failed. But that’s the fun in going for vacations. So starting chronologically (or picturogically) first was:

GUADEC 07 in Birmigham, UK, this was actually before vacations, and long ago, but I didn’t have time to put any pictures online before now.

Next was a paragliding camp near Liptovsky Mikulas, Slovakia that I didn’t actually want to go to but was tricked into it by somebody’s evil tricks. I was going to go flying for a week in September, to a totally different place, but a friend called me and said I absolutely had to change the plans and go with her on the beginning of August (which was in three days from the phonecall) because she had already booked a place for her there and also booked the hardware and stuff, and I said ok. The only problem was she was in Italy at that time and had a ticket back to Poland for the same day when the rest of the group was leaving for Slovakia in a van, just they were leaving in the morning and she was arriving in the afternoon. So we settled on taking a train the next day. Ironically when she finally arrived it turned out that the baggage of everyone on this flight had not arrived with them, instead the baggage from a flight with a completely different destination, arrived here and the flight operator, Norwegian Air, said it would take them up to a week to find someone who knows how to hold a map and get the right baggage to the right airport. So, having already booked all the stuff I went to Slovakia alone on the next day to meet the rest of the group, most of whom I had been travelling with before. Unfortunately at some 6 am on the train, in some village still before Slovakian border and being the only person in the wagon I had an encounter with three individuals that robbed me of a lot of things that I would rather not get robbed of, like a phone and a wallet with more money than I normally use to carry. They were nice enough to give me back all the coins from the wallet and the pictures of my exgirlfriend that turned out to still sit in there. The use of violence was limited to accidentally breaking my headphones while one of the three guys started to perform monkey acrobatics on the metal bars often forming part of passenger wagon interiors (I must admit they also stimulate my own monkey instinct but there are usually people watching and also I’m not usually on drugs like these three guys). He accidentally hit my headphones with one shoe while also hitting one of his fellow thieves in the head so hard that he (the owner of the head) started to bleed, but fortunately this fact didn’t worry him much. The railway staff who I contacted soon and the police who they contacted after waiting some ten minutes for the 112 to answer, were useless, but I guess nobody expected anything else of them. I had all the documents and the train ticket still with me so I didn’t have any problems with going further on the journey except lots of wondering about what I could do to recover the phone and the money and not get hurt, accompanied by general hating the whole world (which I permit myself to do because I’m still a kid).

The first day of flying was quite good but the following six days it rained all afternoons and the conditions were rather poor also in the morning. Still, I’m glad I visited the places known by all gliders and also I had not done any thermal flights in the mountains before (as opposed to thermals generated by seas), and Mikulas is just in the center of Tatra mountains. The air is definitely more turbulent in the mountains but the lifts also don’t end at the height of the top of the nearest mountain, they’re often a couple of kilometers high. Another nice thing is we used the chairlifts that are used by skiers and snowboarders in the winter to get to the launch sites, so there was no need for one person (known as the shuttle bunny) to always stay on earth and drive the van to the landing spot. I also finally saw the Chopok mountain that I’ve heard a lot about from skiers but never skied there myself (but this was in the summer and the place was full of hikers and downhill bike riders now, who in the first moment looked at us like we were a suicide group).

When I came home I found out that the workcamp in Serbia for which I was trying to book a place earlier, was already full and the voluntary service association assigned me a place for me on a different project, which started on the next day after I arrived from Slovakia. I have never been to Serbia before and also the event seemed quite interesting, it was going to be making mountain paths and some cleaning and also helping out with some local music festival. Instead I went to the south of France to a camp that started a week earlier than I planned and was about renovating a sanctuary called Notre-Dame-de-Livron, the nearest village being Caylus. Pictures are here. It was absolutely the greatest experience of this summer, like all other workcamps that I went to. The group had 14 people and we were there for three weeks basically, after the work, having a non-stop party, visiting the region (called Tarn-et-Garonne, and its neighbour Aveyron and Rouergue) and also generally making idiots of ourselves in the eyes of the local villagers none of us speaking much French. It turned out though that maybe half of the population there spoke Spanish or Catalan to some degree because this was quite close to the spanish border. Also the nuns of the Carmelite order, that is the owner of the sanctuary, were mostly Spanish emigrants from the time of civil war, so we had no real communication issues there (worth noting that our group ranged from muslims to shintoists, and the nuns had no problem with that). As on other workcamps, I have tried a number of things that I had never done before in my life, some of them perhaps embarassing, but all of the camp was rather crazy and far too many fun things happened to relate here.

After the camp I had three days before a plane from Toulouse would take me home so I went on a short hitch-hiking trip around Rouergue region which is full of medieval castles and also the regular towns there in a big part are unchanged (architecturally) since centuries ago and are always constantly amazing people like me that only have a chance to see the south of Europe during vacations. I slept in random places (a la belle etoile) and hunted for free food in the cities and almost spent no money other than entrance fees for musea, which is what I call the real vacations. Moving around was rather easy, although hitch-hiking always involves hours of walking with all your things on your back and lots of other annoyances, too. The car drivers sometimes were very helpful to the extent of stopping in a town only to show me the place and let me snap pictures and some of them even did a good job at being a touristic guide (like the person who showed me Cordes), except for my piss poor French.

I think part of the route I made is called Rue-des-Bastides, which means something like the route of medieval towns (not sure). Very recommended.

Oh, ironically the flight from Toulouse to Warsaw, through Amsterdam, also lost my baggage, but it was found and brought directly to my home on the same day later.

Then I had one week at home and then went for a paragliding camp in Slovenia and Italy (actually at the border), in the Alps, which is where I wanted to go at the beginning but then thought I wasn’t going to go. We spent most of the week at Lijak, which is a mountain with launch point at only 530m but the meteo conditions were very good, for almost any style of flying. In fact it is said to have good conditions throughout all the year and it’s confirmed by the fact that you can see a couple of canopies on the google maps satellite view of the place at high enough zoom. The Lijak camping is just at the base of the mountain, some 2km from the official landing spot, so that I landed just in front of our tent two times. I have set my new personal records in all categories: 5.5 m/s raising speed, 14 m/s sinking (or rather falling?) speed (that was in a spiral), some 1300m max altitude over the landing spot, some 2.5 hours in the air from takeoff to landing. I experienced my first uncontrolled full-stall in which I lost 100m in about five seconds, for a moment saw the wing actually one or two meter below me partially collapsed (which scared me to death) because of too strong “overdeveloped” conditions. It was also the first time I have seen hanggliders (aka launch potatoes) and full-size sailplanes (that speed at over 150kmh) flying in the same place, soaring in the same thermals. It was unfortunately slightly overpopulated by paragliders of all levels of experience leading to some dangerous situations (but nothing fatal). Our team was a bunch of very enjoyable people, with three licensed pilots and six people in a second level course there.

Needless to say that left me with a long queue of things to do, mails to read, pictures to retouch, that I finally almost caught-up with this week. Tomorrow is the first day of classes at school again but I’m counting on having a little more vacations this month, just need to figure out a long weekend or a way to take the work with me. I spent a couple of mornings this and last week standing lines to the Russian embassy to apply for a touristic visa, which proceeded in an unimaginable, complete chaos, but I should have a two weeks visa starting from this Wednesday if nothing goes wrong now. I’ve never been to Moscow before and I should have a place to sleep in the dormitory in Moscow so it looks promissing.