Using a Novatel XUA-1 and X950D in Ubuntu

I read an article recently that suggested using a saucepan as a mobile broadband booster and it peeked my interest enough to give it a try. In case I needed to use my Novatel X950D express card with another machine I had already purchased a Novatel XUA-1 USB to Express Card 36 adapter. This, therefore, gave me a way of placing the modem in the middle of a saucepan, which would be nigh on impossible were the modem in it’s rightful express card slot in the laptop.

Unfortunately, however, due to a production issue at the plant my XUA-1 came wired as “bus powered”, which effectively means it tells the operating system it only has 100ma of power available even though that isn’t true. Subsequently the OS – be it Windows or Linux – won’t then allow the X950D to work in conjunction with the XUA-1.

After finding a forum post on the very subject it appears the XUA-1 can come from the factory with a 0 OHM resistor in the wrong position, which can be re-soldered in the right place. I never like soldering. Don’t ask me why so I looked for an alternative solution. Fortunately Linux being what it is these kind of problems can sometimes be worked around. By typing a command in you can effectively tell the kernel to ignore whatever power spec a USB device gives and try to use it regardless.

/bin/echo -n 1 /sys/bus/usb/devices/6-1.1/bConfigurationValue

Where “6-1.1″ is the device ID of the modem after you have plugged it in through the XUA-1. This can be gleaned by checking syslog while plugging the adapter in i.e. tail -f /var/log/syslog.

After typing this for the first time the device is enabled and then proceeds to go into storage mode. With the X950D you have to eject the “fake” CD that is part of the device to get it to switch to modem mode thusly:-

eject sr1

Where “sr1” is the device name Linux has for said “fake” CD (this will probably be “sr1” if you only have one real CDROM in your computer). Again you will then have to re-type the previous “echo” command to enable the device once it has switched to it’s new USB vendor/ID pairing of “1410/1450”.

Ubuntu then picks up from there, on it’s own, and will recognise the device as a standard broadband modem. Understandably I wanted to automate the process. Writing some udev rules and linking them to a script(s) seem the natural way forward. After much hair pulling and wonderment at the various interactions udev has with usb storage devices I eventually cam up with the following:-

“/etc/udev/rules.d/95-udev-late.rules”

ATTRS{idVendor}==1410, ATTRS{idProduct}==5010, RUN+=/root/xua1-stage1.sh
ATTRS{idVendor}==1410, ATTRS{idProduct}==1450, RUN+=/root/xua1-stage2.sh

“/root/xua1-stage1.sh”

#!/bin/sh

if [ -a /var/run/xua1-stage1.sh.pid ]
then
	if [ -a /dev/sr1 ]
	then
		/usr/bin/eject sr1 && rm /var/run/xua1-stage1.sh.pid
	fi
else
	touch /var/run/xua1-stage1.sh.pid
	/bin/echo -n 1 /sys/bus/usb/devices/6-1.1/bConfigurationValue
fi

“/root/xua1-stage2.sh”

#!/bin/sh

rm /var/run/xua1-stage1.sh.pid

if [ -a /dev/ttyUSB0 ]
then
	rm /var/run/xua1-stage2.sh.pid
	exit 0
else
	if [ -a /var/run/xua1-stage2.sh.pid ]
	then
		exit 0
	else
		touch /var/run/xua1-stage2.sh.pid
		/bin/echo -n 1 /sys/bus/usb/devices/6-1.1/bConfigurationValue && sleep 3
	fi
fi

Initially I tried to get this working using sleep in the scripts to hopefully time everything correctly. However I wasn’t taking account of the subtle interactions udev has on devices and the way they appear. To cut a long story short if I had a “sleep” command in the script then udev would sit there waiting for it rather than doing it’s usual magic of creating the CDROM device and the whole thing would fail miserably.
Anyway all good fun and it’s working now. I hope somebody finds this useful.

Leave a Reply