Using usb_modeswitch to enable 4G usb modem

Hey,

for the last hours I’m trying to get a Huawei e3131 usb modem up and running on our container. We are using RPi3 as a hardware platform and running the resin/raspberrypi3-node base image.

With usb_modeswitch we were able to get the modem up and running on the RPi with a default Raspbian - no docker, no resinOS.

Back on our resin.io container, usb_modeswitch is working and showing the same results with lsusb. But the modem itself is not connecting to a cellular network. This is not happening on the default Raspbian.

I thing the problem is that the modem’s mode is not switched on the host OS itself or is now in an inconsistent state.

Is there a possibility to run the usb_modeswitch command on the host OS?

Cheers,

Matt

I know @shaunmulligan had a lot more experience with 4G modems. I think it’s easier on resinOS 2.x, which uses NetworkManager (as opposed to Connman on resinOS 1.x) To test it out, create an account on our beta site, http://dashboard.resinstaging.io, start a new application, download the latest Resin OS 2.0.0-beta.7 image. Now to add your cellular connection info you need to mount the resin-boot partition and add in a simple network configuration file in system-connection/ directory, for example system-connection/resin-cellular In the file drop in the following, changing the APN, password, etc for your GSM provider (this below is just on example for one particular provicer we’ve tested):

[connection]
id=giffgaff Mobile Broadband
uuid=3b8f359e-4df2-4997-99d8-04e15742d38f
type=gsm
autoconnect=true
permissions=
secondaries=

[gsm]
apn=giffgaff.com
number=*99#
password=password
username=giffgaff

[serial]
baud=115200

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore

The current docs on cellular modems unfortunately still link to an old blogpost and a repo (that actually used usb_modeswitch, etc), but should not use that anymore, as noted in the blogpost too. Would highly recommend the resinOS 2.x approach. It is still in beta, but should be coming soon to the production service.

Let us know if this helps!

Hi @matt and @imrehg .
I haven’t messed around with many modems that require the usb_modeswitch. However I know one or two of the other users in the gitter.im chat. Unfortunately I can’t find the reference for the conversation right now because it appears gitter.im is having major outages :angry: , but I will come back and update here when I finally am allowed to find it. Failing that, I will try find the users that had it working and ask them to comment here.

Looks like someone tried the Huawei E3531i-2 modem that uses modeswitch and it works, though no specific details in that chat. Let’s see if they have more info, asked them on chat. :thought_balloon:

Hi @imrehg @shaunmulligan thanks for your quick reply! Always a pleasure to ask the community here.

I tried several other Huawei sticks this night. They work on default Raspbian, but not in the docker container.

The behavior when the modem is used on a default Raspbian:

  • usb_modeswitch
  • Modem is switching mode to ppp
  • The indicator led is blinking blue and found a cellular network automatically
  • All working fine with sakis3g or wvdial or pppd

Behavior in the docker container:

  • usb_modeswitch
  • Modem is switching mode to ppp
  • Light is stuck in green blinking which indicates that there is no cellular network available
  • Wvdial or sakis3g connect the modem but there is no network found

When I switch mode in the docker container, I get some errors from usblib which could be the reason the modem is not reaching network connectivity.

I’ll keep up on that and report the state here.

Thanks for your help

Matt

1 Like

Thanks for keeping us informed of where you’re up to Matt.
We’ll continue our efforts to access prior community wisdom, and once the new week begins I’ll reach out to others on our team.

1 Like

From experience on my end, wvdial won’t work inside a container, this is because the container cannot access all ppp functions.

The best way to connect with a 3G/4G dialup based modem is to use ResinOS 2 together with a GSM configuration, here’s an example of working network configuration on my end:

[connection]
id=Soracom
type=gsm

[gsm]
apn=soracom.io
number=99**1#
password-flags=1

[ipv4]
dns-search=
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto

PS: ResinOS 2 automatically takes care of usb_modeswitch so no need to worry about it.
PS2: Otherwise, you can use a Huawei “HiLink” based modem which exposes a USB Ethernet interaface after usb_modeswitch > Which works in Resin OS 1 / containers

2 Likes

Ok, here we go again.

I managed to get the Huawei E3131 running with sakis3g and wvdial. The trick was to use usb_modeswitch with the following mode ID:

sudo usb_modeswitch -v 12d1 -p 14fe -V 12d1 -P 1506 -M “55534243123456780000000000000011060000000000000000000000000000”

The modem is now switched to:

Bus 001 Device 005: ID 12d1:1c05 Huawei Technologies Co., Ltd. E173s 3G broadband stick (modem on)

It is up and running for the last 24h hours without any problems.

@eblex I think for the future we will run the modem with your solutions and the brand new resinOS 2 with NetworkManager

Thank you all for your great help! If someone is in trouble to get his modem running, just ask me.

Cheers,

Matt

2 Likes

@matt That’s great, looking like a good solution

Could you post your Sakis3G install script and wvdial configuration?
Will be sure to try that out with other modems on Resin OS 1

Hey @eblex,

sorry for the late reply. I primary use sakis3g to start and stop the connection. Here are the configurations:

sudo ./sakis3g/sakis3g connect --sudo --console --pppd USBINTERFACE=“1” OTHER=“USBMODEM” USBMODEM=“12d1:1506” APN=“CUSTOM_APN” CUSTOM_APN=“m2m-net.sa.t-mobile” APN_USER=“0” APN_PASS=“0”

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800

[Dialer provider]
Phone = 99**1#
Stupid Mode = 1
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,“IP”,“m2m-net.sa.t-mobile”

As mentioned above, wvdial is working but sakis3g is a bit more handy to configure on new devices.

2 Likes

Hi folks,

I have been able to get a 4G USB Cellular Dongle from Verizon to work with resin 1.24 on rpi2. I am using this dongle (https://www.verizonwireless.com/internet-devices/verizon-mifi-4g-lte-global-usb-modem-u620l/). Verizon has a guide for how to connect on linux. I just followed it and it was up and running (https://www.verizonwireless.com/dam/support/pdf/user_guide/u620-linux-integration-guide-7-17-15.pdf). I was surprised that it worked.

i will try it with resinOS 2 and see if it still works.

Happy to help and join the resin community,
Sid

2 Likes

Got some news from our lab here:

We now use the Huawei HiLink mode to enable a constant connection via 3G/4G. We use the Huawei E3372 wich provides antenna outputs and 4G ability.

To set the modem to HiLink we use this usb_modeswitch command:

usb_modeswitch -v 0x12d1 -p 0x15ca -V 0x12d1 -P 0x14dc -M “55534243123456780000000000000011063000000100010000000000000000”

Hope this helps

Cheers,

Matt

2 Likes

did it work with resinOS 2?

2 Likes

Hi, sorry to reply to this old topic.

I am trying to connect with a E3531 Dongle, ID 12d1:155e, I have tried to run your command to set the modem to HiLink, but I get this error:

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 006 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 255
Error: can't use storage command in MessageContent with interface 0; interface class is 2, expected 8. Abort

and the device doesn’t change his Id nor it connects to internet, but it seems like it hangs:

ttyUSB0 gsm connecting (prepare) ttyUSB0

Any idea?

Thanks

Matteo

I guess the message content is not valid for this modem, try 55534243123456780000000000000011063000000100010000000000000000 ( found here https://askubuntu.com/questions/489936/huawei-e3531-view-signal-strength ).

I tried with this new message, but same result.

usb_modeswitch -W -v 0x12d1 -p 0x155e -V 0x12d1 -P 0x1506 -M "55534243123456780000000000000011063000000100010000000000000000"
Take all parameters from the command line
 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.5.0 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x155e
TargetVendor=   0x12d1
TargetProduct=  0x1506
MessageContent="55534243123456780000000000000011063000000100010000000000000000"

Look for target devices ...
  found USB ID 12d1:155e
   vendor ID matched
  found USB ID 0424:7800
  found USB ID 0424:2514
  found USB ID 0424:2514
  found USB ID 1d6b:0002
 No devices in target mode or class found
Look for default devices ...
  found USB ID 12d1:155e
   vendor ID matched
   product ID matched
  found USB ID 0424:7800
  found USB ID 0424:2514
  found USB ID 0424:2514
  found USB ID 1d6b:0002
 Found devices in default mode (1)
Access device 006 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 255
Error: can't use storage command in MessageContent with interface 0; interface class is 2, expected 8. Abort

But still the ModemManager sees the Usb as a modem:

mmcli -m 0
  -----------------------------
  General  |         dbus path: /org/freedesktop/ModemManager1/Modem/0
           |         device id: xxx
  -----------------------------
  Hardware |      manufacturer: huawei
           |             model: E3531
           | firmware revision: xxx
           |         supported: gsm-umts
           |           current: gsm-umts
           |      equipment id: xxx
  -----------------------------
  System   |            device: /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3
           |           drivers: cdc_ncm, option1
           |            plugin: Huawei
           |      primary port: ttyUSB0
           |             ports: ttyUSB0 (at), ttyUSB2 (at), wwan0 (net)
  -----------------------------
  Status   |    unlock retries: sim-pin (2), sim-pin2 (3), sim-puk (10), sim-puk2 (10)
           |             state: connecting
           |       power state: on
           |       access tech: umts
           |    signal quality: 19% (recent)
  -----------------------------
  Modes    |         supported: allowed: 2g, 3g; preferred: none
           |                    allowed: 2g, 3g; preferred: 2g
           |                    allowed: 2g, 3g; preferred: 3g
           |                    allowed: 2g; preferred: none
           |                    allowed: 3g; preferred: none
           |           current: allowed: 2g, 3g; preferred: none
  -----------------------------
  IP       |         supported: ipv4
  -----------------------------
  3GPP     |              imei: xxxxx
           |       operator id: 22288
           |     operator name: I WIND
           |      registration: home
  -----------------------------
  SIM      |         dbus path: /org/freedesktop/ModemManager1/SIM/0
  -----------------------------
  Bearer   |         dbus path: /org/freedesktop/ModemManager1/Bearer/2

Any suggestion?

Thanks again

Hi, I pinged an engineer from our devices team who has experience with this modem and usb_modeswitch and we will follow up as soon as we have more information on this.

1 Like

Hi, can you reboot and then run “lsusb -v” and paste the output here please?

Hi floion, here the output:

Bus 001 Device 008: ID 12d1:155e  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x12d1 
  idProduct          0x155e 
  bcdDevice            1.02
  iManufacturer           1 HUAWEI
  iProduct                2 HUAWEI Mobile
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x00bd
    bNumInterfaces          5
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      ** UNRECOGNIZED:  05 24 00 10 01
      ** UNRECOGNIZED:  04 24 02 02
      ** UNRECOGNIZED:  05 24 01 00 00
      ** UNRECOGNIZED:  05 24 06 00 00
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               5
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 
      bInterfaceSubClass    255 
      bInterfaceProtocol    255 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x03  EP 3 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 
      bFunctionSubClass      13 
      bFunctionProtocol       0 
      iFunction              11 HUAWEI Mobile
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 
      bInterfaceSubClass     13 
      bInterfaceProtocol      0 
      iInterface              8 CDC Network Control Model (NCM)
      CDC Header:
        bcdCDC               1.10
      CDC Union:
        bMasterInterface        3
        bSlaveInterface         4 
      CDC Ethernet:
        iMacAddress                     xxxx
        bmEthernetStatistics    0x0000000f
        wMaxSegmentSize               1514
        wNumberMCFilters            0x0003
        bNumberPowerFilters              1
      CDC NCM:
        bcdNcmVersion        1.00
        bmNetworkCapabilities 0x1f
          crc mode
          max datagram size
          encapsulated commands
          net address
          packet filter
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               9
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass        10 
      bInterfaceSubClass      0 
      bInterfaceProtocol      1 
      iInterface              9 CDC Network Data
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        4
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass        10 
      bInterfaceSubClass      0 
      bInterfaceProtocol      1 
      iInterface              9 CDC Network Data
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            2 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered

Thanks

So looking at your output it says “bNumConfigurations 1”. So there’s only the one config you are using now, nothing else to be switched to. Can you check maybe there is a firmware update for you modem that would allow multiple configs? Also, just as a double check, this is the output you got after reboot without you doing any manual modeswitch, correct? In which case in looks like the modem is already running under the 12d1:155e vid:pid combination.