Wednesday, March 26, 2008

Thinkpad X61 Wireless and Ubuntu

At last I have resolved a long-standing gripe with Ubuntu on my ThinkPad X61.

Months ago, soon after installing Gutsy Gibbon, I found that my wireless card initially worked well. But a few minutes later, my connection was dead, and I could only restore it by unloading the iwl4965 driver, reloading it, and reconnecting to my access point. Unfortunately, after an indeterminite amount of time the problem would reoccur.

I experimented a little and discovered that by instructing my wireless router to accept anything only 802.11g, the problem vanished. When away from home and using other wireless networks, occasionally my connection would spuriously disconnect. Fortunately, the wireless networks I usually frequent somehow never cause this bug to manifest.

Yesterday my wireless connection was unbearably flaky, and several times, even reloading the driver proved fruitless. I finally decided to look for a proper solution.

Typing dmesg revealed that every time the connection dropped, a message similar to the following would be logged:
[  154.652000] wlan0: No ProbeResp from current AP 04:11:46:fe:24:b0 - assume out of range
Googling for "iwl4965 no proberesp" shows that many others have had the same trouble. Some pages were unanswered bug reports, and others contained discussion where the consensus was to reload the kernel module as a workaround. Happily, before long I stumbled across a FAQ for the ThinkPad T61 that describes a permanent fix, which I'll repeat:
  1. Download the latest iwlwifi microcode
  2. Replace /lib/firmware/2.6.22-14-generic/iwlwifi-4965-1.ucode.
  3. Reload iwl4965 module
The new microcode banished my wireless woes, and the dreaded "No ProbeResp" no longer appears in the logs.

Now I'm left with one remaining significant complaint: the graphics driver. My i965 mostly behaves but there are minor annoyances involving compiz, and major ones involving Wine. I'll leave this for another time.

Thursday, March 20, 2008

Cross-compiling GMP

I build Windows binaries from Ubuntu, using the MinGW port (search for packages starting with mingw).

For the PBC library I need a Windows version of the GMP library, which I build using:
$ ./configure --prefix=~/cross/gmp --host=i586-mingw32msvc --build=local
$ make install
I don't fully understand how it works, but when it's over, I have libraries I can link against to produce Windows executables that can do multi-precision arithmetic.

I sometimes test the binaries with wine. Thus Windows can be completely avoided in the development cycle, from coding to building to testing. However, for an important project, I'd test on at least one real Windows box.

Monday, March 17, 2008


In the old days, to get the external VGA output working on my laptop in X, or even switch resolutions, I'd have to edit an overly complex configuration file and restart X. Nowadays, I use the X Resize and Rotate Extension via xrandr, which is considerably more convenient. I like to control displays through the command-line interface. I find typing the full command cumbersome, so I use this simple script instead:
case "$1" in
xrandr --output VGA --auto --left-of LVDS
xrandr --output VGA --auto --right-of LVDS
xrandr --output VGA --auto --above LVDS
xrandr --output VGA --auto --below LVDS
xrandr --output VGA --mode 1600x1200 --above LVDS
xrandr --output VGA --off
xrandr --output VGA --auto --same-as LVDS

Saturday, March 15, 2008

Thinkpad X61 Volume Buttons

I tried in vain to get the brightness adjustment keys to work, but at least the volume up and down buttons were easy to handle. They trigger bona fide X key events, so I added a couple of lines to .xbindkeys:
"amixer -c 0 set PCM 1dB+"

"amixer -c 0 set PCM 1dB-"

Tuesday, March 4, 2008

GP2X Revisited

Soon after my last post, I tried out some simple ideas for smoothing out the spurious stylus events on my GP2X. The results were promising, but unfortunately before I could experiment anymore my device began malfunctioning. The left and right edges of the screen did not respond properly, and the problem quickly worsened. Soon I could only draw on about a third of the display, in a central vertical band.

Luckily it was still under warranty. I sent it back to, who promptly passed it on to GamePark Holdings for repair. A few weeks later a replacement arrived. I still can't draw on the extreme left, right and bottom edges, but it works well enough for my primitive drawing program. The improved behaviour due to jitter correction is self-evident.