http://www.draisberghof.de/usb_modeswitch/USB_ModeSwitch - Activating Switchable USB Devices on Linux
If you don't like the text column width, adjust your browser window IntroductionUSB_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 an USB modem) shows up. The WWAN gear maker Option calls that feature "ZeroCD (TM)". As you may have guessed, nothing of this is documented in any form and so far there are no official Linux drivers available (with the notable exception of Option products). On the good side, most of the known devices work out of the box with the available Linux drivers like "usb-storage" or "usbserial" (in recent kernels quite a lot of devices are acknowledged by the "option" module). 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 with Linux.
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. Please read the information on this page carefully before you go around posting questions! This is no tool that does it all for you automagically (yet). It really helps to understand in principle what is happening, which in turn makes it easy to adapt the config file to your setup or even do your own exploring of new devices. For hints about doing your own sniffing see paragraph Contribute below Breaking News: just found this humble tool in the source code of the fine Dovado UMR router, which they publish in compliance with the GPL. So if you want the power of your Wireless Broadband across your local network, but without the "fun" of setting up your own Linux router (as I did), consider investing in such a machine. DownloadThe latest release version is 1.0.5. The tar archive contains the source and a i586 binary (32 bit, GCC 4.3.2). I used libusb-0.1.12.There are changes and updates to the config file more often than new releases; most of the valuable knowledge about devices is contained in this file. So you better use the latest version linked here.
How to installUnpack and run "make install". Edit "/etc/usb_modeswitch.conf" according to your hardware (it's heavily commented and should tell you what to do).If you want to compile it for yourself, just delete the binary, then run "make" or type on the shell: $ gcc -l usb -o usb_modeswitch usb_modeswitch.cThat's as easy as it gets. And it should be as portable as libusb itself (some limitations on FreeBSD based systems are known). If installing manually, take the executable "usb_modeswitch" and put
it into your path (preferably "/sbin" or "/usr/sbin").
Alternatively you can use the command line interface to tell
USB_ModeSwitch
the things it needs to know; try "usb_modeswitch -h" to list the
parameters.
This way you can handle multiple configurations. If any command line
parameters
except -W and -q are used, the default config file is NOT read. Important: USB_ModeSwitch - like all programs with libusb routines - has to be run as root. Otherwise strange error messages come up ... How to use and to automateIf your device was switched successfully, there are three possible outcomes:
Mind that you have to run USB_ModeSwitch every time you plug your
device or boot with it.
If you have "udev" in your distribution it's really not hard to
automate this and just
forget about it, once you figured how to switch your device manually. Here is the manual way: You should have a folder named "/etc/udev" or similar. Somewhere in
there (I have a
folder "rules.d") you find some files with the extension ".rules".
Create a new one (or
edit an existing one, but by convention not the default
"50-something.rules").
I chose one named "45-hotplug.rules" since hotplugging is what USB is
about after all. SUBSYSTEM=="usb", SYSFS{idProduct}=="<YourDefaultProdID>", SYSFS{idVendor}=="<YourDefaultVendID>", RUN+="<YourPathToUSB_ModeSwitch>"That's basically it. From here, there are several ways to continue. If your GSM device is
recognized by a recent version of the "option"
driver you shouldn't have to do anything but to load the module (most
certainly handled by udev automatically). Some
devices switch to the ACM class and are bound to the module "cdc-acm"
("USB Abstract Control Model driver for USB
modems and ISDN adapters"). The created serial devices are named
"ttyACM0", "..1", etc. instead of "ttyUSB0" ... As for the difference between "usbserial" and "option", here is a quote from option.c: This driver exists because the "normal" serial driver doesn't work too well with GSM modems. Issues: - data loss -- one single Receive URB is not nearly enough - nonstandard flow (Option devices) control - controlling the baud rate doesn't make sense Devices supported by the "option" driver that don't change their IDs after switching might run into problems because of the driver trying to attach before the switching happened. In this case it could help to blacklist it and to load it manually via the helper script after execution of usb_modeswitch. In newer kernels (definitely in 2.6.28) this problem is handled by probing for the device class before binding. Known working hardwareVery 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:
TroubleshootingNote: if you still need support after having followed the advice on this page, please use the forum!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. Almost all distributions today are using "udev" as a device and hotplug manager, and in some cases this daemon is not able to "release" the established connection of a switched device and to see it as a freshly plugged one (after all, this is something outside the USB specs). There are several ways to analyze and tackle these problems:
Kernel related issuesIn newer kernels, some device families (Huawei, ZTE since 2.6.26) get a special treatment in the usb-storage code to enable switching right away. You don't even need USB_ModeSwitch anymore; 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 obviously brought no results and even 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 mounted). The default value is 5; this might affect the switching result in some way, especially when using an udev rule. I'd be interested to learn about good or bad results of playing around with it. Add in /etc/modprobe.conf: options usb-storage delay_use=1 (or 10, or other) Kernel SupportStandby for more content ...ContributeUSB_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. Alltel UM175AL USB EVDO under Ubuntu Hardy Heron Please post any improvements, new device information and/or bug
reports to the ModeSwitchForum
! WhodunitCopyright (C) 2007, 2008, 2009
Other contributorsCommand line parsing, decent usage/config output and handling, bugfixes added by:
HistoryVersion 1.0.5, 2009/08/26 More changes and fixes regarding
success check; "--version" option; config "database" updated
Version 1.0.4, 2009/08/23Success check bugs (and others) fixed Version 1.0.3, 2009/08/20 Success check improved; experimental
system integration (fully automated), optional; new parameter
"TargetProductList" needed for this; other necessary small adaptations;
more devices
Version 1.0.2, 2009/06/09Some 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 Attention: possible
incompatibilities for command line control! On/off flags don't
require arguments anymore (-H, -S, -O, -d, -R, -n, new: -I), meaning
"-R 0" does a reset like "-R 1" or "-R"; long option names changed to
standard format (e.g. --HuaweiMode to --huawei-mode); added device
inquiry, for future help with device identification; catch error -19 as
possible success; send and response endpoints now autoselected
(consequently NeedResponse is back); code cleanup; new devices
Version 0.9.7, 2009/04/15Updated 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 ... LegalThis 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: |