How to disable USB mode-switching on Huawei 3G sticks?

Huawei 3G USB sticks ("dongles") support a special command to control the mode how they will appear to a host computer. This allows to switch off the flipflop USB capability, also called USB modeswitching.

USB modeswitching means that these and many other USB 3G sticks at first only provide a virtual CD-ROM drive to the computer from which a (Windows) computer will install the device drivers, and then the device will switch to show only a 3G modem interface. This of course does not work with non-Windows computers like Linux and Android systems, making it a completely bad idea of course. For Linux, there is now the usb_modeswitch utility which now switches the device to the 3G modem mode more or less automatically, but this is still not standard for Android (though possible on rooted devices, and included in the PPP Widget app for rooted devices).

So for using Huawei 3G sticks on non-rooted Android devices, we want to disable the virtual CD-ROM mode permanently. This can be done as follows on a Linux host:

  1. Make sure you execute these steps from a computer that can see the serial line interfaces of the device. This should be possible on any Linux computer that has usb_modeswitch installed and configured, like done by default on at least Ubuntu 12.10 (and newer).
  2. Find out the first USB interface of the device by doing ls /dev/ttyUSB* before and after plugging the 3G stick in and taking the first result.
  3. Open one terminal for receiving messages from the device, by executing cat /dev/ttyUSB1 (using your device number of course).
  4. In another terminal, send a command to the stick to test communication with it. Execute echo "ATi^M" > /dev/ttyUSB1. But note: You can not simply copy this over, as the ^M is just the visual representation of a single control character. Enter this character in the terminal directly by pressing Ctrl+V and afterwards Ctrl+M.
  5. Now, your terminal with cat should display information that the stick sent about itself.
  6. If this worked, now send the command to disable the virtual CD-ROM mode: echo "AT^U2DIAG=0^M" > /dev/ttyUSB1. Note that ^M is again a control character that you have to enter specially (see above), but ^U is just normal text, so you can copy & paste it.
  7. Now your cat terminal should answer with OK. If so, the command was successful. [source]

The basic idea for this console based process comes from the article "Send AT commands to USB modem" by brunomgalmeida.

There are also instructions on an equivalent procedure using Windows; however I was not able to follow that procedure as my Huawei K3715 3G stick did not let me talk to it through a serial terminal at all, probably because I set it up with bad connection speed etc. settings (as these were nowhere to be found …).

Also compare "Hayes command set" on Wikipedia for more information.


Posted

in

,

by

Tags:

Comments

3 responses to “How to disable USB mode-switching on Huawei 3G sticks?”

  1. Note that you can replace this:

    echo “ATi^M” > /dev/ttyUSB1. But note: You can not simply copy this over, as the ^M is just the visual representation of a single control character. Enter this character in the terminal directly by pressing Ctrl+V and afterwards Ctrl+M.

    with

    echo -e “ATi\r” > /dev/ttyUSB1

  2. You can also use the minicom program to send AT commands. Use minicom -D /dev/ttyUSB0 (replacing “ttyUSB0” of course if necessary). Then you don’t need to send the special character (^M), just type “ATi” followed by the Enter/Return key.

  3. @Possum: Thank you for the comment! That’s a valuable hint, and I was not aware of this little tool so far.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.