Erroneous behavior with 4g dongle

I got an installation of Openwrt 19.07.07 in an Alix 2d13 (Pcengines) and it has a 4G usb dongle on it. The board has 2 physical usb ports and the dongle is recognised on different port on every reboot (ttyUSB0 or 1). The dongle is a Huawei 3372 (Not Hilink). How do i fixe that?
dmesq when attaching the device

root@OpenWrt_alix: ~ $ dmesg
[  118.340228] usb 1-1: USB disconnect, device number 3
[  118.345846] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0
[  118.354153] option 1-1:1.0: device disconnected
[  118.374588] option1 ttyUSB1: GSM modem (1-port) converter now disconnected from ttyUSB1
[  118.382764] option 1-1:1.1: device disconnected
[  118.387796] huawei_cdc_ncm 1-1:1.2 wwan0: unregister 'huawei_cdc_ncm' usb-0000:00:0f.5-1, Huawei CDC NCM device
root@OpenWrt_alix: ~ $

lsusb

root@OpenWrt_alix: ~ $ lsusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@OpenWrt_alix: ~ $

The network config that i have for the dongle in /etc/config/network

config interface '4G_Q'
        option proto 'ncm'
        option ipv6 'auto'
        option apn 'myq'
        option delay '5'
        option pdptype 'IP'
        option dialnumber '*99#'
        option service 'preferlte'
        option device '/dev/cdc-wdm0'

some times it works under /dev/cdc-wdm0, while others with /dev/ttyUSB0 or /dev/ttyUSB1

Different kind of device, but should be the same Persistent usb device name
Assigning device nodes and interface names on hotplug

1 Like

FYI I wrote a Rust program (you could do the same in any language, but if you need good error handling I'd recommend Rust or Python) to do this. The coldplug section was extremely useful, and all I did in my program was

  • detect what's happening using the env vars ACTION (bind or remove), PRODUCT, DEVPATH, and DEVICENAME
  • break up the path to figure out the USB ids
  • if the USB ids match the product you're interested in, make a symlink that's got a sensible name eg. /dev/mymodem -> /dev/cdc-wdm0.

Now you can use that symlink in your /etc/config/network config.

@detly thanks for the reply. I am trying to understand the script you mentioned, but i am not a programmer.
The solution i am trying to find is that my 2 usb devices on reboot some times change the ttyUSB0 & 1 between them. I would like to make the A usb device be permanently ttyUSB0 and B usb device be ttyUSB1, respectively.
i have 2 installations where in one router i got 2 usb modems while on the other router i got a sub modem and a usb camera. Both of the routers have the same issue to get the ttyUSB0 & 1 changed between the devices when rebooted (or power failure).