This should be added to a FAQ I think because has been asked constantly.
UMTS dongle installation instructions are [url=http://wiki.openwrt.org/doc/recipes/3gdongle?s[]=umts]here[/url]
There is nasty bug somewhere in the firmware (hotplug event handling I suppose) that reattaches a modem to the wrong character device name. Normally if a USB modem is attached several character devices are automatically created with the name - /dev/ttyUSBx where x is from 0 to N. With my modem for example I get 4 devices created:
root@Alix:~# ls -la /dev/ttyUSB*
crw-rw-rw- 1 root root 188, 0 Jul 30 09:21 /dev/ttyUSB0
crw-rw-rw- 1 root root 188, 1 Jul 30 09:21 /dev/ttyUSB1
crw-rw-rw- 1 root root 188, 2 Jul 30 09:21 /dev/ttyUSB2
crw-rw-rw- 1 root root 188, 3 Jul 30 09:21 /dev/ttyUSB3
In the network config I'm specifying the /dev/ttyUSB0 as the device to be used to establish the connection
root@Alix:~# cat /etc/config/network | grep "'wan'" -A 5
config 'interface' 'wan'
option 'proto' '3g'
option 'service' 'umts'
option 'apn' 'flux'
option 'pincode' '242'
option 'device' '/dev/ttyUSB0
Everything works but for some reason the modem gets detached and reattached again. This could happen if the modem looses connection to the UMTS base station. The problem is the modem is attached to the /dev/ttyUSBx but now x changes from 1 to 4! Which means that I need to change the device name to /dev/ttyUSB1 in the /etc/config/network or physically reattach the modem to bring up the wan interface! Ain't that a bitch.
A workaround is to manually rebind the modem driver. I've written two scripts for that purpose.
The first script is to unbind the driver:
root@Alix:~# cat /mnt/sd/bin/unbind
#!/bin/sh
binddev=/sys/bus/usb/drivers/usbserial_generic/unbind
for link in /sys/bus/usb/drivers/usbserial_generic/1-1*; do
id=$(echo "$link" | sed -n -r "s/.*\/(.*)/\1/p")
echo -n "$id" > $binddev
done
The second one is a bit more complex:
root@Alix:~# cat /mnt/sd/bin/bind
#!/bin/sh
vid=12d1
pid=1003
devpath=/sys/bus/usb/devices
binddev=/sys/bus/usb/drivers/usbserial_generic/bind
for dev in $devpath/*; do
cvid=$([ -f $dev/idVendor ] && cat $dev/idVendor)
cpid=$([ -f $dev/idVendor ] && cat $dev/idProduct)
#echo "$dev, $cvid:$cpid"
[ "$vid" = "$cvid" ] && [ "$pid" = "$cpid" ] && devdir=$dev
done
if [ -z "$devdir" ]; then
echo "Device $vid:$pid not found"
return 1
fi
devpref=$(echo "$devdir" | sed -n -r "s/.*\/(.*)/\1/p")
for subdev in $devdir/$devpref*; do
id=$(echo "$subdev" | sed -n -r "s/.*\/(.*)/\1/p")
#echo "$subdev"
echo -n "$id" > $binddev
done
The complexity comes from the necessity to find proper device directory. vid and pid variables shall be adjusted to correspond to vendor id and product id of the modem you use.
So to bring the wan interface up one has to call:
unbind
bind
ifup wan
I have defined a rebind script that does exactly this
(Last edited by flux on 30 Jul 2011, 14:30)