Trigger usb_modeswitch on boot for Huawei E3372 Modem

huaweimodemusb deviceusb-modeswitch

I am trying to make a Huawei Brovi E3372-325 USB LTE model work with a Raspberry Pi. Out of the box, it shows as a CDROM when plugging it in. (This is apparently used to automatically run the driver installation on Windows.)

So far, I found this post with a udev rules configuration file. That enables the modem when hotplugging it while the system is running by running usb_modeswitch. However, if the modem is plugged in on boot, it does not work, instead showing as a CD ROM.

Therefore, I am now trying to write a system service to run usb_modeswitch on boot. As a step towards that, I booted with the modem plugged in and then tried executing the usb_modeswitch commands from the configuration file manually. However, that does not have the intended effect.

The commands are

/sbin/usb_modeswitch -v 3566 -p 2001 -W -R -w 400
/sbin/usb_modeswitch -v 3566 -p 2001 -W -R

What do I need to do to make this work? Does the udev rules configuration trigger more actions that just the two listed commands? Or why do the seemingly same commands not have the same effect?

Update

Apparently, upon being powered on, the modem shows itself as a modem for a second, then switches to CDROM mode, but does not seem to accept commands switching it back to modem mode. The CDROM mode is intended for automatic driver installation in Windows. Though, that also means that when the driver is installed, the drive can be switched back to modem mode. So, it seems that usb_modeswitch and the Windows driver use different commands to switch to modem mode?

Best Answer

Those commands don't do anything useful on their own; both only reset the USB port. Actual mode-switching would be done using the -J or -X options (the former switches it to CDC fake-Ethernet mode; the latter to MBIM modem mode).

However, the modem also appears to start in RNDIS fake-Ethernet mode, only switching to CDROM mode if nothing binds to the RNDIS interface within a second. So the behavior will be different during normal connection (when udev is ready to load the driver instantly) vs during a system boot (when it takes a while between USB device initialization and driver load).

At least that was the case when I originally got mine, but then it mysteriously switched behavior two days later. I believe it must've downloaded a firmware update¹ and now its "startup" appears to be completely different – when connected it only stays 3566:2001 for a second before turning into 12d1:1f01, which usb_modeswitch recognizes and switches to CDC fake-Ethernet mode. (It also freezes a lot.)


¹ It's not just a modem, it's a whole Linux device on a stick, complete with internal web server and automatic updates.

Related Question