usb_modeswitch

I'm trying to use usb_modeswitch to get my Huawei E3372 4G USB Modem to connect with the Internet and am following some Linux guide

I realise that the guide is for Linux and Raspberry Pi, but assume the principles should be similar and if I can get it working in that environment, a similar procedure should work on a laptop running FreeBSD...

One query I have is about the usb_modeswitch database /usr/local/share/usb_modeswitch... Is this a universal database where entries for vendor/product would be the same irrespective of OS? And if an entry is missing could I copy it from one system to another?


One strange thing I found was that on Linux lsusb showed the vendor/product as
12d1:1506
but on FreeBSD it was
12d1:14fe
not sure how it could be different.... Aren't these values embedded in the device somewhere?

FreeBSD does contain the file
/usr/local/share/usb_modeswitch/12d1:14fe


The contents of which are
Code:
# Huawei E352 (T-Mobile NL), E173s (Variant)
TargetVendor=0x12d1
TargetProductList="1506,150f,151d,1c1e"
HuaweiNewMode=1

I notice that I do have a
/usr/local/etc/usb_modeswitch.conf

the contents of which are
Code:
# Configuration for the usb_modeswitch package, a mode switching tool for
# USB devices providing multiple states or modes
#
# Evaluated by the wrapper script /usr/sbin/usb_modeswitch_dispatcher
#
# To enable an option, set it to "1", "yes" or "true" (case doesn't matter)
# Everything else counts as "disable"


# Disable automatic mode switching globally (e.g. to access the original
# install storage)

DisableSwitching=0

# Disable check for MBIM module presence and configuration globally (to aid
# special embedded environments). Available as per-device parameter
# 'NoMBIMCheck'

DisableMBIMGlobal=0

# Enable logging (results in a extensive report file in /var/log, named
# "usb_modeswitch_<interface-name>" and probably others

EnableLogging=0

# Optional increase of "delay_use" for the usb-storage driver; there are hints
# that a recent kernel default change to 1 sec. may lead to problems, particu-
# larly with USB 3.0 ports. Set this to at least 3 (seconds) in that case.
# Does nothing if the current system value is same or higher

#SetStorageDelay=4

# If the configuration for your Huawei modem uses the standard switching method,
# you can globally set an alternative method here which provides a different mode:
# either plain serial PPP (for older modems) or NCM which integrates nicely
# with recent Linux distributions, possibly avoiding configuration through a
# modem built-in web page. All other modems are not affected.
# Available as per-device parameter 'AltHuaweiMode'

HuaweiAltModeGlobal=0
I have no idea what the source of this file is and whether I should append something to it based on my USB vendor/product.

Can anyone advise?
 
Just noticed.... On FreeBSD...
Code:
/dev/usb Device /dev/ugen1.3: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode)

On Linux...
Code:
/dev/usb Device /dev/ugen1.3: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem/Networkcard

Looking at /usr/local/etc/usb_modeswitch_conf, which both have, the only difference is that the FreeBSD version contains:
Code:
# If the configuration for your Huawei modem uses the standard switching method,
# you can globally set an alternative method here which provides a different mode:
# either plain serial PPP (for older modems) or NCM which integrates nicely
# with recent Linux distributions, possibly avoiding configuration through a
# modem built-in web page. All other modems are not affected.
# Available as per-device parameter 'AltHuaweiMode'

HuaweiAltModeGlobal=0
at the end of the file.

What is it that installs this conf file along with the usb_modeswitch database in /usr/local/share?

I'll try commenting out the last line and see if that changes the productid when running lsusb.
 
Hi,

I use usb-modeswitch on my Raspberry Pi with a Huawei 3G cellular mobile USB modem to connect my perimeter firewall to the Internet.

Linux can use udev rules to automatically switch to serial mode when when ever the device is plugged in, but I don't use them. I switch it explicitly from the rc script that brings up the ppp link.

Google suggests that, for your modem, the mass storage id is 0x1506 and the modem id is 0x1446.

Usually usb-modeswitch usually works fine, without changes.

My guess is that if the device identifies as "12d1:14fe" it may already be in serial mode. But you would need to verify that.

You should verify that /usr/local/share/usb_modeswitch/12d1:1506 exists.

I would then try the following:

Code:
usb-modeswitch -v 0x12d1 -p 0x1506 -c /usr/share/usb_modeswitch/12d1:1506
The command will tell you what it is doing on stdout.

Cheers,
 
You should verify that /usr/local/share/usb_modeswitch/12d1:1506 exists.

I have just reinstalled sysutils/usb_modeswitch and there is no 12d1:1506...

There is a 12d1:14fe:-

Code:
# Huawei E352 (T-Mobile NL), E173s (Variant)
TargetVendor=0x12d1
TargetProductList="1506,150f,151d,1c1e"
HuaweiNewMode=1
lsusb (fromsysutils/usbutils) shows
Code:
Bus /dev/usb Device /dev/ugen1.3: ID 12d1:14fe Huawei Technologies Co., Ltd. Modem (Mass Storage Mode)

so it appears not to be in serial mode. One thing which puzzles me is why does lsusb come up with this Vid/Pid when this file suggests the device is an E352 rather than an E3372.
 
What happens if you run:

Code:
usb-modeswitch -v 0x12d1 -p 0x14fe -c /usr/share/usb_modeswitch/12d1:14fe
(I would expect it to report that it was looking at the modem, conclude there was nothing to do in order to switch into serial mode, and exit with zero status.)

Regarding device identification, it's common for several different models to share a common configuration. Don't sweat on the name in the file.

Cheers,
 
What happens if you run:

Code:
usb-modeswitch -v 0x12d1 -p 0x14fe -c /usr/share/usb_modeswitch/12d1:14fe
Code:
usb-modeswitch: Command not found.
;)
...but you probably meant...

usb_modeswitch -v 0x12d1 -p 0x14fe -c /usr/share/usb_modeswitch/12d1:14fe

Code:
Error: Could not find file /usr/share/usb_modeswitch/12d1:14fe. Abort
 
The modeswitch config files live in various locations depending on the port.

You said above that "There is a 12d1:14fe", and also, from above probably in /usr/local/share/usb_modeswitch/12d1:14fe.

So verify it's there,
Code:
find /usr -name 12d1:14fe
and try it:
Code:
find /usr -name 12d1:14fe
usb_modeswitch -v 0x12d1 -p 0x14fe -c /usr/local/share/usb_modeswitch/12d1:14fe

Cheers,
 
Sorry, it was late and I ran the command without thinking....

usb_modeswitch -v 0x12d1 -p 0x14fe -c /usr/local/share/usb_modeswitch/12d1:14fe

Code:
Look for target devices ...
 No devices in target mode or class found
Look for default devices ...
   product ID matched
 Found devices in default mode (1)
Access device 003 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI_MOBILE
     Product: HUAWEI_MOBILE
  Serial No.: 0123456789ABCDEF
-------------------------
Using standard Huawei switching message
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response reading failed (error -99)
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

lsusb
Code:
Bus /dev/usb Device /dev/ugen1.3: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard

So it looks like it worked, many thanks.

Just wondering if this is a permanent change or do I need to run it every time I insert the modem...

I guess I just check... - it looks to be set permanently now.
 
Hi,

I expect some type of reset or power loss would switch it back to mass storage mode.

udev(7) may assist, as usb_modeswitch is designed to work with the Linux udev. That's the path I would pursue (for clues, look at the udev stuff in the usb_modeswitch source package).

Alternatively, the outcome above suggests that you could wrap your dial script and prepend the following:

Code:
lsusb | grep -q '12d1:14fe' && usb_modeswitch -v 0x12d1 -p 0x14fe -c /usr/local/share/usb_modeswitch/12d1:14fe
Cheers,
 
I've just been playing with Linux Debian and clicked on 'Network Manager' after inserting the 4G dongle and it 'just worked'!!!

Do we have a Network Manager for FreeBSD?
 
I've just been playing with Linux Debian and clicked on 'Network Manager' after inserting the 4G dongle and it 'just worked'!!!

Do we have a Network Manager for FreeBSD?

  • Opal's net-mgmt/wifimgr, works well
  • net/wpa_gui, my favourite: lightweight, well performing, basically just a GUI front-end for wpa_supplicant including a systray applet
  • Eric Turgeon's net-mgmt/networkmgr from GhostBSD project: the most featured, and closest to Linux' Network Manager
  • TrueOS' pc-netmanager available inside sysutils/pcbsd-utils-qt5. Not bad, but you'll have to install the full PC-BSD metaport
 
After messing around with Arch Linux, I've found that it runs usb_modeswitch whilst booting and when running lsusb the VID/PID values for my Huawei E3372 are 12d1:1506.

The PID seems to be re-assigned via a lookup table in /etc/usbmodeswitch.setup (on Arch Linux) and a MessageContent number is provided. Thsi MessageContent value is probably significant.

Not sure how all this lot works, but I don't think FreeBSD provides this facilty.

Anyone know?
 
In FreeBSD we use the config file, and devd for the events. I'm not at one of my FreeBSD machines right now, so I can't give you an example. Google for it, or read the man page.
 
In FreeBSD we use the config file, and devd for the events. I'm not at one of my FreeBSD machines right now, so I can't give you an example. Google for it, or read the man page.

I've read the man page and it mentions something about usb_modeswitch_dispatcher which I don't think is relevant to FreeBSD, but there is probably something equivalent.

There are also three huawei modes so am not sure which is relevant. Also, on Arch Linux there is a /etc/usb_modeswitch.setup which includes the DefaultVendor/Product for my dongle along with the TargetVendor/Product along with a MessageContent string.

I don't see anything like this on FreeBSD.
 
Don't worry about the usb_modeswitch.setup file; you don't need it. Simply put the necessary items into /usr/local/etc/usb_modeswitch.conf. Here is an example:
Code:
# Dymo LabelManager PnP

DefaultVendor= 0x0922
DefaultProduct=0x1001

TargetVendor=  0x0922
TargetProduct= 0x1002

MessageEndpoint= 0x01
ResponseEndpoint=0x01

MessageContent="1b5a01"
HTH
 
I now have this in /usr/local/etc/usb_modeswitch.conf:-
Code:
DisableSwitching=0

DisableMBIMGlobal=0

EnableLogging=0

#SetStorageDelay=4

HuaweiAltModeGlobal=0

DefaultVendor= 0x12d1
DefaultProduct=0x14fe

TargetVendor=  0x12d1
TargetProduct= 0x1506

MessageContent="55534243123456780000000000000011062000000100000000000000000000"

How does thia look?

I've no documentation on MessageContent and have no idea whether it is correct or what it is supposed to do. At least my E337 show the required Pid/Vid. Now to get it working with PPP.

Here is a link I found which I'll post here for my own reference in case I lose it.
 
In FreeBSD we use the config file, and devd for the events. I'm not at one of my FreeBSD machines right now, so I can't give you an example. Google for it, or read the man page.

I've never used devd and am not really sure what it does, but assume it provides something like an initialisation script for a particular device.... Looking at devd.conf() I can't figure out what I need to include so that usb_modeswitch will run at any particular time.
I'm hoping that I can get it to run either on boot or when my USB modem is inserted. A link to an example would be appreciated.
 
Back
Top