Huawei USB Modem and Connman

I am trying to install a Huawei USB modem (MS2372h) on a Colibri iMX7D 1GB SOM and Colibri Evaluation Board (V3.2B). My preference is to have the modem managed by Connman and Ofono

I first attempted this by using the Toradex Easy Installer to install the Toradex provided image (2.7.4).

# uname -a
Linux colibri-imx7-emmc 4.1.44-2.7.4+gb1555bf #1 SMP Wed Oct 4 21:39:05 UTC 2017 armv7l GNU/Linux

The modem is recognised on insertion as a ttyUSBx device.

# dmesg
[ 3039.680825] usb 1-1.1: new high-speed USB device number 5 using ci_hdrc
[ 3039.868348] usbcore: registered new interface driver option
[ 3039.874160] usbserial: USB Serial support registered for GSM modem (1-port)
[ 3039.881689] option 1-1.1:1.0: GSM modem (1-port) converter detected
[ 3039.888373] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB0
[ 3039.895659] option 1-1.1:1.1: GSM modem (1-port) converter detected
[ 3039.902452] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
[ 3039.909561] option 1-1.1:1.2: GSM modem (1-port) converter detected
[ 3039.916265] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2

#lsusb
Bus 001 Device 005: ID 12d1:1596 Huawei Technologies Co., Ltd.    

I have used opkg to install ppp, ofono, and ofono-tests; however I have not been successful in finding the modem when I use the test scripts from Ofono.

The following yields nothing:

    # ofono -d
    # ./list-modems

So, I abandoned the ofono approach for now and have been trying to just get it working based on the following article https://www.toradex.com/pt-br/blog/how-to-use-gsm-3g-4g-in-embedded-linux-systems. Using the stock image (which I now doesn’t provide ppp or acm support), I was able to communicate with the modem, but obviously it didn’t work.

Here is my ppp log:

OK

CONNECT
Script chat -v -f /etc/ppp/chat/vodafone-3g.chat finished (pid 711), status = 0x0
Serial connection established.
using channel 5
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB0
sent [LCP ConfReq id=0x3 <asyncmap 0xa0000> <magic 0x1d415972> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x1 <accomp> <pcomp> <asyncmap 0x0> <mru 1500> <magic 0x547> <auth chap MD5>]
No auth is possible
sent [LCP ConfRej id=0x1 <auth chap MD5>]
rcvd [LCP ConfAck id=0x3 <asyncmap 0xa0000> <magic 0x1d415972> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x2 <accomp> <pcomp> <asyncmap 0x0> <mru 1500> <magic 0x547>]
sent [LCP ConfAck id=0x2 <accomp> <pcomp> <asyncmap 0x0> <mru 1500> <magic 0x547>]
sent [LCP EchoReq id=0x0 magic=0x1d415972]
kernel does not support PPP filtering
sent [CCP ConfReq id=0x3 <deflate 15> <deflate(old#) 15>]
sent [IPCP ConfReq id=0x8 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [LCP EchoRep id=0x0 magic=0x547]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfNak id=0x1 <addr 0.0.0.0>]
rcvd [LCP ProtRej id=0x3 80 fd 01 03 00 0c 1a 04 78 00 18 04 78 00]
Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
rcvd [IPCP ConfNak id=0x8]
sent [IPCP ConfReq id=0x9 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
rcvd [IPCP ConfReq id=0x2]
sent [IPCP ConfAck id=0x2]
rcvd [LCP TermReq id=0x3]
LCP terminated by peer
sent [LCP TermAck id=0x3]
rcvd [IPCP TermReq id=0x3]
Discarded non-LCP packet when LCP not open
Hangup (SIGHUP)
Modem hangup
Connection terminated.

So, obviously, the stock image I installed does not support ppp filtering. I did the test above because if I compile the kernel myself and enable PPP and USB ACM options as indicated in the article above, then I am unable to see the modem mount as a ttyUSBx or ttyACMx device.

With my custom kernel, I get:

# dmesg
[   83.411050] usb 1-1.1: new high-speed USB device number 5 using ci_hdrc

# lsusb
Bus 001 Device 005: ID 12d1:1596 Huawei Technologies Co., Ltd.

# ls /dev/tty*
/dev/tty      /dev/tty19    /dev/tty3     /dev/tty40    /dev/tty51    /dev/tty62
/dev/tty0     /dev/tty2     /dev/tty30    /dev/tty41    /dev/tty52    /dev/tty63
/dev/tty1     /dev/tty20    /dev/tty31    /dev/tty42    /dev/tty53    /dev/tty7
/dev/tty10    /dev/tty21    /dev/tty32    /dev/tty43    /dev/tty54    /dev/tty8
/dev/tty11    /dev/tty22    /dev/tty33    /dev/tty44    /dev/tty55    /dev/tty9
/dev/tty12    /dev/tty23    /dev/tty34    /dev/tty45    /dev/tty56    /dev/ttymxc0
/dev/tty13    /dev/tty24    /dev/tty35    /dev/tty46    /dev/tty57    /dev/ttymxc1
/dev/tty14    /dev/tty25    /dev/tty36    /dev/tty47    /dev/tty58    /dev/ttymxc2
/dev/tty15    /dev/tty26    /dev/tty37    /dev/tty48    /dev/tty59
/dev/tty16    /dev/tty27    /dev/tty38    /dev/tty49    /dev/tty6
/dev/tty17    /dev/tty28    /dev/tty39    /dev/tty5     /dev/tty60
/dev/tty18    /dev/tty29    /dev/tty4     /dev/tty50    /dev/tty61

I’m building my kernel using the following steps:

//get latest kernel source
# git clone -b toradex_4.1-2.0.x-imx git://git.toradex.com/linux-toradex.git

//get toolchain
#cd
#wget -c https://releases.linaro.org/components/toolchain/binaries/6.2-2016.11/arm-linux-gnueabihf/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz
# tar xvf gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz
# ln -s gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf gcc-linaro

/set paths for cross-compile
# export ARCH=arm
# export PATH=~/gcc-linaro/bin:$PATH
# export CROSS_COMPILE=arm-linux-gnueabihf-

//get image files
# cd
# wget http://files.toradex.com/Colibri/Linux/Images/Colibri-iMX7_LXDE-Image_2.7-20180104.tar.bz2 
# sudo tar xjvf Colibri-iMX7_LXDE-Image_2.7-20180104.tar.bz2 

// install device tree compiler
# sudo apt-get install device-tree-compiler
# dtc -v

//make and compile kernel
# cd linux-toradex
# make colibri_imx7_defconfig

***********enable ppp and acm options in kernel config******************

# make -j3 zImage 2>&1 | tee build.log
# make imx7d-colibri-emmc-eval-v3.dtb
# make -j3 modules

//copy zImage and imx7d-colibri-emmc-eval-v3.dtb) to the Easy Installer bootfs
//compress and export kernel modules

//Run Easy Install, install custom image
//copy kernel modules to rootfs, extract, and then run depmod and reboot

I’ve reached a point of not really knowing what to try next and could really need some guidance.
Does anyone have any suggestions to help me get this modem installed? I am a Linux novice, so if I haven’t provide enough information, then please let me know and I’ll post more detailed logs if required.

It really should work at this point. For some reason your new kernel seems not to pick up the kernel modules.

Can you check with lsmod whether any modules got loaded?

The kernel modules should be stored in a directory in /lib/modules. The directory need to be named exactly the same as the kernel you are using:

root@colibri-imx7-emmc:~# uname -r
4.1.44-2.7.4+gb1555bf
root@colibri-imx7-emmc:~# ls /lib/modules/
4.1.44-2.7.4+gb1555bf

Hi Stefan,
You were 100% correct. I was not properly loaded the custom kernel modules. I have corrected this.

root@colibri-imx7-emmc:~# uname -r
4.1.44-00003-ge08513e
root@colibri-imx7-emmc:~# ls /lib/modules/
4.1.44-00003-ge08513e

Now, with my custom kernel, when I plug in I see:

root@colibri-imx7-emmc:~# dmesg

[60303.851479] usb 1-1.1: new high-speed USB device number 10 using ci_hdrc
[60303.985435] option 1-1.1:1.0: GSM modem (1-port) converter detected
[60303.992322] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB0
[60304.000025] option 1-1.1:1.1: GSM modem (1-port) converter detected
[60304.009757] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
[60304.018298] option 1-1.1:1.2: GSM modem (1-port) converter detected
[60304.025957] usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2

root@colibri-imx7-emmc:~# ls /dev/ttyU*
/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2

Unfortunately, ofono still does not see the modem when I attempt to use the test scripts (./list-modems) returns nothing.

Can you assist in next steps to see why ofono does not recognize the modem?

Hi @mikec

Maybe oFono doesn’t support this specific modem? Can you upload what the following command outputs?

killall ofonod
ofonod -dn

Does it recognize the modem somewhere in the log?

Regards,
Stefan

Hi @stefan.tx

It appears to recognise the modem as a huawei. As an aside, I have been successful in using ppp and chat scripts to get the modem to connect to the internet; however, for my application, Connman and Ofono are preferred to manage multiple ways to establish internet.

Here is the output from the commands:
log

Hi @mikec

Unfortunately it really looks like that oFono doesn’t support your Modem. If you know which the modem port is you can force it by setting a udev rule. Something like (Choose the correct ID_USB_INTERFACE_NUM):
ACTION!=“add|change”, GOTO=“ofono_speedup_end”

SUBSYSTEM!="tty", GOTO="ofono_speedup_end"
KERNEL!="ttyUSB[0-9]*", GOTO="ofono_speedup_end"

# Force the modem port to be recognized as modem
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1596", ENV{ID_USB_INTERFACE_NUM}=="01", ENV{OFONO_LABEL}="modem" 
LABEL="ofono_speedup_end"

But there is no guarantee that it will work afterwards, maybe the modem uses an incompatible AT command set.

If you really need to use this modem, you may also check if you can put your modem into another mode (e.g. qmi/mbim) with usb_modeswitch ( http://www.draisberghof.de/usb_modeswitch/#download). Unfortunately this is out of Toradexes scope.

Regards,
Stefan

Hi @stefan_e.tx,

Unfortunately, this isn’t great news, but I appreciate your response and support. I’ll investigate the udev solution and post back if I am successful. I may ultimately have to choose a different modem.

Mike

Yeah, provide us feedback once you tried the solution with udev since this will help also the other users.

@jaski.tx , @stefan.tx

Ok, so I tried the above suggestion, but am not seeing any different behaviour. Perhaps I’m not doing something correctly. I have not used udev before.

To determine my interface number, I did:

root@colibri-imx7-emmc:~# udevadm info -a -n /dev/ttyUSB0 | grep -i interface
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceProtocol}=="31"
    ATTRS{bInterfaceSubClass}=="03"
    ATTRS{bNumInterfaces}==" 4"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bNumInterfaces}==" 1"

So it appears that my interface is 00. I then created a rule in /etc/udev/rules.d, which is:

root@colibri-imx7-emmc:~# cat /etc/udev/rules.d/88-imx-usbcellular.rules
ACTION!="add|change", GOTO="ofono_speedup_end"

SUBSYSTEM!="tty", GOTO="ofono_speedup_end"
KERNEL!="ttyUSB[0-9]*", GOTO="ofono_speedup_end"

# SpeedUp Huawei 2372
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1596", ENV{ID_USB_INTERFACE_NUM}=="00", ENV{OFONO_LABEL}="modem"

LABEL="ofono_speedup_end"

I am running the ofono daemon and then inserting the modem, but I don’t see any entries in dmesg or journalctl that lead me to believe that something is happening.

Could you share the complete dmesg log in a text file? Thanks.

@jaski.tx

Here are the log files.

link text

hi @mikec

Thanks for the log. Unfortunately it is difficult to help you without having the hardware. You should ask the modem supplier how to use and test with linux or try to get a different modem.

@mikec , you may have a try with usb-modeswitch. Build BSP from OpenEmbedded with usb-modeswitch and config files. Add IMAGE_INSTALL_append = " usb-modeswitch usb-modeswitch-data" to local.conf.
Flash new BSP to your module. When plugin modem, you can find it in mass storage mode.

root@colibri-imx6:~# lsusb
Bus 001 Device 004: ID 12d1:1f01 Huawei Technologies Co., Ltd. E353/E3131 (Mass storage mode)
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Find the config file by VID and PID under /usr/share/usb_modeswitch/

root@colibri-imx6:~# cat /usr/share/usb_modeswitch/12d1:1f01                                                                                          
# Huawei E353 (3.se) and others
DefaultVendor=0x12d1
DefaultProduct=0x1f01
TargetVendor=0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NoDriverLoading=1

you may add DefaultVendor and DefaultProduct to it. Then use usb-modeswitch to enable it. Now check it with lsusb, this device is not in mass storage mode any more and another network interface is added.

root@colibri-imx6:~# usb_modeswitch -c /usr/share/usb_modeswitch/12d1\:1f01



root@colibri-imx6:~# lsusb
Bus 001 Device 004: ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@colibri-imx6:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:14:2D:4E:5A:00  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:2585 errors:0 dropped:6 overruns:0 frame:0
          TX packets:137 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:515217 (503.1 KiB)  TX bytes:19051 (18.6 KiB)

eth1      Link encap:Ethernet  HWaddr 58:2C:80:13:92:63  
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::5a2c:80ff:fe13:9263%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6234 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3624 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8765020 (8.3 MiB)  TX bytes:232424 (226.9 KiB)

Hi @benjamin.tx,

Thanks for the suggestion. I actually already had mode_switch as part of the Yocto build. The vid:pid of my modem is 12d1:1596, for which there was no config file in /usr/share/usb_modeswitch. I created one; however, I do not now if the Target pid I’m using is correct.

root@colibri-imx7-emmc:~# cat /usr/share/usb_modeswitch/12d1:\1596
# Huawei MS2372
DefaultVendor=0x12d1
DefaultProduct=0x1596
TargetVendor=0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NoDriverLoading=1

Running usb_modeswitch yields:

root@colibri-imx7-emmc:~# lsusb
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 003: ID 045e:0750 Microsoft Corp. Wired Keyboard 600
Bus 001 Device 005: ID 12d1:1596 Huawei Technologies Co., Ltd.
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@colibri-imx7-emmc:~# usb_modeswitch -c /usr/share/usb_modeswitch/12d1\:1596
Look for target devices ...[   28.556676] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0

 No devices in target mode or c[   28.567643] option 1-1.1:1.0: device disconnected
lass found
Look for default devices ...
   product ID matched
 Found devices in default mode (1)
Access device 005 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI_MOBILE
     Product: HUAWEI_MOBILE
  Serial No.: not provided
-------------------------
Using standard Huawei switching message
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Reset response endpoint 0x81
Reset message endpoint 0x01
-> Run lsusb to note any changes. Bye!

root@colibri-imx7-emmc:~# lsusb
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 003: ID 045e:0750 Microsoft Corp. Wired Keyboard 600
Bus 001 Device 005: ID 12d1:1596 Huawei Technologies Co., Ltd.
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

root@colibri-imx7-emmc:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:14:2D:2D:BC:4A
          inet addr:10.128.203.141  Bcast:10.128.207.255  Mask:255.255.248.0
          inet6 addr: fe80::214:2dff:fe2d:bc4a%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3498 errors:0 dropped:66 overruns:0 frame:0
          TX packets:116 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:321431 (313.8 KiB)  TX bytes:14228 (13.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:191 errors:0 dropped:0 overruns:0 frame:0
          TX packets:191 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:14797 (14.4 KiB)  TX bytes:14797 (14.4 KiB)

usb0      Link encap:Ethernet  HWaddr 00:14:2D:FF:FF:FF
          inet addr:192.168.11.1  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::214:2dff:feff:ffff%lo/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:81 errors:0 dropped:0 overruns:0 frame:0
          TX packets:87 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7462 (7.2 KiB)  TX bytes:21053 (20.5 KiB)

Only difference I see now is that /dev/ttyUSB0 has detached.

TargetProductList="14db,14dc" is for E353/E3131 modem device, I am afraid it is may not be right for your MS2372h. After searching from usb.ids, I can’t find entry of 12d1:1596 within Huawei products. You can cherry-pick one from above usb.ids and have a try, e.g. 15bb or 15c1 for 4G LTE modem. Ubuntu’s NetworkManager has good support of modem. You can plugin MS2372h into a Unbuntu PC and check what is the VID when wireless connection via modem is ready. Then copy this VID to TargetProduct or TargetProductList.

Hi @mikec

One other idea, could it be that not all drivers are available? Can you once post the output of:

lsusb -t

Can you see a driver registered for each USB endpoint of the modem? Maybe the cdc_ether driver is missing? If I remember correctly Huawei often uses this driver for data connections.

Regards,
Stefan

Hi @benjamin.tx ,

I tried 15bb and 15c1 as the target. No difference.

Plugging the modem into Ubuntu and establishing a ppp0 connection works; however, the vid does not change. It remains at 1596.

Hi @stefan_e.tx ,

Here is the output:

root@colibri-imx7-emmc:~# lsusb
Bus 001 Device 004: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 001 Device 003: ID 045e:0750 Microsoft Corp. Wired Keyboard 600
Bus 001 Device 009: ID 12d1:1596 Huawei Technologies Co., Ltd.
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

root@colibri-imx7-emmc:~# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ci_hdrc/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 9, If 0, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 1: Dev 9, If 1, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 1: Dev 9, If 2, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 1: Dev 9, If 3, Class=Vendor Specific Class, Driver=, 480M
        |__ Port 3: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 3: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
        |__ Port 4: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

@stefan_e.tx

Regarding the cdc_ether driver, in my kernel build, the USB_NET_CDCETHER symbol is set to m.

Hi @mikec

Maybe this 4th interface would be the key, it is hard to say… Can you check if you have enabled CONFIG_USB_NET_HUAWEI_CDC_NCM, CONFIG_USB_NET_CDC_MBIM and CONFIG_USB_ETH_RNDIS?

Without the modem available it could be nearly everything…

Regards,
Stefan