Ubuntu 11.04 Natty Narwhal Annoyances (Dell E6410 with NVS 3100m GPU)

I recently upgraded my Dell E6410 with NVS 3100m GPU laptop from Ubuntu 10.10 (Maverick Meerkat) to 11.04 (Natty Narwhal), and I can’t shake this feeling that the distribution has taken a few steps back. I’m not even referring to the new Unity desktop, but to some super-irritating annoyances I had to fix or work around before being able to use the system. These annoyances were not present in 10.10, it had a whole different collection. ­čÖé

Wireless N connects, but no packets get through

The first annoyance was when I successfully connected to my wireless N access point, but couldn’t get a single packet through. After much searching, it turns out there’s a bug in the firmware for the Centrino Advanced-N 6200 wireless adapter that keeps it from getting any data through.

The solution is to disable wireless N on your laptop by creating a file┬á´╗┐etc/modprobe.d/inteldisablen.conf with the following contents:

options iwlagn 11n_disable50=1 11n_disable=1

and then to reboot. If you don’t want to reboot, just rmmod and modprobe the iwlagn kernel module. I’ve confirmed that this fix works.

Google Chrome scrolls excruciatingly slowly

After resuming and suspending, certain 2D and GPU-assisted graphics operations slow down. Scrolling in Chrome, even on a simple Google results page, is excruciatingly slow with head-explosion-levels of lag.

The solution is to disable hyperthreading, or at least to disable a number of CPU cores, at suspend and re-enable at resume. My laptop i5 CPU has 2 real cores, and thus 4 virtual cores due to hyperthreading. I’m using the following script, taken from this forum thread to do the necessary core disabling / enabling automatically:

#!/bin/sh

# Disable hyper-threading processor cores on suspend and hibernate, re-enable them
# on resume. Presumably helps for buggy nvidia behaviour.
# save this file as /etc/pm/sleep.d/20_core_i5_disable_cores and make excutable
# with chmod +x /etc/pm/sleep.d/20_core_i5_disable_cores

# from: http://www.nvnews.net/vbulletin/showthread.php?t=158091

case $1 in
        hibernate|suspend)
                echo 0 > /sys/devices/system/cpu/cpu1/online
                echo 0 > /sys/devices/system/cpu/cpu3/online
                ;;

        thaw|resume)
                echo 1 > /sys/devices/system/cpu/cpu1/online
                echo 1 > /sys/devices/system/cpu/cpu3/online
                ;;
esac

I’ve confirmed both the slow-down behaviour and the working of the fix.

Eclipse scrollbars don’t work

Natty’s new overlay scrollbars screw with Eclipse’s scrollbars, leaving you with 100% non-working scrollbars! You can either disable the overlay scrollbars completely, or comment out the GDK_NATIVE_WINDOWS line close to the start of the /usr/bin/eclipse shell script:

#export GDK_NATIVE_WINDOWS=true

On my setup, this fix works most of the time.

Conclusion

It’s a shame that these things don’t work out of the box, as some of them had been reported long before the Natty release. Before I forget, if you install 11.04 on this specific laptop, you might also have to follow my Ubuntu 10.10 howto if you see a black screen at bootup or resume.

The Django Book 2.0 in MobiPocket / Kindle format

I wanted to read the web preview of the Django Book’s second edition on my Kindle. Besides the fact that all image links are broken on that website and have apparently been so for some time, I prefer to have these things in the DRM-free MobiPocket / Kindle format. Of course I couldn’t find this anywhere, so I rolled my own based on the book’s SVN repository.

On this page you can download the MobiPocket version of the book and the HTML source files I generated to make it. You can also read on for the skinny on how you can do this yourself.

This procedure works best on a unix-like machine, as we’re going to use grep and sed along with some Python.

1. We start by doing a checkout of the reStructuredText sources of the book, moving the linked graphics into the same directory as the reStructuredText txt files and then creating a grepindex.txt file that will serve as the basis for our table of contents index.txt:

svn co http://djangobook.com/svn/branches/2.0/ 20svn
cd 20svn
find graphics/ -name *.png -exec mv {} . \;
grep -h "^Chapter [0-9]*:" *.txt > grepindex.txt

2. The grepindex.txt will now be converted to something more reStructuredText-like using this script, called grepindex2index.py:

# first do:
# grep -h "^Chapter [0-9]*:\|^Appendix [A-Z]:" *.txt > grepindex.txt
# then:
# python grepindex2index.py grepindex.txt > index.txt

import re
import sys

rst_header = """
===================
The Django Book 2.0
===================

Copyright 2006, 2007, 2008, 2009 Adrian Holovaty and Jacob Kaplan-Moss.
This work is licensed under the GNU Free Document License.

This ebook version was prepared by Charl Botha <http://charlbotha.com/> from
the SVN at http://djangobook.com/svn/branches/2.0/ on 2011-04-25, and is
hosted by <http://vxlabs.com/>.

"""

def main():
    f1 = open(sys.argv[1])
    print rst_header

    # this will match on "Chapter 10: the title" or "Appendix B: another title"
    # groups 0: chapter 10 or appendix A; 1: 10 (or None), 2: A (or None), 3: title
    pat = re.compile('(^Chapter\s*([0-9]*)|^Appendix\s*([A-Z])):\s*(.*)$')
    chapters = []
    appendices = []
    for l in f1:
        # Chapter 10: Advanced Models -> `Chapter 10: Advanced Models <chapter10.html>`_
        mo = pat.match(l)

        if mo.groups()[1] is not None:
            chapters.append("* `Chapter %s: %s <chapter%02d.html>`_" % (mo.groups()[1],mo.groups()[3],int(mo.groups()[1])))

        else:
            appendices.append("* `Appendix %s: %s <appendix%s.html>`_" % (mo.groups()[2],mo.groups()[3],mo.groups()[2]))

    print "\n".join(chapters)
    print "\n".join(appendices)

if __name__ == "__main__":
    main()

Save this to a script called grepindex2index.py, then invoke it with:

python grepindex2index.py grepindex.txt > index.txt

3. We’ll then proceed to fix all chapter references with the following bit of sed:

sed -i "s/\.\.\/\(chapter[0-9]*\)\//\1.html/g" chapter*txt

(this will change all “../chapter??/” links to just “chapter??.html”)

4. Everything is now ready to be converted to HTML:

for i in *.txt; do rst2html $i `echo $i | cut -f 1 -d .`.html; done

5. After downloading this django desktop background as cover image, I dragged and dropped the top-level index.html file onto the free Calibre software to import it, and then used the edit metadata function to set the cover image. After this, I converted the imported files to MobiPocket remembering to add the word “appendix” to the chapter detection xpath expression in the “structured detection” section of the conversion dialogue.

That’s all there’s to it! Have a good read.

Don’t buy HomePlug / Powerline ethernet adapters

(Post summary: The real-world throughput of current generation Homeplug AV 200 Mbit/s powerline ethernet adapters in a modern house is woefully inadequate. Even wireless is much to be preferred, and can be had for cheaper. Read below for why.)

Based on the superb price / performance ratio of the MSI ePower 200AV II kit as extolled by this comparative review (32 powerline adapters were tested), and especially the fact that in the test setup these adapters managed to attain 32 Mbit/s even in the bad case scenario (two different circuits, 100 metres of cable separating the two adapters), I purchased the MSI ePower 200AV+ II kit to replace a wireless link I currently have in my house between the second and third floors. Based on iperf measurements, the wireless link currently manages around 22Mbit/s of throughput. Because the two power sockets I was planning to use are on the same circuit, I thought that I could improve on this existing connection with the two powerline adapters. Little did I know…

The MSI ePower 200AV+ kit still nicely in its box.

After taking delivery of the new kit, I started testing with both adapters in the same room. One thing that can be said for this hardware, is that it’s really plug and play. One adapter in wall-socket and connected to first floor ethernet hub, second adapter in wall-socket and connected to my laptop, and my laptop was online. No mess no fuss.

The first nasty surprise appeared as I installed and started up up the software that came in the box (version 5.0). It claimed not to find any homeplug adapters on the network, although the laptop I was running it on was directly connected to one of the PLCs. So I downloaded version 6.0 of the software, only available in German, from MSI’s website and that did manage to see both adapters. At least now I was able to configure both the PLCs (in German…) and set the network name to something private for security’s sake.

After moving one of the adapters to my study on the third floor and connecting it to a Linux server there, I could start running iperf on the server and my laptop on the second floor for testing. The two PLC adapters were now in the same-circuit sockets I was intending to use. Below is the output of three runs of iperf:

C:\Users\cpbotha\Downloads>iperf -c 192.168.1.126
------------------------------------------------------------
Client connecting to 192.168.1.126, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[148] local 192.168.1.38 port 49921 connected with 192.168.1.126 port 5001
[ ID] Interval       Transfer     Bandwidth
[148]  0.0-10.0 sec  10.7 MBytes  8.95 Mbits/sec

C:\Users\cpbotha\Downloads>iperf -c 192.168.1.126
------------------------------------------------------------
Client connecting to 192.168.1.126, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[148] local 192.168.1.38 port 49987 connected with 192.168.1.126 port 5001
[ ID] Interval       Transfer     Bandwidth
[148]  0.0-10.0 sec  11.2 MBytes  9.41 Mbits/sec

C:\Users\cpbotha\Downloads>iperf -c 192.168.1.126
------------------------------------------------------------
Client connecting to 192.168.1.126, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[148] local 192.168.1.38 port 49988 connected with 192.168.1.126 port 5001
[ ID] Interval       Transfer     Bandwidth
[148]  0.0-10.0 sec  10.4 MBytes  8.70 Mbits/sec

Yes ladies and gentlemen, that’s an absolutely miserable 9 Mbit/s (think 1 Mbyte/s…) between two MSI ePower 200AV+ II adapters on the same circuit, on different floors in a house that was built 5 years ago. For your reference, my wireless link (two Sitecom 300N X2 access points in Wireless Distribution Mode) easily manages 22 Mbit/s effective throughput right through a reinforced concrete floor.

MSI’s own utility claimed the following (I’ve cut out things that you don’t need to see):

Rate 18/39
Vendor Atheros
Firmware INT6400-MAC-4-0-4011-00-3430-20090501-FINAL-C
├ťbertragungsrate hoch 174.00
├ťbertragungsrate niedrig 15.00

… with its reported link speed varying between 17 and 35 Mbit/s.

I tried the third floor PLC adapter on various different sockets, the results were similarly depressing.

As if the miserable throughput was not reason enough to avoid powerline adapters, note the following mechanical issue:

When the adapter sits in a double socket, the only thing that’ll fit in the free socket is a really thin plug as the upper part of the adapter is flush with the socket and covers a fair part of the other hole.

As you can see in the caption, although the PLC has a socket of its own, it covers the neighbouring socket in a double-socket setup to such an extent that you can only fit a really thin plug in the neighbouring socket.

To conclude: Homeplugs perform really well in a test environment, even when different circuits are introduced and metres of extra cable are inserted. However, what the tests often fail to take into account, is the fact that people actually make use of other electrical devices besides homeplugs (!!) and that these all introduce noise into the home grid that apparently severely affect powerline ethernet performance. Perhaps in your house things work out differently, but my advice would be to steer clear of powerline adapters (unless you can borrow a pair to test with), opting of course for ethernet cables whenever this is possible and for wireless otherwise.

Sipura / Linksys / Cisco SPA3102 Voice Gateway in The Netherlands

After recently spending some hours configuring my new Cisco SPA3102 Voice Gateway with a Betamax SIP provider (voipbuster / voipstunt / voipcheap / and so forth, see http://www.backsla.sh/betamax for a full list of all Betamax providers) and the Dutch PSTN system, I thought I’d try and make your life easier by documenting the most important of the settings.

With this box you can stick it to the man!

The SPA3102 is connected to an existing router, so I have the Lan Setup set to Bridge, and have configured the Internet port (on the Router | Wan tab) with a suitable static IP. To be clear, in this configuration, one only connects up the Internet port and NOT the Ethernet port.

Voice | Regional

For the Voice | Regional tab I found the following Call Progress Tone settings on a voxilla forum page by users PJH and edokter:

Dial Tone: 425@-10;20(*/0/1)
Second Dial Tone: 425@-10;20(*/0/1)
Outside Dial Tone: 350@-19;440@-19;20(*/0/1+2)
Busy Tone: 425@-10;10(.5/.5/1)
Reorder Tone: 425@-10;10(.25/.25/1)
Off Hook Warning Tone: 1000@0;*(0/9.5/0,.1/.1/1,.1/.1/1,.1/0/1)
Ring Back Tone: 440@-19,480@-19;*(2/4/1+2)
Confirm Tone: 425@-10;1(.1/.1/1)
SIT1 Tone: 950@-19,1400@-19,1800@-19;30(.333/0/1,.333/0/2,.333/1/3)
MWI Dial Tone: 425@-10;1(.1/.1/1);20(*/0/1)
Cfwd Dial Tone: 425@-10;20(.5/.05/1)

On the same tab and from the same forum page, the following Distinctive Ring Patterns and Distinctive Call Waiting Tone Patterns:

Ring1 Cadence: 90(1/4)
Ring2 Cadence: 90(.3/.4,.3/4)
CWT1 Cadence: 60(.5/9.5)
CWT Frequency: 425@-16

To get caller ID working, I made the following changes (still on the Voice | Regional tab):

Caller ID Method: ETSI FSK
Caller ID FSK Standard: bell 202

Finally on this tab, set:

FXS Port Impedance: 270+750||150nF

(according to the Cisco admin manual, this is the standard for The Netherlands)

Voice | Line 1

This is the tab where you get to do most of the SIP configuration.

I have my primary betamax provider (12voip.com) setup under Proxy and Registration and Subscriber Information:

Proxy: name of your sip server e.g. sip.voipbuster.com
Display name: 0031xxxxxxxxx (number that you have verified and configured as callerid with the voipbuster software)
User ID: 0031xxxxxxxxx (same as above)
Password: hard to figure this one out ­čÖé
Use Auth ID: yes
Auth ID: your betamax (voipbuster etc.) username

My dialplan looks as follows:

(112S0<:@gw0>|0800x.<:@gw0>|090x.<:@gw0>|<#9:>xx.<:@gw0>|<1601:>xx.|<0:0031>[1-7]xxxxxxxxS0|xx.|*xx)

Here is the commented version for your edification:

(112S0<:@gw0>| # emergency number goes through PSTN
0800x.<:@gw0>| # 0800 numbers go through PSTN
090x.<:@gw0>| # 090x numbers go through PSTN
<#9:>xx.<:@gw0>| # prefix number with #9 to force dialing through PSTN
<1601:>xx.| # throw away 1601 preselect still in some handset phonebooks. you won't need this.
<0:0031>[1-7]xxxxxxxxS0| # numbers without 0031 country code will get it added
xx.| # all other numbers
*xx) # linksys codes

You can find more info on dialplans here and here. You can use other betamax providers in the Gateway Accounts and integrate them in your dialplan. The betamax providers don’t require registration.

Voice | PSTN Line

In order for your SPA3102 to realise that the call has been ended, you need to setup PSTN Disconnect Detection correctly:

Detect CPC: yes
Detect Polarity Reversal: no
Detect Disconnect Tone: yes
Disconnect Tone: 425@-30,425@-30; 2(0.5/0.5/1+2)

When I had “Detect Polarity Reversal” set to yes, I’d get immediate disconnects on incoming calls with my new Ziggo cable PSTN connection.

On the same tab, make sure your FXO Port Impedance is also set to 270+750||150nF (the Dutch standard).

Later I discovered that if we took longer than 10 seconds to answer the phone, the call would be lost. To fix this, set the “PSTN Answer Delay” to 60 seconds or something reasonable.

Conclusion

Please let me know in the comments if this worked for you, or if you have any questions on the instructions above!

Updates

  • June 17, 2014: Fixed typesetting of the code examples.
  • September 30, 2012: Removed 13 digit S0 shortcut from dialplan, this could interfere with calls to international numbers with more digits. Added two links explaining dialplans.

International characters on the HTC Desire Z keyboard

I’m typing this up because it took me far too long to find, probably because I wasn’t using the right search terms, or because I was trying stupid key combinations…

Frustration (was: threesixtyfive | day 244)

In any case, if you want to make international characters (that is, characters with accent marks, diacritics, trema (plural tremata), umlauts, eat that google!) such as ├ź, ├ę, ├¬ or even ├ or ├» and so forth on the HTC Desire Z hardware keyboard, you simply long press the base character. A menu pops up and you get to choose the accented character that you would prefer to insert at that moment.

I sincerely apologise for interrupting your usual high IQ programming with this. If however you stumble upon this post and it helps you, why don’t you leave a comment just for laughs?