USB_ModeSwitch - Activating Switchable USB Devices on Linux
- Introduction
- Download
- How to install
- How to use
- Known working hardware
- Troubleshooting
- Contribute
- Whodunit
- History
If you don't like the text column width, adjust your browser window
Introduction
USB_ModeSwitch is (surprise!) a mode switching tool for controlling "flip flop" (multiple device) USB gear.
Several new USB devices (especially high-speed wireless WAN stuff, there seems to be a chipset
from Qualcomm offering that feature) have their MS Windows drivers onboard; when plugged in
for the first time they act like a flash storage and start installing the driver from there.
After that (and on every consecutive plugging) this driver switches the mode
internally, the storage device vanishes (in most cases), and a new device (like
a USB modem) shows up. The WWAN gear maker Option calls that feature "ZeroCD (TM)".
As you may have guessed, hardly anything of this is documented and Linux support by the better part of the makers is non-existent.
On the good side, most of the known devices do work in both modes with the available Linux drivers like "usb-storage" or "option" (an optimized serial driver for high-speed modems).
That leaves the problem of the mode switching from storage to modem or whatever the thing is supposed to do.
Fortunately there are things like human reason, USB sniffing programs and "libusb". It is possible to eavesdrop the communication of the MS Windows driver, to isolate the command or action that does the switching and to reproduce the same thing under the rule of Linux or the BSD variants.
USB_ModeSwitch makes the last step considerably easier by taking the important parameters
from a configuration file and doing all the initialization and communication stuff.
From version 1.0.3 upwards there is a simple framework for integrating the
switching with udev (the device manager) to make it fully automatic.
This tool is now on the way to be integrated into the big distributions; soon
you should not be having to install from the source packages here anymore.
But I strongly advise against using packaged versions before 1.1.0.
Please read the information on this page carefully before you go around posting questions! If you encounter a new device, it really helps to understand the principle of what is happening, which in turn makes it easier to find out about the switching command and to add a new config entry.
For hints about doing your own sniffing see paragraph Contribute below.
Download
The latest release version is 1.1.4. The tar archive contains only the source. I used libusb-0.1.12 but the "compat" library from libusb-1.0 is now working smoothly too.
Important: you need the data package as well !!
Changes and updates to the configuration data may happen more often than new releases; most of the
valuable knowledge about devices is contained in these files. That's why it is provided separately.
- Download usb-modeswitch-1.1.4.tar.bz2, dated from 2010-08-17;
a Debian (Xandros/Ubuntu) package should be available soon at the
Debian Repository. Many architectures are supported there (like amd64 or ia64).
- Download the usb-modeswitch-data package (2010-08-26). It contains the device database and the rules file, including full paths. You can use this package with program releases from 1.0.3 upward, but the latest devices and features may require the most recent program release too.
- The optional device_reference.txt (gzipped) from 2010-08-26; this is a collection of all device setups with their respective contributors; you can use it as a starting point if you want to make a new device working.
- Don't forget libusb if it's not on your system. In most distributions there is most likely a package named "libusb-dev" or "libusb-devel". Choose the legacy version (0.1.12) or the "compatible" package from libusb-1.0; last time I checked it had the version number 0.1.14.
How to install
If you have an earlier version installed, de-installation is recommended ("make uninstall"). Several file locations changed in 1.1.0, old ones might be orphaned if not taken care of. If you have a version after 1.1.0 you can just update and overwrite all existing files.Important: you need "tcl" for the wrapper script to work; if you enter "tclsh" and you get a "%" prompt, you are set (to exit enter "exit"). The "tcl" package is part of all distributions I know.
Unpack the source file of the program (who might have thought!). In the newly created directory run as root or superuser:
# make installThis installs a tiny shell script for udev, the larger wrapper script, a config file, the man page and the freshly compiled binary.
Now do the same for the data package. It will install the config files in /etc/usb_modeswitch.d and the udev rule file in /lib/udev/rules.d.
You are set already; if your device is known, you should be able to just plug it and use it. If it doesn't work right away we'll find out why.
For manual use just install the program. Work with the command line interface or with the original
setup reference file. To do the latter you put "usb-modeswitch.setup" into "/etc" and edit it according
to your hardware. It's heavily commented and should tell you what to do.
The setup file can have any name and place; just tell usb_modeswitch how to find it with the
-c parameter.
Manual use is intended for testing and analyzing. See next paragraph.
How to use
In most cases, you should be able to use your device without any interaction except plugging your device in.
For testing, debugging and taming new devices from the wild, you can use the binary
part of USB_ModeSwitch in manual mode.
There are two ways for that: using a config file or using the command line.
Run "usb-modeswitch -h" to list the command line parameters. If any of them except -W, -D, -I and -q are used, a config file given with -c is ignored and all mandatory parameters have to be provided on the command line. See also the included man page.
To work with a config file, use one of the little files in /etc/usb_modeswitch.d or create one yourself. Then give the path and file name to usb_modeswitch with the -c option. You also can have a look into the device_reference.txt (gzipped) for hints about model families and an explanation of the parameters.
Important: USB_ModeSwitch - like all programs using libusb - has to be run as root (or with "sudo") when calling it manually. Otherwise strange error messages turn up and things won't work. When trying out switching commands and strategies, it's probably easier to work at a root shell for a while ("sudo bash" or "su -").
The automatic approach consists of several components working together:
- /usr/sbin/usb_modeswitch - the binary program
- /lib/udev/usb_modeswitch - a wrapper script using the binary, doing additional ID checking and driver loading. For this to work, the "tcl" package is needed on the system.
- /lib/udev/rules.d/40-usb_modeswitch.rules - the udev rules starting the wrapper
if a known device ID (vendor/product) is recognized.
If the switched device provides standard serial ports, a second rule calls the wrapper again and adds a symbolic link to the correct connection port (see below) - /etc/usb_modeswitch.conf - a global config file to enable logging and to disable switching alltogether (mostly to access the install part of devices)
- /etc/usb_modeswitch.d - a folder containing the individual setup information files per device, named according to the IDs and possibly further identity tokens (to resolve known ambiguities). If your device ID shows up in one of the file names, chances are your device is supported even if the model or brand does not match.
When dealing with wireless devices, there may be issues with NetworkManager (or its ModemManager component) which does not seem to be overly reliable when trying to recognize a proper modem port.
Good results were reported by working with wvdial, UMTSmon and several tools providing a user interface to PPP like kppp; some of these programs may require a bit of basic knowledge though.
There is also a new - unusual but intriguing - concept which shortcuts the tedious path of putting
together all components for a successful wireless broadband connection. The Sakis3G tool
is a self-containing script (including among others the latest USB_ModeSwitch binary). It supports
quite a number of providers already and is rapidly expanding. The beauty of it is that no installation
is necessary and only a minimum of input required. Contrary to NetworkManager, it really delivers.
Check it out at Sakis' blog ToDo Forever. There
is even a HowTo for setting it up so that it connects right away when a modem is plugged in.
The main hurdle for NetworkManager and others to a fully automated use of a newly switched modem is to find the right port for connecting. Often more than one serial port is created after switching (even up to five). Generally, not all of them are really standard serial (the driver can't decide), some may look like it and even accept AT commands, but usually the right one is providing an interrupt transfer endpoint. Unfortunately, NetworkManager does rely on other ways of probing for the correct port and sometimes fails. It is worth to note that the said Sakis3G tool is able to find this port quite easily.
Starting from version 1.1.2, usb_modeswitch will add a symbolic link to the correct port with
interrupt transfer if the device provides standard serial ports. The link will have the name
/dev/gsmmodem, with a number appended if more than one device is attached.
You can use this name with connection helpers like wvdial. Note that in many cases you
may have to edit the configuration file manually.
If you managed to get a new or badly supported device to switch correctly in manual mode, you can add a udev rule and a config file yourself. But please report it back to share it !!
See Contribute.
Known working hardware
Very important note:Personally, I could only test my Option Icon and the S.E. MD400; the list here - as well as all the necessary data - relies on reports from third parties (people, that is). So don't be surprised if you hit sudden obstacles even with your device listed here. You have been warned.
There are hitherto three known methods for initiating the switching process:
- sending a rarely used or seemingly weird standard storage command (equivalent to those of SCSI) to the storage device ("eject" for example)
- actively removing (rather detaching) the storage driver from the device
- sending a certain control message to the device
Again, if you don't find the name of your device in this list, it may still be supported. The important thing is that you find your device's USB ID in the config file folder. Have a look into the latest data package (See Download.).
- All Option devices
All known Option devices use the USB storage command REZERO UNIT for switching (inherited from SCSI). Older devices change vendor and product ID, newer ones don't (just their device class). These newer sticks have a special interface after switching (HSO) for which there is a specific driver. Some older devices are able to be loaded with the new HSO firmware which changes their behaviour.
Note: for HSO driver questions and HowTos consult the fine Pharscape site!
All Option devices come included in the config database of the new integrated version. There is no need to use "ozerocdoff" or "rezero" anymore.
There is a switching routine for Option devices in the kernel driver usb-storage (since beginning of 2009). It works only for devices entered in "unusual_devs.h". More to that below.
You can safely install USB_ModeSwitch alongside. If your Option device gets switched by the kernel it just does nothing, otherwise it kicks in. - Option GlobeSurfer iCON (aka "Vodafone EasyBox")
The thing that started it all, because I wanted it to work on my Linux router.
- Option GlobeSurfer iCON 7.2
If you get hardware lockups of this thing when plugging in (flashing LEDs), update the firmware. You can probably update it to the new HSO interface - Option GlobeTrotter HSUPA Modem (aka "T-Mobile wnw Card Compact III")
HSO interface - Option GlobeTrotter GT MAX 3.6 (aka "T-Mobile wnw Card Compact II")
- Option GlobeTrotter EXPRESS 7.2 (aka "T-Mobile wnw Card Express II")
- Option GlobeTrotter GT MAX "7.2 Ready"
- Option iCON 210
Not sure if this is a generic Option design (see PROLiNK A600) - Option iCON 225 HSDPA (aka "T-Mobile web'n'walk Stick")
HSO interface - Option iCON 401 and AT&T Quicksilver
HSO interface; has additional Micro SD.
The Quicksilver looks exactly like the 401 but the product ID is different. - Vodafone K3760 (an Option device, original name yet unknown)
HSO interface - All remaining Option HSO devices (in sync with kernel 2.6.34)
- All Huawei devices
Some need a custom control message and others want a custom bulk message.
Newer kernels try to apply the control message to certain Huawei devices from the driver (special treatment in usb-storage). The latest models are not supported by the kernel.
You can safely install USB_ModeSwitch alongside. If your Huawei gets switched by the kernel it just does nothing, otherwise it kicks in. - Huawei E220 (aka "Vodafone EasyBox II", aka "T-Mobile wnw Box Micro")
- Huawei E160, E160G, E169, E180, E230, E270(+),
E280, E630, E870, E1550, E1612, E1662, E1690,
E1692, E1750, E1752, EC168C, K3765, K4505, K4605,
MTE WM610, R201, K4605, K3765, K4505
- Huawei E630
There are reportedly modem-only variants around (without the storage part); for these no switching is required. - Huawei U7510 / U7517 (phone), U8110 (Android smartphone)
Like the sticks, these phones have software for Windows onboard and must be switched - Novatel Wireless Ovation MC950D HSUPA, Ovation 930D and Merlin XU950D
May switch with "eject <device>" as well - Novatel Wireless U727, Novatel Wireless U760, Novatel MC990D,
Novatel MC760 3G
- All ZTE devices
Some ZTE devices can be switched by issueing the "eject" command to the "CD-ROM" device as well.
Please read the last paragraph in Troubleshooting! - ZTE MF620 (aka "Onda MH600HS")
- ZTE MF622 (aka "Onda MDC502HS")
- ZTE MF100, MF110 variants, ZTE MF112, MF626, MF627, MF628,
MF628+, MF651
- ZTE MF636 (aka "Telstra / BigPond 7.2 Mobile Card")
- ZTE MF638 (aka "Onda MDC525UP")
- ZTE MU351 (may also work for MF350)
- ZTE AC581
- ZTE AC8710, AC2710 (EVDO, featured by PTCL)
- ZTE 6535-Z (featured by SFR)
- ZTE K3520-Z, K3565, K2525, K4505-Z, K3805-Z,
K3570-Z, K3571-Z, K3806-Z
- ONDA MT503HS, MT505UP, MW833UP
- Alcatel One touch X020 (aka OT-X020, aka "MBD-100HU", aka "Nuton 3.5G",
works with "Emobile D11LC")
- Alcatel One touch X030 (aka OT-X030, aka "Nuton NT36HD")
- Alcatel X200, X220L
- AnyDATA ADU-500A, AnyDATA ADU-510A, AnyDATA ADU-510L, AnyDATA ADU-520A
- BandLuxe C120, C170, C270
- Solomon S3Gm-660
Seems to be related to the BandLuxe C120 above - C-motech D-50 (aka "CDU-680")
Important notes at this Forum Entry - C-motech CGU-628 (aka "Franklin Wireless CGU-628A" aka "4G Systems XS Stick W12")
- C-motech CHU-629S
- Toshiba G450
- UTStarcom UM175, UTStarcom UM185E (distributor "Alltel")
- Hummer DTM5731
- A-Link 3GU
- Quanta/Royaltek MU-Q101, Q110
- Sierra Wireless AirCard/Compass and all others
Supported by newer kernels. If you are stuck with an older one, use USB_ModeSwitch - Sony Ericsson MD300, MD400, MD400G (aka "Rogers Rocket Stick")
Special handling, takes around 25 seconds to switch - LG LDU-1900D, L-05A, LUU-2100TI, KP500 (experimental)
- Samsung SGH-Z810 USB (with microSD card)
- Samsung GT-B3730 (LTE/4G)
Switching fine, but driver situation yet unknown - MobiData MBD-100HU, MobiData MBD-200HU
- MyWave SW006 Sport Phone/Modem Combination
- Hyundai Mobile MB-810
Same parameters as Option iCON 210 - PROLiNK PHS100 (various looks)
Same parameters as Option iCON 210 - Cricket A600
Switches to ACM device. Might need a ResetUSB after switching - or not - EpiValley SEC-7089 (featured by Alegro and Starcomms / iZAP)
- ST Mobile Connect HSUPA USB Modem
- D-Link DWM-162-U5
- Micromax MMX 300c
- Philips TalkTalk, HuaXing E600 (NXP Semiconductors "Dragonfly")
- Motorola 802.11 bg WLAN (TER/GUSB3-E)
- Sagem F@ST 9520-35-GLR
- Nokia CS-10, CS-15
- Vodafone MD950 (Wisue Technology)
- Siptune LM-75 ("LinuxModem")
- Zydas ZD1211RW WLAN USB
Switching code will be removed from the kernel driver in the 2.6.32 series - Sphairon HomeLink 1202
- Vertex Wireless 100 Series
- AVM Fritz!Wlan USB Stick N
This will switch itself after a (long) while with no action from outside; with USB_ModeSwitch or "eject" the change happens immediately after plugging - InfoCert Business Key (SmartCard/Reader emulation)
- Beceem BCSM250 Mobile WiMAX modem
The driver situation is not clear yet - Novatel 2352 MiFi (generic), Vodafone MiFi 2352 (variant)
- Franklin Wireless U210
- Netgear WNDA3200 (Atheros Wireless)
- BSNL EVDO Capitel
- Olivetti Olicard 100, Olicard 145
Troubleshooting
Note: if you still need support after having followed the advice on this page, please use the forum! E-mail may be used for device/config contributions.Known quirks:
- Automatic serial driver assignment works only for kernels from 2.6.27 and up. If your modem
is not recognized by any driver (no ttyUSB device after switching) and you have an older kernel,
the only way is to use the generic serial driver where you can provide the USB ID as a parameter
when loading it as a module.
- There is a problematic handling of devices with ID 19d2:2000 in kernels 2.6.26 to 2.6.28. This affects mostly ZTE devices and makes the "usb-storage" driver ignore the ID. In turn this will prevent proper initialization and may cause switching to fail. There is no other way around this than compiling your own kernel with some tiny edits. See Kernel related issues below for details.
For debugging of the automated system integration, edit (as root or su) /etc/usb_modeswitch.conf in a text editor and change the line
EnableLogging=0to
EnableLogging=1This gives you a verbose output of the hotplug activity to /var/log/usb_modeswitch_<device>.
If you're next to certain that you have the right values for your device, followed all the hints (see Known working hardware), and USB_ModeSwitch seems to do something run after run but to no effect, there are most likely system issues involved.
The first suspects are existing system rules for modems which handle things not
quite correctly.
If you own a device with the unswitched ID of 05c6:1000, it will most likely
get a wrong switching command. There are four different types of switching devices,
all with that same ID; in the big distributions they are all treated alike as a
model from "Option" (the manufacturer) which is wrong in three out of four cases.
There are even cell phones with that ID which get the same treatment when connected
to an USB port.
To fix problems like that you can try to remove rules files from "/lib/udev/rules.d"
which contain calls to "modem-modeswitch".
USB_ModeSwitch will do additional checks beside the USB ID and treat all known
ambiguous devices in the right way. Furthermore, it leaves unknown devices with
the 05c6:1000 ID alone.
Annother notorious candidate is again 19d2:2000. It may be switched O.K. by an existing
rule, but there is no driver loading if your model is new and its ID is not yet added to
the "option" module.
Disable the rule running "eject" and the ID will be handled by usb_modeswitch.
Kernel related issues
In some newer kernels, certain device families (some Option, some Huawei, some ZTE as mentioned above) get a special treatment in the usb-storage code to enable switching right away. You would not need USB_ModeSwitch anymore for these specific dvices; on the other hand you have no choice of accessing the "CD-ROM" part of your device. Plus, there were cases when the special treatment brought no results and furthermore prevented USB_ModeSwitch to work properly afterwards (happened with ZTE devices, error "-2").
In case of trouble, look into "unusual_devs.h" in the "drivers/usb/storage" folder of
your kernel source. If your default ID (vendor and product ID of the storage part) can be found there and
you get errors when running USB_ModeSwitch, try first to blacklist "usb-storage".
If that helps, you should consider rebuilding your kernel with the entry in "unusual_devs.h" deactivated.
The only thing that will happen is that usb-storage works in the default way afterwards.
I found a tip in the Russian Gentoo wiki to
do exactly what I just suggested for the ZTE MF626.
Annother way of influencing the kernel behaviour is the parameter "delay_use" of
"usb-storage" which sets the time in seconds after plugging when the storage device will
actually be used (and probably automounted). The default value is 5; this might affect
the switching result under certain conditions.
To change the default add in /etc/modprobe.conf:
options usb-storage delay_use=1 (or 10, or other)I will try and monitor - possibly influence - further kernel development to prevent unpleasant surprises in the future.
Between the kernel USB developers there is a consensus about future removal of any switching code from the kernel if the "userspace" handling is broadly working and available.
Contribute
USB_ModeSwitch comes quite handy for experimenting with your own hardware if not supported yet. You could try this approach:
Note the device's Vendor and Product ID from /proc/bus/usb/devices (or from
the output of "lsusb"); the assigned driver is usually "usb-storage".
Then try spying out the USB communication to the device with the same ID inside M$ Windoze.
I recommend this tool: "SniffUSB" (http://www.pcausa.com/Utilities/UsbSnoop/default.htm).
Alltel UM175AL USB EVDO under Ubuntu Hardy Heron
Please post any improvements, new device information and/or bug reports to the ModeSwitchForum !
If you don't need support you can also send me an old-fashioned - and at your demand
confidential - e-mail (see below).
Whodunit
Copyright (C) 2007, 2008, 2009, 2010- Josua Dietze (usb_admin at this domain)
Other contributors
Command line parsing, decent usage/config output and handling, bugfixes added by:- Joakim Wennergren (jokedst) (gmail.com)
- Paul Hardwick (http://www.pharscape.org)
- "usbsnoop2libusb.pl" by Timo Lindfors (http://iki.fi/lindi/usb/usbsnoop2libusb.pl)
- Guillaume Dargaud (http://www.gdargaud.net/Hack/SourceCode.html)
- Jouni Malinen (http://hostap.epitest.fi/wpa_supplicant, from "common.c")
- Aki Makkonen
- Denis Sutter
- Lucas Benedičič
- Roman Laube
- Luigi Iotti
- Vincent Teoh
- Tommy Cheng
- Daniel Cooper
- Andrew Bird
- Yaroslav Levandovskiy
- Sakis Dimopoulos
- Steven Fernandez
- Christophe Fergeau
- Nils Radtke
- Andrei Nazarenko
History
Version 1.1.4, 2010/08/17Success check bugs (and others) fixed
Version 1.0.3, 2009/08/20
Some output bugs fixed
Version 1.0.1, 2009/06/08
Added output of descriptor strings for further identification
Version 1.0.0, 2009/06/03
Updated SonyMode, MD 400 now stable; automatic default endpoint detection from Andrew Bird
Version 0.9.7beta, 2009/03/15
Major code clean up, optional success control (both suggested by Daniel Cooper), new devices
Version 0.9.6, 2009/01/08
Special modes added for Sierra and Sony Ericsson, new devices
Version 0.9.5, 2008/10/27
New options for USB tuning added (jokedst), lots of new devices, clean up
Version 0.9.4, 2008/06/09
Compat fix for libusb on FreeBSD quirks, more devices
Version 0.9.4beta2, 2008/03/19
Udev 'release' fix
Version 0.9.4beta, 2008/03/16
Multiple device support
Version 0.9.3, 2008/03/09
More devices, no other changes from 0.9.3beta
Version 0.9.3beta, 2007/12/30
New TargetClass parameter for recent Option firmware (Paul Hardwick), more devices
Version 0.9.2, 2007/11/02
New Huawei mode (code from Miroslav Bobovsky, added by Denis Sutter), more devices
Version 0.9.1beta, 2007/09/11
Added command line parsing (jokedst), cleaned up config stuff (jokedst), bug fixes, doc updates
Version 0.9beta, 2007/08/12
Name change from "icon_switch", parameter file and generalizing
Version 0.2, 2006/09/25
Code cleaning, more messages
Version 0.1, 2006/09/24
Just very basic functionality ...
Legal
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details:
http://www.gnu.org/licenses/gpl.txt