Activation Codes and Methods, Hardware Details, Sniffing
Post Reply
allengeek
Posts: 5
Joined: 10 Dec 2015, 00:29

usb_modeswitch works on one USB port, not the other

Post by allengeek » 10 Dec 2015, 00:46

I am trying to use the usb_modeswitch to set up a ZTE MF591 4G modem on an embedded Linux system.

The same usb_modeswitch command works one port, but not the other. The two port are on different bus.

In the working case
root@LiteOn-SMC:~# lsusb
Bus 002 Device 002: ID 19d2:1523 ZTE WCDMA Technologies MSM
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@LiteOn-SMC:/data# ./zte.sh
Look for default devices ...
product ID matched
Found devices in default mode (1)
Access device 002 on bus 002
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: T-Mobile
Product: T-Mobile Rocket 4G prepaid
Serial No.: MF5910TMOD000000
-------------------------
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
Read the response to message 1 (CSW) ...
Response successfully read (13 bytes).[436435.459560] usb 2-1: USB disconnect, device number 2

Reset response endpoint 0x81
Could not reset endpoint (probably harmless): -4
Reset message endpoint 0x01
Could not reset endpoint (probably harmless): -4
Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

root@LiteOn-SMC:/data# [436444.461067] usb 2-1: new high-speed USB device number 3 using musb-hdrc
[436444.602190] usb 2-1: New USB device found, idVendor=19d2, idProduct=1525
[436444.609382] usb 2-1: New USB device strings: Mfr=3, Product=2, SerialNumber=4
[436444.617046] usb 2-1: Product: T-Mobile Rocket 4G prepaid
[436444.622769] usb 2-1: Manufacturer: T-Mobile
[436444.627292] usb 2-1: SerialNumber: 6D13E967FE8DC4DF73F04287AC6C9F86173D8788
[436444.643474] cdc_acm 2-1:1.1: ttyACM0: USB ACM device
[436444.681236] cdc_acm 2-1:1.3: ttyACM1: USB ACM device
[436444.718402] cdc_ether 2-1:1.5 usb0: register 'cdc_ether' at usb-musb-hdrc.1.auto-1, CDC Ethernet Device, 02:8d:c4:df:73:f0
[436444.733777] usb-storage 2-1:1.7: USB Mass Storage device detected
[436444.800104] scsi1 : usb-storage 2-1:1.7
[436445.813984] scsi 1:0:0:0: CD-ROM T-Mobile USB SCSI CD-ROM 0001 PQ: 0 ANSI: 0
[436445.831741] scsi 1:0:0:1: Direct-Access T-Mobile MMC Storage 0001 PQ: 0 ANSI: 0
[436445.864378] sd 1:0:0:1: [sda] Attached SCSI removable disk

root@LiteOn-SMC:/data# lsusb
Bus 002 Device 003: ID 19d2:1525 ZTE WCDMA Technologies MSM
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In the non-working case
root@LiteOn-SMC:/data# lsusb
Bus 001 Device 002: ID 19d2:1523 ZTE WCDMA Technologies MSM
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@LiteOn-SMC:/data# ./zte.sh
Look for default devices ...
product ID matched
Found devices in default mode (1)
Access device 002 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: T-Mobile
Product: T-Mobile Rocket 4G prepaid
Serial No.: MF5910TMOD000000
-------------------------
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
Read the response to message 1 (CSW) ...
Response successfully read (13 bytes).
Reset response[436554.426461] usb 1-1: USB disconnect, device number 2
endpoint 0x81
Could not reset endpoint (probably harmless): -4
Reset message endpoint 0x01
Could not reset endpoint (probably harmless): -4
Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!

root@LiteOn-SMC:/data# [436561.741057] usb 1-1: new high-speed USB device number 3 using musb-hdrc
[436561.882276] usb 1-1: New USB device found, idVendor=19d2, idProduct=1523
[436561.889470] usb 1-1: New USB device strings: Mfr=2, Product=1, SerialNumber=3
[436561.897139] usb 1-1: Product: T-Mobile Rocket 4G prepaid
[436561.902869] usb 1-1: Manufacturer: T-Mobile
[436561.907384] usb 1-1: SerialNumber: MF5910TMOD000000
[436561.932046] usb-storage 1-1:1.0: USB Mass Storage device detected
[436561.951522] scsi3 : usb-storage 1-1:1.0
[436562.963016] scsi 3:0:0:0: CD-ROM T-Mobile USB SCSI CD-ROM 0001 PQ: 0 ANSI: 0
[436562.973982] scsi 3:0:0:1: Direct-Access T-Mobile MMC Storage 0001 PQ: 0 ANSI: 0
[436562.996697] sd 3:0:0:1: [sda] Attached SCSI removable disk

root@LiteOn-SMC:/data# lsusb
Bus 001 Device 003: ID 19d2:1523 ZTE WCDMA Technologies MSM
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
The zte.sh looks like the following:

Code: Select all

/usr/local/bin/usb_modeswitch -v 0x19d2 -p 0x1523 -n -M "5553424312345678000000000000061b000000020000000000000000000000"
Any help will be greately appreciated.

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

Re: usb_modeswitch works on one USB port, not the other

Post by LOM » 11 Dec 2015, 16:43

allengeek wrote:I am trying to use the usb_modeswitch to set up a ZTE MF591 4G modem on an embedded Linux system.
You are allowed to name the embedded board, no need to be secretive about it.
Is it a Beagleboard?

Looks like one of your usb ports is sensitive to a short spike of overcurrent making it drop
the voltage to such a low level that the modem resets.
You have a succesful switching, device has "gone", but is afterwards there in its initial state.
It has reset, similar to unpugging and replugging.

Easy to verify, test with a separately powered usb hub in between.

allengeek
Posts: 5
Joined: 10 Dec 2015, 00:29

Re: usb_modeswitch works on one USB port, not the other

Post by allengeek » 11 Dec 2015, 16:50

It's not a exactly Beaglebone, but it is based on the same AM335x platform

allengeek
Posts: 5
Joined: 10 Dec 2015, 00:29

Re: usb_modeswitch works on one USB port, not the other

Post by allengeek » 11 Dec 2015, 17:01

LOH,

Thank you for the help!

I tried with a USB powered hub, and it works!

Somehow I never thought about this because both ports have the same circuitry!

You make my day!

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

Re: usb_modeswitch works on one USB port, not the other

Post by LOM » 11 Dec 2015, 17:04

allengeek wrote:It's not a exactly Beaglebone, but it is based on the same AM335x platform
Using the Mentor Graphics usb controller where usb1 is dual-role (otg) while usb2 is host only? :wink:
There is a hint about unwanted VBUS voltage drops in the linux driver source musb_core.c

allengeek
Posts: 5
Joined: 10 Dec 2015, 00:29

Re: usb_modeswitch works on one USB port, not the other

Post by allengeek » 12 Dec 2015, 02:28

I am reading the musb_core.c, and here is the hint:

/* During connection as an A-Device, we may see a short
* current spikes causing voltage drop, because of cable
* and peripheral capacitance combined with vbus draw.
* (So: less common with truly self-powered devices, where
* vbus doesn't act like a power supply.)
*
* Such spikes are short; usually less than ~500 usec, max
* of ~2 msec. That is, they're not sustained overcurrent
* errors, though they're reported using VBUSERROR irqs.
*
* Workarounds: (a) hardware: use self powered devices.
* (b) software: ignore non-repeated VBUS errors.
*
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/

Workaround a is not an option here. But I am not sure how to do b), in mbus_core.h,

#define VBUSERR_RETRY_COUNT 3

Should I try to increase the retry count?

Thanks for the help.

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

Re: usb_modeswitch works on one USB port, not the other

Post by LOM » 12 Dec 2015, 05:24

allengeek wrote:I am reading the musb_core.c, and here is the hint:

/* During connection as an A-Device, we may see a short
* current spikes causing voltage drop, because of cable
* and peripheral capacitance combined with vbus draw.
* (So: less common with truly self-powered devices, where
* vbus doesn't act like a power supply.)
*
* Such spikes are short; usually less than ~500 usec, max
* of ~2 msec. That is, they're not sustained overcurrent
* errors, though they're reported using VBUSERROR irqs.
*
* Workarounds: (a) hardware: use self powered devices.
* (b) software: ignore non-repeated VBUS errors.
*
* REVISIT: do delays from lots of DEBUG_KERNEL checks
* make trouble here, keeping VBUS < 4.4V ?
*/

Workaround a is not an option here. But I am not sure how to do b), in mbus_core.h,

#define VBUSERR_RETRY_COUNT 3

Should I try to increase the retry count?

Thanks for the help.
You could try increasing the count but I don't think it will improve anything.
The VBUS spikes will occur on both of your controllers but only one of them is sensitive about it and I guess it is because that controller has dual-role function and monitors VBUS in order to decide which role to enter.
The spike is unavoidable, it is caused by your modem disappearing and then reappearing on the bus after it has been mode switched. This spike somehow (because usb controller is doing a role switch?) causes a VBUS drop long enough to make your modem reset and thereby cancelling out the mode switch it just had gone through.

USB controllers are complicated state machine devices and I am just a layman with limited knowledge about them, I suggest you report the problem to the linux_usb mailing list and cc the maintainer of musb.
It is assumed that you have tested and verified your problem on one of the latest linux kernels to make sure it is not an old problem which has already been bug fixed.

MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
M: Felipe Balbi <balbi@kernel.org>
L: linux-usb@vger.kernel.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
S: Maintained
F: drivers/usb/musb/

allengeek
Posts: 5
Joined: 10 Dec 2015, 00:29

Re: usb_modeswitch works on one USB port, not the other

Post by allengeek » 14 Dec 2015, 21:30

I tried to increase the retry count without success.

Since I am only using the USB port in host mode, I tried to change the dr-mode of the USB port from otg to host. Viola! I can now run the usb_modeswitch successfully on both ports.

I am not sure why the modem will fail to switch when the port is set to OTG mode. I will look into this a little more later.

Thanks a lot for your help, LOM.

Post Reply