Author Message

<  Setup Discussion  ~  Huawei K5160 doesn't create an interface after mode switch

PostPosted: Tue May 16, 2017 4:24 pm Reply with quote
Posts: 2 Joined: Mon May 15, 2017 11:24 pm
Hi all!

I could really use some help from the experts here, I have been working with a Huawei K5160 (first time using a Huawei modem) with CentOS7. I have been reading through the forums here regarding this modem and I am running into an issue that I haven't seen discussed. Perhaps my expectations are misplaced.

I am trying to put the K5160 into cdc_mbim mode so my software can interact with the modem. When I have the cdc_mbim kernel modules running the mode switch appears to work fine but no interface is created in linux. I am expecting to see a new interface available for use after the mode switch. Is this correct?

When I remove the cdc_mbim module it properly puts the modem into cdc_ether and an interface is created as expected. This setup however won't work for me as I need to speak to the modem in mbim. Below is the dmesg, lsusb, and mode switch info. I would greatly appreciate any help or guidance!

dmesg:

[ 0.914938] usbcore: registered new interface driver usbfs
[ 0.921115] usbcore: registered new interface driver hub
[ 0.927147] usbcore: registered new device driver usb
[ 2.697949] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 2.705554] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 2.713640] usb usb1: Product: EHCI Host Controller
[ 2.719103] usb usb1: Manufacturer: Linux 3.19.2-ovn-rev2 ehci_hcd
[ 2.726021] usb usb1: SerialNumber: 0000:00:16.0
[ 2.760326] usbcore: registered new interface driver usbserial
[ 2.766886] usbcore: registered new interface driver usbserial_generic
[ 2.774217] usbserial: USB Serial support registered for generic
[ 3.873245] usbcore: registered new interface driver usbhid
[ 3.879488] usbhid: USB HID core driver
[ 4.040434] usb 1-1: new high-speed USB device number 2 using ehci-pci
[ 4.154772] usb 1-1: New USB device found, idVendor=8087, idProduct=07db
[ 4.162283] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 4.460496] usb 1-1.1: new full-speed USB device number 3 using ehci-pci
[ 4.557788] usb 1-1.1: New USB device found, idVendor=067b, idProduct=2303
[ 4.565510] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4.573722] usb 1-1.1: Product: USB-Serial Controller D
[ 4.579593] usb 1-1.1: Manufacturer: Prolific Technology Inc.
[ 4.659531] usb 1-1.2: new high-speed USB device number 4 using ehci-pci
[ 4.755015] usb 1-1.2: New USB device found, idVendor=12d1, idProduct=1f1e
[ 4.762728] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4.770936] usb 1-1.2: Product: Vodafone (Huawei)
[ 4.776226] usb 1-1.2: Manufacturer: Vodafone (Huawei)
[ 4.782000] usb 1-1.2: SerialNumber: 0123456789ABCDEF
[ 4.872908] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[ 4.880681] scsi host0: usb-storage 1-1.2:1.0
[ 4.919588] usbcore: registered new interface driver usb-storage
[ 10.847566] usbcore: registered new interface driver cdc_wdm
[ 10.950506] usbcore: registered new interface driver cdc_ncm
[ 10.979349] usbcore: registered new interface driver cdc_mbim
[ 11.509968] usbcore: registered new interface driver pl2303
[ 11.510005] usbserial: USB Serial support registered for pl2303
[ 11.528995] usb 1-1.1: pl2303 converter now attached to ttyUSB0
[ 1091.690391] usbcore: registered new interface driver option
[ 1091.691672] usbserial: USB Serial support registered for GSM modem (1-port)

lsusb:
Code:
Bus 001 Device 004: ID 12d1:1f1e Huawei Technologies Co., Ltd.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol       255
  bMaxPacketSize0        64
  idVendor           0x12d1 Huawei Technologies Co., Ltd.
  idProduct          0x1f1e
  bcdDevice            1.02
  iManufacturer           1 Vodafone (Huawei)
  iProduct                2 Vodafone (Huawei)
  iSerial                 3 0123456789ABCDEF
  bNumConfigurations      2
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              4 Mass Storage
      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               1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          118
    bNumInterfaces          3
    bConfigurationValue     2
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower                2mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass      14
      bFunctionProtocol       0
      iFunction               8 K5160
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         2 Communications
      bInterfaceSubClass     14
      bInterfaceProtocol      0
      iInterface              5 NCM Network Control Model
      CDC Header:
        bcdCDC               1.10
      CDC MBIM:
        bcdMBIMVersion       1.00
        wMaxControlMessage   1024
        bNumberFilters       32
        bMaxFilterSize       128
        wMaxSegmentSize      1500
        bmNetworkCapabilities 0x20
          8-byte ntb input size
      UNRECOGNIZED CDC:  08 24 1c 00 01 10 dc 05
      CDC Union:
        bMasterInterface        0
        bSlaveInterface         1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               5
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      2
      iInterface              6 CDC Network Data
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass        10 CDC Data
      bInterfaceSubClass      0 Unused
      bInterfaceProtocol      2
      iInterface              6 CDC Network Data
      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        2
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk-Only
      iInterface              4 Mass Storage
      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               1
Binary Object Store Descriptor:
  bLength                 5
  bDescriptorType        15
  wTotalLength           22
  bNumDeviceCaps          2
  USB 2.0 Extension Device Capability:
    bLength                 7
    bDescriptorType        16
    bDevCapabilityType      2
    bmAttributes   0x00000002
      Link Power Management (LPM) Supported
  SuperSpeed USB Device Capability:
    bLength                10
    bDescriptorType        16
    bDevCapabilityType      3
    bmAttributes         0x00
    wSpeedsSupported   0x000f
      Device can operate at Low Speed (1Mbps)
      Device can operate at Full Speed (12Mbps)
      Device can operate at High Speed (480Mbps)
      Device can operate at SuperSpeed (5Gbps)
    bFunctionalitySupport   1
      Lowest fully-functional device speed is Full Speed (12Mbps)
    bU1DevExitLat           1 micro seconds
    bU2DevExitLat         500 micro seconds
Device Status:     0x0001
  Self Powered


modeswitch:

usb_modeswitch -I -W -v 12d1 -p 1f1e -J

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= 0x1f1e
HuaweiNewMode=1

Look for default devices ...
found USB ID 12d1:1f1e
vendor ID matched
product ID matched
found USB ID 067b:2303
found USB ID 8087:07db
found USB ID 1d6b:0002
Found devices in default mode (1)
Access device 004 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
with class 8
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Vodafone (Huawei)
Product: Vodafone (Huawei)
Serial No.: 0123456789ABCDEF
-------------------------
Using standard Huawei switching message
Looking for active driver ...
No active driver found. Detached before or never attached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
Read the response to message 1 (CSW) ...
Response successfully read (13 bytes), status 0
Reset response endpoint 0x81
Reset message endpoint 0x01
-> Run lsusb to note any changes. Bye!


Thanks!

-Adam


Offline
PostPosted: Tue May 16, 2017 5:27 pm Reply with quote
Posts: 1166 Joined: Wed Jul 11, 2012 3:14 pm Location: Koh Samui, TH
Your dmesg should show the mbim interface being taken by the cdc_mbim driver when that driver is available in the kernel and show a wwan0 device being created.

Example from another user:

Code:
Feb 16 22:57:00 arch kernel: usb 3-2: new high-speed USB device number 4 using xhci_hcd
Feb 16 22:57:00 arch kernel: usb-storage 3-2:1.0: USB Mass Storage device detected
Feb 16 22:57:00 arch kernel: scsi host8: usb-storage 3-2:1.0
Feb 16 22:57:01 arch usb_modeswitch[7314]: switch device 12d1:1f1e on 003/004
Feb 16 22:57:02 arch kernel: usb-storage 3-2:2.2: USB Mass Storage device detected
Feb 16 22:57:02 arch kernel: scsi host9: usb-storage 3-2:2.2
Feb 16 22:57:02 arch kernel: usbcore: registered new interface driver cdc_ncm
Feb 16 22:57:02 arch kernel: usbcore: registered new interface driver cdc_wdm
Feb 16 22:57:03 arch kernel: cdc_mbim 3-2:2.0: setting rx_max = 16384
Feb 16 22:57:03 arch kernel: cdc_mbim 3-2:2.0: cdc-wdm0: USB WDM device
Feb 16 22:57:03 arch kernel: cdc_mbim 3-2:2.0 wwan0: register 'cdc_mbim' at usb-0000:00:14.0-2, CDC MBIM, a6:04:ed:7c:56:f1
Feb 16 22:57:03 arch kernel: usbcore: registered new interface driver cdc_mbim
Feb 16 22:57:03 arch kernel: cdc_mbim 3-2:2.0 wwp0s20u2c2: renamed from wwan0


Offline
PostPosted: Tue May 16, 2017 6:42 pm Reply with quote
Posts: 2 Joined: Mon May 15, 2017 11:24 pm
Thank you for the reply!

That does seem to be the issue, despite having the cdc_mbim kernel module loaded it doesn't seem to take over after the switch.

Code:
lsmod | grep cdc_mbim
cdc_mbim               13400  0
cdc_ncm                30903  1 cdc_mbim
cdc_wdm                23109  1 cdc_mbim
usbnet                 43863  2 cdc_mbim,cdc_ncm


I have tried running the usb_modeswitch manually after verifying the usb modem is plugged and the mbim module is loaded, the switch message looks to be sent with no issue but then mbim doesn't do anything. I must be fundamentally missing something.


Offline
PostPosted: Tue May 16, 2017 8:36 pm Reply with quote
Site Admin Posts: 6420 Joined: Sat Nov 03, 2007 12:30 am
Please post the full log of usb_modeswitch (enable in /etc/usb_modeswitch.conf) after plugging the modem with the MBIM driver present - just the automatic process with no manual interference.


Offline
PostPosted: Fri Jun 16, 2017 7:17 pm Reply with quote
Posts: 6 Joined: Fri Jun 16, 2017 7:10 pm
I appear to have a similar problem, the switch fails when attempting automatically and then is ok when I run it from the command line on boot (running it in raspbian).


USB_ModeSwitch log from Sat Jun 10 11:35:03 BST 2017

Use global config file: /etc/usb_modeswitch.conf

Started via systemd
Adjust delay for USB storage devices ...
Delay set to 4 seconds

Raw args from udev: /1/1.4:1.0

Use top device dir /sys/bus/usb/devices/1-1.4

----------------
USB values from sysfs:
manufacturer Vodafone (Huawei)
product Vodafone (Huawei)
serial 0123456789ABCDEF
----------------
Found packed config collection /usr/share/usb_modeswitch/configPack.tar.gz
ConfigList: pack/12d1:1f1e pack/12d1:#linux
SCSI attributes not needed, move on
Check config: pack/12d1:1f1e
! matched. Read config data
Extract config 12d1:1f1e from collection /usr/share/usb_modeswitch/configPack.tar.gz
config: TargetVendor set to 12d1
config: TargetProductList set to 157f,1592
Driver module is "option", ID path is /sys/bus/usb-serial/drivers/option1

Device may have an MBIM configuration, check driver ...
driver for MBIM devices is available
Find MBIM configuration number ...
Command to be run:
usb_modeswitch -W -D -s 20 -b 1 -g 4 -v 12d1 -p 1f1e -f $configBuffer


Offline
PostPosted: Sat Jun 17, 2017 6:56 am Reply with quote
Posts: 1166 Joined: Wed Jul 11, 2012 3:14 pm Location: Koh Samui, TH
Jherries wrote:
I appear to have a similar problem, the switch fails when attempting automatically and then is ok when I run it from the command line on boot (running it in raspbian).



As a starter upgrade to latest usb_modeswitch ver.2.5


Offline
PostPosted: Sat Jun 17, 2017 7:01 pm Reply with quote
Posts: 6 Joined: Fri Jun 16, 2017 7:10 pm
LOM wrote:
Jherries wrote:
I appear to have a similar problem, the switch fails when attempting automatically and then is ok when I run it from the command line on boot (running it in raspbian).



As a starter upgrade to latest usb_modeswitch ver.2.5


I am, just checked and have the lastest version of the -data package. What information will help diagnose the issue?


Offline
PostPosted: Sat Jun 17, 2017 7:13 pm Reply with quote
Posts: 6 Joined: Fri Jun 16, 2017 7:10 pm
Syslog start up:

Code:
Jun 16 18:25:57 raspberrypi systemd[1]: Starting USB_ModeSwitch_1-1.4...
Jun 16 18:25:57 raspberrypi systemd[1180]: Failed at step EXEC spawning /usr/sbin/usb_modeswitch_dispatcher: No such file or directory
Jun 16 18:25:57 raspberrypi systemd[1]: usb_modeswitch@1-1.4.service: main process exited, code=exited, status=203/EXEC
Jun 16 18:25:57 raspberrypi systemd[1]: Failed to start USB_ModeSwitch_1-1.4.
Jun 16 18:25:57 raspberrypi systemd[1]: Unit usb_modeswitch@1-1.4.service entered failed state.
Jun 16 18:25:57 raspberrypi systemd[1]: Starting USB_ModeSwitch_1-1.4:1.0...
Jun 16 18:25:57 raspberrypi systemd[1190]: Failed at step EXEC spawning /usr/sbin/usb_modeswitch_dispatcher: No such file or directory
Jun 16 18:25:57 raspberrypi systemd[1]: usb_modeswitch@1-1.4:1.0.service: main process exited, code=exited, status=203/EXEC
Jun 16 18:25:57 raspberrypi systemd[1]: Failed to start USB_ModeSwitch_1-1.4:1.0.
Jun 16 18:25:57 raspberrypi systemd[1]: Unit usb_modeswitch@1-1.4:1.0.service entered failed state.


Offline
PostPosted: Sun Jun 18, 2017 12:10 pm Reply with quote
Posts: 6 Joined: Fri Jun 16, 2017 7:10 pm
I wonder, as raspbian doesnt create a root account automatically (it creates a "pi" user), would the start up process be attempting to run as root?

Jon


Offline
PostPosted: Tue Jun 20, 2017 12:37 pm Reply with quote
Site Admin Posts: 6420 Joined: Sat Nov 03, 2007 12:30 am
Have you checked if the file "/usr/sbin/usb_modeswitch_dispatcher" exists and has the right permissions set?


Offline
PostPosted: Wed Jun 21, 2017 12:03 pm Reply with quote
Posts: 6 Joined: Fri Jun 16, 2017 7:10 pm
Josh wrote:
Have you checked if the file "/usr/sbin/usb_modeswitch_dispatcher" exists and has the right permissions set?


Ok, so the file exists, the permissions I overrode to be for the "pi" user which didn't help.
I then noticed the gui was showing the file as a text document rather than a script or executable...

So I opened the file and the shebang in the file pointed to tclsh. This didnt exist as a default package in my Raspbian install so the interpreter couldn't be called...

Added this package via apt and voila we have automatic switching...

Hope this helps others,

Jon


Offline
PostPosted: Wed Jun 21, 2017 4:47 pm Reply with quote
Site Admin Posts: 6420 Joined: Sat Nov 03, 2007 12:30 am
Hmm, if you're using usb_modeswitch as a Raspbian package, it should depend on "tcl".

If you installed from source, there is an important bit in the README file, in the chapter "How to install":
Code:
1. If you have the "Tcl" scripting language available on your system (packages
   "tcl" or "jimsh"), use the light-weight installation:

   # make install
 


Offline
PostPosted: Wed Jun 21, 2017 6:00 pm Reply with quote
Posts: 6 Joined: Fri Jun 16, 2017 7:10 pm
Josh wrote:
Hmm, if you're using usb_modeswitch as a Raspbian package, it should depend on "tcl".

If you installed from source, there is an important bit in the README file, in the chapter "How to install":
Code:
1. If you have the "Tcl" scripting language available on your system (packages
   "tcl" or "jimsh"), use the light-weight installation:

   # make install
 


Yep, always read the instructions. The stock Raspbian install didn't come with "Libusb" either, so saw that and added and just missed the "tcl" requirement.

Based my project on this link (RPi3 wifi hotspot with mobile broadband and Plex server):

http://www.gavsworld.net/?page=Raspberry%20Pi/Car%20Media%20Server

and I am guessing he installed the repo version rather than the updated source from this site (which he could depending on the modem).

Jon


Offline

Display posts from previous:  Sort by:

All times are UTC+02:00
Page 1 of 1
13 posts
Users browsing this forum: No registered users and 1 guest
Search for:
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum