Activation Codes and Methods, Hardware Details, Sniffing
Post Reply
nelg
Posts: 6
Joined: 08 Jul 2021, 07:56

12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by nelg » 08 Jul 2021, 08:07

I've got a problem with getting usb_modeswitch to set the Configuration for 12d1:15c1 Huawei Technologies Co, Ltd. ME906s LTE M.2 Module

When I run:
usb_modeswitch -v 0x12d1 -p 0x15c1 -W -u 3
libusb produces an error, because it's trying to read /sys/bus/usb/devices/1-2/bConfigurationValue, which has no value.

Error looks like:
usb_modeswitch -v 0x12d1 -p 0x15c1 -W -u 3
Take all parameters from the command line

* usb_modeswitch: handle USB devices with multiple modes
* Version 2.6.1 (C) Josua Dietze 2017
* Based on libusb1/libusbx

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x15c1
Configuration=0x03

Look for default devices ...
Found devices in default mode (1)
Access device 002 on bus 001
Get the current device configuration ...
libusb: error [op_get_active_config_descriptor] device unconfigured
Determining the active configuration failed (error -5). Abort



strace shows this as when it's reading /sys/bus/usb/devices/1-2/bConfigurationValue

If I do: cat /sys/bus/usb/devices/1-2/bConfigurationValue
This value is empty.


However, I can get the modem to work fine, if I do:
echo 3 >> /sys/bus/usb/devices/1-2/bConfigurationValue

Which I currently do with a shell script when I want to use the LTE modem. However, would be nice if I could get this to work with usb_modeswitch.
After using echo to write to /sys/bus/usb/devices/1-2/bConfigurationValue , usb_modeswitch is happy if I re-run it, and reports it does not need to do anything as the modem is already in mode 3, but of course after a suspend/reboot, this value goes back to being not set and usb_modeswitch goes back to getting errors from libusb.

Any suggestions?

nelg
Posts: 6
Joined: 08 Jul 2021, 07:56

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by nelg » 08 Jul 2021, 13:04

I can also confirm that:

File: usb_modeswitch.c

Line: 1865: int ret = libusb_get_active_config_descriptor(dev, &active_config);

ret is equal to -5.

From the libusb documentation, -5 is LIBUSB_ERROR_NOT_FOUND
https://libusb.sourceforge.io/api-1.0/g ... 8b2c27f03f

Maybe the code could just ignore this and set the config value.. however I don't know how to do that in C.

LOM
Posts: 1380
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by LOM » 08 Jul 2021, 19:26

Which linux distro are you using and what is its kernel version?
The linux usb core should set a default configuration, this is the first time for me to see a device being left unconfigured by the linux kernel.
Something is wrong there.

nelg
Posts: 6
Joined: 08 Jul 2021, 07:56

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by nelg » 08 Jul 2021, 23:25

I am running Arch Linux.

Kernel: 5.12.14-arch1-1 #1 SMP PREEMPT Thu, 01 Jul 2021 07:26:06 +0000 x86_64 GNU/Linux


Something else interesting, if I run:
# usb-devices

I get:

T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 9 Spd=480 MxCh= 0
D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs= 3
P: Vendor=12d1 ProdID=15c1 Rev=01.02
S: Manufacturer=Huawei Technologies Co., Ltd.
S: Product=HUAWEI Mobile
S: SerialNumber=0123456789ABCDEF
C: #Ifs= 0 Cfg#= 0 Atr= MxPwr=
cat: '/sys/bus/usb/devices/usb1/1-2/1-*:?.*/bInterfaceNumber': No such file or directory
cat: '/sys/bus/usb/devices/usb1/1-2/1-*:?.*/bAlternateSetting': No such file or directory
cat: '/sys/bus/usb/devices/usb1/1-2/1-*:?.*/bNumEndpoints': No such file or directory
cat: '/sys/bus/usb/devices/usb1/1-2/1-*:?.*/bInterfaceClass': No such file or directory
cat: '/sys/bus/usb/devices/usb1/1-2/1-*:?.*/bInterfaceSubClass': No such file or directory
cat: '/sys/bus/usb/devices/usb1/1-2/1-*:?.*/bInterfaceProtocol': No such file or directory
/usr/bin/usb-devices: line 79: printf: (none): invalid number
I: If#=0x Alt= 0 #EPs= 0 Cls=() Sub= Prot= Driver=

Then I make it work with:
# D=$(dirname $(grep -l 15c1 /sys/bus/usb/devices/*/idProduct))
# grep -q 3 $D/bConfigurationValue || echo 3 >> $D/bConfigurationValue


Running usb-devices again after

# usb-devices
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 9 Spd=480 MxCh= 0
D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs= 3
P: Vendor=12d1 ProdID=15c1 Rev=01.02
S: Manufacturer=Huawei Technologies Co., Ltd.
S: Product=HUAWEI Mobile
S: SerialNumber=0123456789ABCDEF
C: #Ifs= 3 Cfg#= 3 Atr=a0 MxPwr=2mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=0e Prot=00 Driver=cdc_mbim
I: If#=0x1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=02 Driver=cdc_mbim
I: If#=0x2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=14 Driver=option

LOM
Posts: 1380
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by LOM » 09 Jul 2021, 04:47

What happens if you disable usb_modeswitch in /etc/usb_modeswitch.conf and then re-plug the card?
Is it still unconfigured?

nelg
Posts: 6
Joined: 08 Jul 2021, 07:56

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by nelg » 09 Jul 2021, 07:10

That's interesting. I've edited /etc/usb_modeswitch.conf and set:
DisableSwitching=1

On reboot, and trying with suspend and resume, it's working. I can't actually unplug/plugin the device, as it's internal to the laptop.

# usb-devices shows:

T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 7 Spd=480 MxCh= 0
D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=ff MxPS=64 #Cfgs= 3
P: Vendor=12d1 ProdID=15c1 Rev=01.02
S: Manufacturer=Huawei Technologies Co., Ltd.
S: Product=HUAWEI Mobile
S: SerialNumber=0123456789ABCDEF
C: #Ifs= 7 Cfg#= 2 Atr=a0 MxPwr=2mA
I: If#=0x0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=06 Prot=00 Driver=cdc_ether
I: If#=0x1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=06 Prot=00 Driver=cdc_ether
I: If#=0x2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=06 Prot=10 Driver=option
I: If#=0x3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=13 Driver=option
I: If#=0x4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=12 Driver=option
I: If#=0x5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=14 Driver=option
I: If#=0x6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=06 Prot=1b Driver=option


and
/sys/bus/usb/devices/1-2/bConfigurationValue
contains: "2"

This is default:
# cat /usr/share/usb_modeswitch/12d1\:15c1
# Huawei ME906, ME909 (MBIM, dummy config)
Configuration=0



It also appears that the device works in both configuration mode 2 and configuration mode 3.
I don't know the difference between these, although the "usb-devices" output is a bit different between mode 2 and mode 3.

LOM
Posts: 1380
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by LOM » 09 Jul 2021, 09:16

Config 2 is what the usb core should select as the default config so this is correct.
usb_modeswitch will switch it to the mbim config which is the favored linux config, it will do that if the system contains mbim drivers in expected place(s) and it does so by first selecting config 0, then sleeping 100mS, and finally selecting config 3.

The reason for first going to config 0 is that some cards (especially Huawei's) will not work in the mbim configuration if we go directly from config 2 to config 3. If you go directly from config 2 to config 3 then everything will look fine from point of viewbut no data will flow over the mbim interface.

One could think that your problem is that usb_modeswitch only selects config 0 and miss to select config 3 but it can not be that simple - the error message you get comes long before usb_modeswitch runs the switchConfiguration routine.
My guess is instead that the problem is caused by debians rewrite of the usb_modeswitch_dispatcher.

Can you download the original usb_modeswitch source from https://www.draisberghof.de/usb_modeswi ... .1.tar.bz2, compile it and see if your problem remains?

nelg
Posts: 6
Joined: 08 Jul 2021, 07:56

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by nelg » 10 Jul 2021, 04:48

Hi LOM,

Just want to say thank you for the help so far, I feel like we are getting somewhere.

Having just tested config 2 (I'm in a spot with limited mobile coverage this weekend),it seem that it will work for me in either config 2 or config 3, although I am not sure why, given what you say about switching to config 0, then config 3.

If I manually try:
# echo 0 > /sys/bus/usb/devices/1-2/bConfigurationValue
# cat /sys/bus/usb/devices/1-2/bConfigurationValue

After echo 0, reading /sys/bus/usb/devices/1-2/bConfigurationValue returns blank.


I'm running Arch Linux, not Debian, so appear to be using the exact source code you mentioned.
https://github.com/archlinux/svntogit-c ... k/PKGBUILD

I've built this package myself, but also the distro one is the same, Arch uses the original usb_modeswitch source from https://www.draisberghof.de

LOM
Posts: 1380
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by LOM » 14 Jul 2021, 02:54

nelg wrote: 10 Jul 2021, 04:48 Hi LOM,

Having just tested config 2 (I'm in a spot with limited mobile coverage this weekend),it seem that it will work for me in either config 2 or config 3, although I am not sure why, given what you say about switching to config 0, then config 3.
You probably have an improved firmware in your card, that direct switching between config 2 and config 3 doesn't work has been reported by a couple of users and I also have a ME906 which needs going via config 0 when selecting another config.
nelg wrote: 10 Jul 2021, 04:48 If I manually try:
# echo 0 > /sys/bus/usb/devices/1-2/bConfigurationValue
# cat /sys/bus/usb/devices/1-2/bConfigurationValue

After echo 0, reading /sys/bus/usb/devices/1-2/bConfigurationValue returns blank.
Yes that is expected.
nelg wrote: 10 Jul 2021, 04:48 I've built this package myself, but also the distro one is the same, Arch uses the original usb_modeswitch source from https://www.draisberghof.de
I have ran out of ideas of why you get this problem, the config selection via config 0 was introduced in usb_modeswitch 5 years ago and you are the first one to report this problem with it.
I guess you'll have to stick with manual echoing of the config value until a reason for the error is found.

nelg
Posts: 6
Joined: 08 Jul 2021, 07:56

Re: 12d1:15c1 Huawei Technologies Co., Ltd. ME906s LTE M.2 Module

Post by nelg » 14 Jul 2021, 11:33

Hi LOM,

So just setting:
DisableSwitching=1

leaves it in config 2, which it seems to work fine in. Is the any reason why configuation 3 is better?

Does the above disable usb_modeswitch for all devices?
Is the an advantage in just having USB modeswitch not do anything for my specific device, but leave it on in case I plugin some other device?

Regards
Glen Ogilvie

Post Reply