Author Archives: hadara

icebiking with the freerunner

Recently I spent half a day trying to find a shop in Tallinn that would have a universal PDA/phone/GPS holder for bicycle in stock that would be able to hold the Openmoko FreeRunner.

There’s a suitable one described in this blog post but since I had a ride planned for the next day ordering it from Germany was out of the question. So I quickly hacked something together myself. It isn’t exactly beautiful but at least it’s extremely sturdy.

Here’s how it looks in action:

freerunner on the bike

Basically I cut it out of 2mm Al sheet (actually chasis of an old tube amp). After that it was more or less just a matter of bending. There are some pictures of a similar but a more beautiful holder project here, sadly my metal saw is far too wide to cut such nice round curves.

freerunner from the side

We rode for 4.5 hours and it was -7 degrees C (19.4F) so I was very positively surprised that the battery of FreeRunner held up for so long in that kind of cold with GPS enabled & TangoGPS running. Actually when I turned it off it still had about 20% battery remaining.

Here’s our GPS tracklog @ OpenStreetMaps

Marju icebiking

a winter road

me

apache deaths with signal 4

Yesterday I did an major upgrade to an rather busy website (should be in the top 10 most used in my country). Basically I moved the code from the old 32 bit single-core webserver running FreeBSD 4.8, Apache 1.3 and PHP 4.X to a new 64 bit, 4 core server running FreeBSD 7.0, Apache 2.2, PHP 5.2. As you might imagine changing so many variables at once caused several surprises. Most interesting one was that Apache died on some pages with signal 4 (SIGILL) which stands for illegal instruction. It’s not that uncommon to see apache deaths with signals 11 (SIGSEGV) and 6 (SIGBUS) which are usually caused by bugs in some PHP modules but signal 4 was something new to me. Quick Google search turned up some threads were people reported getting rid of it by changing module orders in PHPs extensions.ini file and a bug report about PHP function preg_replace() sometimes causing it.

I tried both theories and neither one was the case that I had. Then I spent some time looking at the coredump with GDB but in the end I resorted to good old binary search strategy. So to make a long story short the cause turned out to be a recursive function in the website code that under some circumstances never stopped recursing until it overflowed it’s stack.

using kmymoney with hansapank

I’m using KMyMoney (KMM) to keep track of my finances and in general I think it’s a very nice program but I find inserting the transactions (ledgers) by hand a very tedious thing to do. I’m a client of the Hansapank and their web banking interface allows me to download transaction history in a CSV file. Since I practically always pay with debit card this transaction history covers almost all my transactions so the only question remaining was how to import it into KMM.

KMM seems to be able to import QIF and OFX formats, so in order to get my CSV file imported I wrote a python script that converts Hansapanks CSV to QIF (with KMM transaction ID extension).

Here it is, maybe it’s useful for someone else too. You can run it like so:

python hansacsv_to_kmymoney.py my_transaction_history.csv > out.qif

and import the resulting file into KMM. There’s an payee name based mapping mechanism too that allows you to map payee name from the CSV file to different name for the QIF file and attach category to it. There are several examples of such mappings near the beginning of the file.

a new toy

beagleboard B4

This is the Beagleboard – an TI OMAP 3530 based open source development board from the guys at TI.
It still amazes me that nowadays it is possible to pack 600Mhz CPU, DSP, 2D/3D accelerator, 128MB SDRAM and 256MB NAND flash into a package that measures something like 13x13x4 mm.

OMAP 3530
It doesn’t seem to require any active or even passive cooling and while I haven’t found any power usage measurements yet it can’t be very power hungry since basically the same chip (OMAP 3430) is used in mobile phones.

With that kind of specs this chip is sure to find use in many devices from the set top boxes, car computers and (wearable?) surveillance devices to ultra portable notebooks.

Indeed there’s already an project called Pandora that has created a handheld game console design that is belived to be the most powerful in the world and is expected to ship as early as september 2008.

But now back to the beagleboard itself – it is an extremely small (7.5cm x 7.5 cm), powerful and cheap (149$) board that has:

  • the omap 3530 chip
  • USB 2.0 OTG port (this can act as gadget or host)
  • stereo audio input & output
  • s-video output
  • DVI-D output
  • MMC+/SD/SDIO slot
  • JTAG & RS232 headers
  • an expansion header for I2C, I2S, SPI, MMC/SD

The board design originally also had an separate USB host PHY and an USB host port, but it was removed from this revision because they couldn’t get it working in a stable manner yet. It will probably show up in the next rev. but until then we have to live with the OTG port in the host mode, which will be fine in most cases. So far the only problem that I have encountered with it is the lack of support for the high bandwidth transwers in the host mode in the linux driver (musb) that handles the OTG port. In practice this means that some webcams will not work yet, but all the other USB devices that I have tried work just fine.

Since it only has a single USB OTG port I had to use powered USB hub to connect things like the keyboard, mouse, network dongle and the wireless dongle. I personally use mini usb A -> mini USB B cable and 7 port powered Trendned HUB.

beagleboard playing 720p video

This board is currently able to play back 720p purely on the ARM (with NEON vectorization). We will probably soon see DSP offloaded codecs too, which will free up the main CPU for other things and might even make 1080i possible.

I’m currently running the Ångström distribution based demo image that has Enlightenment window manager & Epiphany web browser. I haven’t been yet able to try sound since the alsa drivers that the demo image has are broken and give kernel panic on every attempt to play sound. Also the USB seems to behave strangely – sometimes all the USB devices are lost, sometimes not recognized on the boot at all. USB devices also become unresponsive when I connect more than 3 devices to the HUB, I still don’t understand if it’s HW or SW issue.

Commands out of sync; you can’t run this command now

After a recent upgrade our rather high volume Python application server started sometimes getting the “Commands out of sync; you can’t run this command now” errors from the MySQLdb library.
I didn’t have time to debug it right away and the searches revealed only various threads where users complained about similar problems without any obvious solution. So at the time I just wrote an exception handler around the database functions that will retry to execute the query when such an error is encountered, this proved to be an rather effective bandage since there were only about 2% of the cases when we got double fault.

Anyway, the problem kept ticking in the back of my mind for some weeks until I accidentally read a post by John Nagel explaining that the cursors abstraction provided by the Pythons MySQLdb library is just an illusion since the underlying MySQL C library doesn’t really support cursors and requires you to always free the results for the last query before executing next one on the same connection. Our database connection spooling library was written with an assumption that there can be multiple open cursors on the same connection and the connections were released back to the spool as soon as the execute() returned and after that the cursor object was returned back to the caller.

This lead to the following race condition which produced the above mentioned “commands out of sync” errors:

  1. thread 1 executes a query on connection 1 which returns results
  2. connection 1 is returned to the spool and cursor object is returned to the caller in the thread 1
  3. thread 2 gets the connection 1 from the spool & tries to execute a query on it (before the thread 1 has called fetchone()/fetchall() on the cursor that it has)

So I guess the morale of the story is that I shouldn’t make intuitive assumptions and should read the actual documentation more. Eeasier said than done.

a good day for biking!

Since 2000 or so each winter has gotten softer and softer around here and this winter is the first that I remember when we didn’t have any snow at all.
So it’s kind of surprising that, now when the spring has officially begun we got the first snowy days and even a real snowstorm.
This gave me an first opportunity this year to do some icebiking which I happen to like a lot.

icebiking

and the tire that makes it possible:

schwalbe ice spiker

xorg lies to me…

Some excerpts from the xorg log:

(**) intel(0): Option "PreferredMode" "768x576"
...
(WW) intel(0): Option "PreferredMode" is not used

Actually the option was used since without it the default mode is used.


(II) intel(0): RandR 1.2 enabled, ignore the following RandR disabled message
...
(--) RandR disabled

FreeBSD & Huawei E630

I recently got Huawei E630 PCMCIA data card that can handle HSDPA/UMTS/EDGE/GPRS/GSM. Cursory look at the internet told me that this card should work under Linux so I was almost sure that I can get it working under FreeBSD (eventually). After plugging it in I was a little surprised to find that it presented itself to the system as a USB mass storage device and SCSI CD-ROM device cd0 tried to handle it (without much success). After doing some research I found that some of the Huawei cards contain this mass storage part that they use to store drivers for Windows and you have to send a magic request to it in order to force it into modem mode.

I found a small program by Hans Petter Selasky that tries to send this message and it indeed seemed to work at least as far as sending of the message is concerned but the problem for me was that the system had already recognized the device as a storage device and so I had no way of attaching ubsa/ucom devices to it. It might be that it would work if you remove the umass device from the kernel and load only the ubsa & ucom modules after running this program. Anyway instead of trying this I took proposed patch against OpenBSDs umsm driver that did the necessary poking in the initialization routine and hacked it into FreeBSDs ubsa driver (patch).

In general it seems to work quite well. Sometimes I get ucom0: ubsa_request: STALLED messages from the kernel when dialing, but it usually works fine at the next attempt.

Here’s what it outputs to the syslog when I insert the card:

ohci0: <NEC uPD 9210 USB controller> mem 0xb0207000-0xb0207fff irq 16 at device 0.0 on cardbus0
ohci0: [GIANT-LOCKED]
ohci0: [ITHREAD]
usb5: OHCI version 1.0
usb5: <NEC uPD 9210 USB controller> on ohci0
usb5: USB revision 1.0
uhub5: <NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb5
uhub5: 1 port with 1 removable, self powered
ohci1: <NEC uPD 9210 USB controller> mem 0xb0208000-0xb0208fff irq 16 at device 0.1 on cardbus0
ohci1: [GIANT-LOCKED]
ohci1: [ITHREAD]
usb6: OHCI version 1.0
usb6: <NEC uPD 9210 USB controller> on ohci1
usb6: USB revision 1.0
uhub6: <NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb6
uhub6: 1 port with 1 removable, self powered
ucom0: <HUAWEI Technologies HUAWEI Mobile, class 0/0, rev 1.10/0.00, addr 2> on uhub5
ucom0: Could not find interrupt in
device_attach: ucom0 attach returned 6
ucom0: <HUAWEI Technologies HUAWEI Mobile, class 0/0, rev 1.10/0.00, addr 2> on uhub5
ucom0: failed to set configuration: IOERROR
device_attach: ucom0 attach returned 6
ucom0: at uhub5 port 1 (addr 2) disconnected
ucom0: <HUAWEI Technologies HUAWEI Mobile, class 0/0, rev 1.10/0.00, addr 2> on uhub5

And here’s my /etc/ppp/ppp.conf file:

umts:
set device /dev/cuaU0
set speed 384000
set phone *99***1\#
set authname ""
set authkey ""
set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
\"\" AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT"
add default HISADDR
set ifaddr 10.0.0.1/0 10.0.0.2/0 0.0.0.0 0.0.0.0

To establish a connection I just use the command ppp -background umts

PS
It’s also a little annoying that the system always panics when you remove the card. It seems to be a known problem with the teardown ordering in the current USB stack and is said to be fixed in the FreeBSDs new USB stack that is currently still in the perforce.