The newer WWAN (HSDPA/UMTS/3G/whatever) USB devices from Option does not come bundled with CD that carries the drivers, instead they are accessible from a mass storage device, this is marketed as by Option as “ZeroCD”. This also means that the device needs to be “switched” from the storage device to the modem/network interface before it’s usable.

There is a utility called usb_modeswitch based around libusb that allows one to switch both Option devices as well as Huwei devices. Unfortunately Option devices require a write to a bulk endpoint to a device that already is attached to a driver (umass), this is not possible with libusb in FreeBSD (it only allows such things on ugen devices). It’s possible to work around this by unloading umass, attaching the device, and then do the switching. This is quite annoying, especially if one needs to use any kind of umass devices at the same time.

The magic byte sequence usb_modeswitch is sending to the device is actually a SCSI REZERO (0×01) command (quite suitable for the name ZeroCD :) ). Sending such command is possible with the standard camcontrol utility.

> camcontrol devlist
<Optiarc DVD RW AD-7173A 1-01>     at scbus3 target 0 lun 0 (cd0,pass0)
<ZCOPTION HSDPA Modem 3.00>        at scbus8 target 0 lun 0 (pass1,cd1)

The WWAN device is at cd1 (ZCOPTION, ZeroCd Option)

> camcontrol cmd cd1 -c "01 00 00 00 00 00" -i 1 i1
camcontrol: error sending command

Even though camcontrol reports an error the device is switched properly. I don’t know why it reports an error, but my best guess is that the device “switches” instantaneously and the response gets lost.

umass0: <Option N.V. Globetrotter HSDPA Modem, class 0/0, rev 1.10/0.00,
addr 2> on uhub0
cd1 at umass-sim0 bus 0 target 0 lun 0
cd1: <ZCOPTION HSDPA Modem 3.00> Removable CD-ROM SCSI-2 device
cd1: 1.000MB/s transfers
cd1: Attempt to query device size failed: NOT READY, Medium not present
umass0: BBB reset failed, STALLED
umass0: BBB bulk-in clear stall failed, STALLED
umass0: BBB bulk-out clear stall failed, STALLED
umass0: at uhub0 port 1 (addr 2) disconnected
(cd1:umass-sim0:0:0:0): lost device
(cd1:umass-sim0:0:0:0): removing device entry
umass0: detached
ugen0: <Option N.V. Globetrotter HSDPA Modem, class 255/255, rev 1.10/0.00,
addr 2> on uhub0

Glue for devd

To get automatic switching, put the following in a file called option.conf and place it in /etc/devd/ (create the directory if it doesn’t exists). Replace product with the correct value for your device, usbdevs -v should report it.

attach 100 {
    match "device-name" "umass[0-9]+";
    match "vendor"  "0x0af0";
    match "product" "0x6911";
    match "devclass" "0x00";
    action "sleep 1; /sbin/camcontrol cmd 
`/sbin/camcontrol devlist | /usr/bin/grep ZCOPTION | 
/usr/bin/awk '{match($11, /pass[0-9]+/); print substr($11, RSTART, RLENGTH) }'`
-c '01 00 00 00 00 00' -i 1 i1 > /dev/null";
};

Restart devd with /etc/rc.d/devd restart

Leave a Reply