USB switching to unwanted dev at boot

Greetings,

when booting with Huawei E3372 USB stick plugged in, it is recognized as

New USB device found, idVendor=12d1, idProduct=14db

This devcice is NOT wanted.

However when i manually unplug and insert the USB devive it is recognized as

New USB device found, idVendor=12d1, idProduct=155e

This is the device I want.

I’m using usb_modeswitch 2.5.1 with
**EnableLogging=1
HuaweiAltModeGlobal=1
**
Is there a proper way to logically remove/insert a USB device via script?
Currently I’m using a script like

USB_DEV=1-1
echo ${USB_DEV} > /sys/bus/usb/devices/1-1/driver/unbind
sleep 10
echo ${USB_DEV} > /sys/bus/usb/drivers/usb/bind

USB_DEV is taken from a prevous dmesg

Thanks for reading and comments.

**"**By default, your linux box would register your Huawei E8372 as a Mass Storage device and not (somehow) as a modem. First, make sure you have the exact same device we’re talking about. This can be confirmed by looking at 2 values."
https://gist.github.com/guseppiguliano/614055d0bc260f5ea305d71439a03790

usb_modeswitch is the proper way and should run automatically. Reboot and before doing anything run as root

udevadm test -a add /sys/bus/usb/devices/1-1

Adjust device name as needed and post complete command and its full ouptut.

Ok, rebooted and udevadm test -a add /sys/bus/usb/devices/4-1

MAG-HP0:~ # udevadm test -a add /sys/bus/usb/devices/4-1 
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

Load module index
Network interface NamePolicy= disabled by default.
Parsed configuration file /usr/lib/systemd/network/99-default.link
Created link configuration context.
Reading rules file: /usr/lib/udev/rules.d/00-dont-del-part-nodes.rules
Reading rules file: /usr/lib/udev/rules.d/01-md-raid-creating.rules
Reading rules file: /usr/lib/udev/rules.d/10-dm.rules
Reading rules file: /usr/lib/udev/rules.d/11-dm-lvm.rules
Reading rules file: /usr/lib/udev/rules.d/11-dm-mpath.rules
Reading rules file: /usr/lib/udev/rules.d/11-dm-parts.rules
Reading rules file: /usr/lib/udev/rules.d/13-dm-disk.rules
Reading rules file: /usr/lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /usr/lib/udev/rules.d/40-libgphoto2.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb-media-players.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /usr/lib/udev/rules.d/50-iscsi-firmware-login.rules
Reading rules file: /usr/lib/udev/rules.d/50-udev-default.rules
Reading rules file: /usr/lib/udev/rules.d/54-before-scsi-sg3_id.rules
Reading rules file: /usr/lib/udev/rules.d/55-Argyll.rules
Reading rules file: /etc/udev/rules.d/55-libsane.rules
Reading rules file: /usr/lib/udev/rules.d/55-scsi-sg3_id.rules
Reading rules file: /usr/lib/udev/rules.d/56-multipath.rules
Reading rules file: /etc/udev/rules.d/56-sane-backends-autoconfig.rules
Reading rules file: /usr/lib/udev/rules.d/58-scsi-sg3_symlink.rules
Reading rules file: /usr/lib/udev/rules.d/59-fc-wwpn-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-autosuspend.rules
Reading rules file: /usr/lib/udev/rules.d/60-block.rules
Reading rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /usr/lib/udev/rules.d/60-drm.rules
Reading rules file: /usr/lib/udev/rules.d/60-evdev.rules
Reading rules file: /usr/lib/udev/rules.d/60-fido-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-input-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-io-scheduler.rules
Reading rules file: /usr/lib/udev/rules.d/60-libpisock.rules
Reading rules file: /usr/lib/udev/rules.d/60-mdevctl.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /usr/lib/udev/rules.d/60-rdma-persistent-naming.rules
Reading rules file: /usr/lib/udev/rules.d/60-scdaemon.rules
Reading rules file: /usr/lib/udev/rules.d/60-sensor.rules
Reading rules file: /usr/lib/udev/rules.d/60-serial.rules
Reading rules file: /usr/lib/udev/rules.d/61-blueberry-rfkill.rules
Reading rules file: /usr/lib/udev/rules.d/61-kde-bluetooth-rfkill.rules
Reading rules file: /usr/lib/udev/rules.d/61-mate-settings-daemon-rfkill.rules
Reading rules file: /usr/lib/udev/rules.d/61-persistent-storage-compat.rules
Reading rules file: /usr/lib/udev/rules.d/63-md-raid-arrays.rules
Reading rules file: /usr/lib/udev/rules.d/64-btrfs-dm.rules
Reading rules file: /usr/lib/udev/rules.d/64-btrfs.rules
Reading rules file: /usr/lib/udev/rules.d/64-md-raid-assembly.rules
Reading rules file: /usr/lib/udev/rules.d/65-libwacom.rules
Reading rules file: /usr/lib/udev/rules.d/65-wacom.rules
Reading rules file: /usr/lib/udev/rules.d/66-kpartx.rules
Reading rules file: /usr/lib/udev/rules.d/68-del-part-nodes.rules
Reading rules file: /usr/lib/udev/rules.d/69-brltty.rules
Reading rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules
Reading rules file: /usr/lib/udev/rules.d/69-dm-lvm-metad.rules
Reading rules file: /usr/lib/udev/rules.d/69-libmtp.rules
Reading rules file: /usr/lib/udev/rules.d/69-md-clustered-confirm-device.rules
Reading rules file: /usr/lib/udev/rules.d/69-xorg-vmmouse.rules
Reading rules file: /usr/lib/udev/rules.d/70-fido2.rules
Reading rules file: /usr/lib/udev/rules.d/70-joystick.rules
Reading rules file: /usr/lib/udev/rules.d/70-mouse.rules
Reading rules file: /etc/udev/rules.d/70-persistent-ipoib.rules
Reading rules file: /etc/udev/rules.d/70-persistent-net.rules
Reading rules file: /usr/lib/udev/rules.d/70-power-switch.rules
Reading rules file: /usr/lib/udev/rules.d/70-printers.rules
Reading rules file: /usr/lib/udev/rules.d/70-touchpad.rules
Reading rules file: /usr/lib/udev/rules.d/70-uaccess.rules
Reading rules file: /usr/lib/udev/rules.d/71-seat.rules
Reading rules file: /usr/lib/udev/rules.d/73-seat-late.rules
Reading rules file: /usr/lib/udev/rules.d/75-net-description.rules
Reading rules file: /usr/lib/udev/rules.d/75-persistent-net-generator.rules
Reading rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /usr/lib/udev/rules.d/75-rdma-description.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-cinterion-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-dell-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-dlink-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-fibocom-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-haier-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-mtk-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-nokia-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-quectel-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-sierra.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-simtech-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-telit-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-tplink-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-ublox-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-usb-device-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-x22x-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-zte-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/78-sound-card.rules
Reading rules file: /usr/lib/udev/rules.d/80-acpi-container-hotplug.rules
Reading rules file: /usr/lib/udev/rules.d/80-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/80-hotplug-cpu-mem.rules
Reading rules file: /usr/lib/udev/rules.d/80-kvm.rules
Reading rules file: /usr/lib/udev/rules.d/80-libinput-device-groups.rules
Reading rules file: /usr/lib/udev/rules.d/80-mm-candidate.rules
Reading rules file: /usr/lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /usr/lib/udev/rules.d/80-udisks2.rules
Reading rules file: /usr/lib/udev/rules.d/84-nm-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/85-nm-unmanaged.rules
Reading rules file: /usr/lib/udev/rules.d/85-regulatory.rules
Reading rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /usr/lib/udev/rules.d/90-fwupd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/90-haveged.rules
Reading rules file: /usr/lib/udev/rules.d/90-issue-generator.rules
Reading rules file: /usr/lib/udev/rules.d/90-libinput-model-quirks.rules
Reading rules file: /usr/lib/udev/rules.d/90-nm-thunderbolt.rules
Reading rules file: /usr/lib/udev/rules.d/90-pulseaudio.rules
Reading rules file: /usr/lib/udev/rules.d/90-rdma-hw-modules.rules
Reading rules file: /usr/lib/udev/rules.d/90-rdma-ulp-modules.rules
Reading rules file: /usr/lib/udev/rules.d/90-rdma-umad.rules
Reading rules file: /usr/lib/udev/rules.d/90-vconsole.rules
Reading rules file: /usr/lib/udev/rules.d/91-trousers.rules
Reading rules file: /usr/lib/udev/rules.d/95-cd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/95-dm-notify.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-csr.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-hid.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-hidpp.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-wup.rules
Reading rules file: /usr/lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /usr/lib/udev/rules.d/98-rdma-sriov.rules
Reading rules file: /usr/lib/udev/rules.d/99-iwlwifi-led.rules
Reading rules file: /usr/lib/udev/rules.d/99-systemd.rules
Reading rules file: /usr/lib/udev/rules.d/99-wakeup-from-idle.rules
DEVPATH=/devices/pci0000:00/0000:00:1c.6/0000:04:00.0/usb4/4-1
DEVNAME=/dev/bus/usb/004/003
DEVTYPE=usb_device
DRIVER=usb
PRODUCT=12d1/14db/102
TYPE=2/0/0
BUSNUM=004
DEVNUM=003
MAJOR=189
MINOR=386
ACTION=add
SUBSYSTEM=usb
ID_VENDOR=HUAWEI_MOBILE
ID_VENDOR_ENC=HUAWEI_MOBILE
ID_VENDOR_ID=12d1
ID_MODEL=HUAWEI_MOBILE
ID_MODEL_ENC=HUAWEI_MOBILE
ID_MODEL_ID=14db
ID_REVISION=0102
ID_SERIAL=HUAWEI_MOBILE_HUAWEI_MOBILE
ID_BUS=usb
ID_USB_INTERFACES=:020600:0a0000:
ID_VENDOR_FROM_DATABASE=Huawei Technologies Co., Ltd.
ID_MODEL_FROM_DATABASE=E353/E3131
ID_PATH=pci-0000:04:00.0-usb-0:1
ID_PATH_TAG=pci-0000_04_00_0-usb-0_1
USEC_INITIALIZED=21143696
Unload module index
Unloaded link configuration context.
MAG-HP0:~ # 

/var/log/usb_modeswitch_4-1


MAG-HP0:~ # cat /var/log/usb_modeswitch_4-1

USB_ModeSwitch log from Thu Jul 21 11:09:35 CEST 2022

Use global config file: /etc/usb_modeswitch.conf
Raw parameters: --switch-mode 4-1:1.0
Use top device dir /sys/bus/usb/devices/4-1
Check class of first interface ...
 Interface 0 class is 02.

----------------
USB values from sysfs:
  manufacturer    HUAWEI_MOBILE
  product    HUAWEI_MOBILE
  serial    
----------------
bNumConfigurations is 1 - don't check for active configuration
Aargh! Config file missing for 12d1:14db! Exit

MAG-HP0:~ # 

…and I have no clue how to build the missing config file for usb_modeswitch :frowning:

It’s a HuaweiE3372

I presume all products are to be configures similarily (see comment at the link “I edited according to my Huawei E303”). Change values at Huawei E8372 Linux Configuration and Setup · GitHub according to your HuaweiE3372.

See also HOWTO: Receive SMS via 4G/LTE Huawei stick on Raspberry Pi 4 and forward them via Telegram · GitHub

usb_modeswitch primary configuration is for switching from virtual CD-ROM to modem mode. Your device is already in one of communication modes. My understanding is that 14db is HiLink (router mode) and 1506 is STICK (modem mode). Any reason you cannot use 14db?

Anyway, please, reboot with stick plugged in, unplug and plug back and provide full output of “journalctl -b” as root. Upload to https://susepaste.org

My understanding is that 14db is HiLink (router mode) and 1506 is STICK (modem mode). Any reason you cannot use 14db?

I’m using modem mode 155e providing /dev/ttyUSB0 - 2 for SMS traffic.
I cannot use 14db HiLink.

journalctl reboot log: SUSE Paste

journalctl unplug/plug USB: SUSE Paste

Thanks for your time.

Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: new high-speed USB device number 2 using xhci_hcd
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: New USB device found, idVendor=12d1, idProduct=1f01, bcdDevice= 1.02
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: Product: HUAWEI_MOBILE
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: Manufacturer: HUAWEI_MOBILE
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: SerialNumber: 0123456789ABCDEF
**Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: reset high-speed USB device number 2 using xhci_hcd
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: device firmware changed**
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: USB disconnect, device number 2
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: new high-speed USB device number 3 using xhci_hcd
Jul 22 11:20:00 MAG-HP0 kernel: usb 3-1: New USB device found, idVendor=12d1, idProduct=14db, bcdDevice= 1.02

This sounds very similar to E3372h-320 (update 2020 version of E3372) automatically switches itself into ethernet mode. Try adding suggested quirk, make sure to run mkinitrd after creating this file because usb-storage is loaded in initrd already.

journalctl unplug/plug USB: SUSE Paste

It is more or less the same, except this time usb_modeswitch is the first to run. As it is apparently race condition, it can explain why it happens during boot (modem has more time to initialize its firmware).

For testing you could also try to disable usb-storage completely (see the same thread).

Thanks to all for your helpful comments.

It finally turned out that by removing the usb device **CD-ROM ASUS **my issue is solved.
The USB stick is recognized as 12d1:1f01 and usb_modeswitch comes inot action and switches it to 12d1:155e.

As arvidjaar mentioned, it’s likely a race condition.

Thanks for your time!