3

I have a 4G module that requires me to run

echo '03f0 581d' > /sys/bus/usb-serial/drivers/generic/new_id

after every startup/resume to make the modem visible. How should I make this automatic?

  • Add the VID&PID to usb-serial sources and recompile
  • Create script that run on startup/resume that adds them dynamically
  • Some sort of udev rule?

What would be the best approach. I think the udev approach sounds the most reasonable. I assume that would work over suspend/resume too?

The modem is a HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei ME906E).

Bonus question: Why does the command need to be re-run after a suspend/resume cycle. Does the kernel module get unloaded or somehow reset when the laptop gets suspended to RAM?

2
  • @don_crissti I've thought the primary function of usb_modeswitch was to send some kind of payloads to the device to for example switch from storage mode to serial mode. I guess it might handle attaching right modules as well
    – varesa
    Nov 7, 2015 at 5:04
  • @don_crissti Done.
    – varesa
    Nov 8, 2015 at 7:44

1 Answer 1

1

Assuming your device's vendor and product IDs are as configured above, ie 03f0 and 581d respectively, you can create a udev rule that will automatically initialize the device and bind it to libqmi, as shown below:

file /etc/udev/rules.d/98-modem-rules.rules

Create the file using your favorite text editor (and appropriate permissions, sudo is required) with the content:

ACTION!="add|change", GOTO="mbim_to_qmi_rules_end"
SUBSYSTEM!="usb|drivers", GOTO="mbim_to_qmi_rules_end"

# load qmi_wwan module
SUBSYSTEM=="usb", \
ATTR{idVendor}=="03f0", ATTR{idProduct}=="581d", \
RUN+="/sbin/modprobe -b qmi_wwan"

# Initialize the LTE lt112 module to operational status:
SUBSYSTEM=="usb", \
ATTR{idVendor}=="03f0", ATTR{idProduct}=="581d", \
ATTR{bConfigurationValue}="3"

# add the new id in the qmi_wwan driver
SUBSYSTEM=="drivers", \
ENV{DEVPATH}=="/bus/usb/drivers/qmi_wwan", \
ATTR{new_id}="03f0 581d"

# load qcserial module
SUBSYSTEM=="usb", \
ATTR{idVendor}=="03f0", ATTR{idProduct}=="581d", \
RUN+="/sbin/modprobe -b qcserial"

# add the new id in the qcserial driver
SUBSYSTEM=="drivers", \
ENV{DEVPATH}=="/bus/usb-serial/drivers/qcserial", \
ATTR{new_id}="03f0 581d"
LABEL="mbim_to_qmi_rules_end"

On your machine, you'll also need to install the appropriate packages:

Assuming Ubuntu (as no distribution information was given), run:

sudo apt install libqmi libqmi-utils

When done, activate the new udev rule:

sudo udevadm control --reload-rules
sudo udevadm trigger

You may also find modem-manager, a GUI front-end to see modem stats, such as network signal strength, etc, to be of use.

It can be installed via:

sudo apt install modem-manager-gui

A cold start will be required after inserting a SIM card.

Update:

An alternative to this would be to install the package usb-modeswitch-data (which will also pull in usb-modeswitch as a dependency).

The package contains udev rules that allow usb-modeswitch to initialize the device correctly, with multiple entries for multiple devices. See the changelog(s) on the same here.

The udev rules in the package are stored in a file called 40-usb_modeswitch.rules. For your particular hardware, its' on line 32-33:

# HP hs4112
ATTR{idVendor}=="03f0", ATTR{idProduct}=="581d", RUN+="usb_modeswitch '/%k'"

After installing usb-modeswitch and usb-modeswitch-data, you'll need to reboot, even after reloading udev rules before the SIM card is recognized.

1
  • 1
    usb-modeswitch seems like the easiest option now. Support for the 4112 was added a year after I asked the question so it was not an option at the time.
    – varesa
    May 25, 2020 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .