Author Message

<  Everything Coding  ~  Only libusb with version 0.1.12 can be used in modeswitch?

PostPosted: Mon Aug 31, 2009 5:00 am Reply with quote
Posts: 5 Joined: Mon Aug 24, 2009 7:53 am
hi friends,
I use usb_modeswitch 1.0.4 both in ubuntu and in my ARM target platform, both with kernel version :2.6.27, also with Huawei E1750 modem. the switching is fine, however, I can't enumerate the switched E620 modem by the API like search_devices, following are the log in ubuntu.

ypluo@ypluo-dt:~/src/usb_modeswitch-1.0.4$ sudo usb_modeswitch --v
Reading config file: /etc/usb_modeswitch.conf
Read config file: /etc/usb_modeswitch.conf

* usb_modeswitch: tool for controlling "flip flop" mode USB devices
* Version 1.0.3 (C) Josua Dietze 2009
* Works with libusb 0.1.12 and probably other versions

DefaultVendor= 0x12d1
DefaultProduct= 0x1446
TargetVendor= 0x12d1
TargetProduct= 0x1001
TargetClass= not set

DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
MessageEndpoint= not set
MessageContent="55534243000000000000000000000011060000000000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00

InquireDevice enabled (default)
Success check enabled, max. wait time 5 seconds

usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 005
usb_os_find_busses: Found 001
usb_os_find_busses: Found 007
usb_os_find_busses: Found 006
usb_os_find_busses: Found 004
usb_os_find_busses: Found 003
usb_os_find_busses: Found 002
usb_os_find_devices: Found 004 on 005
skipped 1 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 005
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 001
usb_os_find_devices: Found 011 on 007
skipped 4 class/vendor specific interface descriptors
skipped 3 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 007
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 002 on 006
skipped 1 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 006
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 004
usb_os_find_devices: Found 004 on 003
usb_os_find_devices: Found 001 on 003
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 002

Looking for target devices ...
No devices in target mode or class found
Looking for default devices ...
Found default devices (1)
Accessing device 004 on bus 003 ...
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached

Received inquiry data (detailed identification)
-------------------------
Vendor String: HUAWEI
Model String: Mass Storage
Revision String: 2.31
-------------------------

Device description data (identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Trying to send the message to endpoint 0x01 ...
OK, message successfully sent
USB error: could not clear/halt ep 1: Protocol error
Device is gone, skipping further steps ...

Checking for mode switch (max. 5 times, once per second) ...
USB error: failed to open /dev/bus/usb/003/004: No such file or directory
USB error: could not claim interface 0: Bad file descriptor
Original device can't be accessed anymore. Good.
usb_os_find_devices: Found 004 on 005
skipped 1 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 005
error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 001
usb_os_find_devices: Found 011 on 007
skipped 4 class/vendor specific interface descriptors
skipped 3 class/vendor specific interface descriptors
usb_os_find_devices: Found 001 on 007
......

error obtaining child information: Inappropriate ioctl for device
usb_os_find_devices: Found 001 on 004
usb_os_find_devices: Found 001 on 003
usb_os_find_devices: Found 001 on 002
No new devices in target mode or class found

Mode switch has failed. Bye.

so I am wondering there is the mapping between libusb version and linux kernel version, I use the option and usb-serial driver. does it make sense that compiling the usb_modeswitch with libusb 1.0.3 ? will try it.

thanks.


Offline
PostPosted: Mon Aug 31, 2009 8:30 am Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
The libusb version used is always 0.1.12; the problem is certainly somewhere else.

Some points:
  • is the switched device visible with "lsusb" afterwards?
  • try to increase the CheckSuccess value to 10 or even 20 seconds
  • use the latest version 1.0.5, there were some changes in the check logic


Offline
PostPosted: Mon Aug 31, 2009 10:13 am Reply with quote
Posts: 5 Joined: Mon Aug 24, 2009 7:53 am
1) the switched device visible via lsusb
Bus 003 Device 012: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem

and before switch is :
Bus 003 Device 011: ID 12d1:1446 Huawei Technologies Co., Ltd.

2) and after switch, the new device can't be found with check time 20.

3) still doesn't wok using the 1.0.5 version.

after switched, and run usb_modeswitch again, it's said the target devices can't be found.

thanks.


Offline
PostPosted: Mon Aug 31, 2009 12:43 pm Reply with quote
Posts: 5 Joined: Mon Aug 24, 2009 7:53 am
found the code handling for TargetProductList when parsing the conf file, I only keep the Huawei E1750 cfg and comment others. so in function readConfigFile, it isn't initialized.
obviously the calling of search_devices() affected, and I just to change the TargetProductList to NULL when "Count existing target devices" , about source code line 365. then the targeted product can be picked up after second running of the usb_modeswitch.

while still failed in checkSuccess() with previous change.
btw, I am not sure the usb api calling convention, like when to call usb_find_devices() and usb_find_busses(), I have tested the check func with/without adding usb_find_busses() before usb_find_devices(), both failed.

Thanks.


Offline
PostPosted: Mon Aug 31, 2009 7:12 pm Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
You are right, there is a bug. I'm working on it.

Your fix should work fine for your setup, including success check; I will do further research.

The switching procedure does not change the busses, just the devices. So it should be sufficient to only look for changed devices.
And success check with the TargetProductList works fine here.
You can try and write your target product ID into a list ...

Thanks for reporting!


Offline
PostPosted: Mon Aug 31, 2009 7:58 pm Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
Found the second bug.

I wonder if you could test this version please:
usb_modeswitch.c


Offline
PostPosted: Tue Sep 01, 2009 3:43 am Reply with quote
Posts: 5 Joined: Mon Aug 24, 2009 7:53 am
it works for me with the patch.
both for checkSucc after switch , and second run usb_modeswitch to check the target device.

Thank you, Josh. you save my time. I am using your modeswitch on Google Android platform to support external usb modem.

btw, my ARM compiler complain that there is no return value for resetUSB ().

and for signal handler of release_usb_device, I comment usb_release_interface() and usb_close() since there is crash about resource release. (note: mayebe that's due to my usage: I use usb_modeswitch as one service. when usb modem inserted, detected by uevent, then start this service, will be restarted by the framework after exit, and in code , if target found whatever right after switch, or second run, will stop the service. in the first case, the crash happen.)

please let me know if additional tests needed.


Offline
PostPosted: Wed Sep 02, 2009 9:42 pm Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
I'm not sure I understand what you are doing. Are you starting usb_modeswitch with a shell script from the service facility (runlevel scripts)?

Or are you modifying the code to run and check continuously?


Offline
PostPosted: Fri Sep 11, 2009 4:39 am Reply with quote
Posts: 5 Joined: Mon Aug 24, 2009 7:53 am
I can't use the script, in my embedded system, no tcl supported.
anyway, it's no main concern now. :)


Offline
PostPosted: Tue Mar 30, 2010 4:12 pm Reply with quote
Posts: 10 Joined: Tue Mar 30, 2010 3:51 pm
I have a very similar problem with a very similar device. I am running on the embedded system as well. I tested with a couple of different devices and they are ok, except this one, where the switch IS happening, but usb_modeswitch fails to detect new device.

This is rather strange, as the switched device ID is present in the usb_modeswitch output during post-switching check (12d1:1001 is the correct target device ID)!

It even says "found matching vendor ID, found matching product ID from list"... and then keeps on searching...

I wonder if the TargetProductList option is really handled correctly, i.e. if there is more than one target product ID.

Here is the result of executing usb_modeswitch 1.1.1 by hand:

Code:
usb_modeswitch -I -W -D -c /etc/usb_modeswitch.d/12d1:1446

Reading config file: /etc/usb_modeswitch.d/12d1:1446

* usb-modeswitch: handle USB devices with multiple modes
* Version 1.1.1 © Josua Dietze 2010
* Based on libusb0 (0.1.12 and above)

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x12d1
DefaultProduct= 0x1446
TargetVendor= 0x12d1
TargetProduct= not set
TargetProductList=1001,1406,140c,14ac
TargetClass= not set

DetachStorageOnly=0
HuaweiMode=0
SierraMode=0
SonyMode=0
GCTMode=0
MessageEndpoint= not set
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
NeedResponse=0
ResponseEndpoint= not set
Interface=0x00

InquireDevice disabled
Success check enabled, max. wait time 20 seconds
System integration mode enabled

usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 002
usb_os_find_busses: Found 001
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 002 on 001
usb_os_find_devices: Found 001 on 001

Looking for target devices ...
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1446
found matching vendor ID
searching devices, found USB ID 0000:0000
No devices in target mode or class found
Looking for default devices ...
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1446
found matching vendor ID
found matching product ID
adding device
searching devices, found USB ID 0000:0000
Found devices in default mode or class (1)
Accessing device 033 on bus 001 ...

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
Setting up communication with interface 0 ...
Trying to send the message to endpoint 0x01 ...
OK, message successfully sent
USB error: could not clear/halt ep 1: Protocol error
Device is gone, skipping any further commands

Checking for mode switch (max. 20 times, once per second) ...
Original device is gone already, not checking
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list
searching devices, found USB ID 0000:0000
No new devices in target mode or class found

Mode switch has failed. Bye.

fail:


Offline
PostPosted: Tue Mar 30, 2010 6:29 pm Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
That is extremely strange.

I have a test device here (Huawei E161) which has the exact same IDs and parameters; just checked again and it's working like a charm. Are you using libusb1-compat ? That would be the only difference.

I'll try once more with my OpenSUSE installation; it has libusb1. Will report back.



Offline
PostPosted: Tue Mar 30, 2010 6:59 pm Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
No, everything works fine with libusb-compat-0.1.14.

For a quick test, can you edit the source code (usb_modeswitch.c) ?

Change the following line (1125)

if (dev->devnum >= devnum && (int)strtol(dev->bus->dirname,NULL,10) == busnum) {

to

{

and reinstall ...



Offline
PostPosted: Tue Mar 30, 2010 7:01 pm Reply with quote
Posts: 10 Joined: Tue Mar 30, 2010 3:51 pm
Josh wrote:
Are you using libusb1-compat ? That would be the only difference.


Josh, many thanks for your prompt reply. We are not using libusb1-compat here, but libusb-0.1.12, as recommended.

I just wanted to draw your attention one more time to the fact that usb_modeswitch does detect the new ID correctly, but keeps on searching...

Code:
Searching for target devices ...
usb_os_find_devices: Found 001 on 002
usb_os_find_devices: Found 003 on 001
usb_os_find_devices: Found 001 on 001
searching devices, found USB ID 0000:0000
searching devices, found USB ID 12d1:1001
found matching vendor ID
found matching product ID from list


Do you really think this is related to libusb? Looks more like a programming logic. But what do I know? :wink:


edit: you posted your suggested fix, while i was making my post. :lol: Does it change things that now you know we are not using libusb-compat? Or shall I try that suggested test anyway?


Offline
PostPosted: Tue Mar 30, 2010 7:18 pm Reply with quote
Site Admin Posts: 6423 Joined: Sat Nov 03, 2007 12:30 am
The error is obviously unrelated to the libusb version. I rather suspect the bus (or rather the device) check I used is not working on your system. It's marked as "dirty hack", which might give a subtle hint ...
8)

O.K., after further thoughts, try this new line 1125:

if ( (int)strtol(dev->bus->dirname,NULL,10) == busnum ) {

Aaargh, had to correct again!



Offline
PostPosted: Tue Mar 30, 2010 7:28 pm Reply with quote
Posts: 10 Joined: Tue Mar 30, 2010 3:51 pm
Thanks very much!

Unfortunately I cannot report back immediately, as our version is for an embedded system, for which I have to recompile the complete firmware image and send it to a person who owns the device in question.

While I am doing that, I just want to ask one more thing: two other devices worked OK. They were switched and then detected correctly with the current version 1.1.1. They both had only one possible value for the target product ID. The problematic device has target product list. Coincidence? Perhaps not?


Offline

Display posts from previous:  Sort by:

All times are UTC+02:00
Page 1 of 2
21 posts
Go to page 1 2 Next
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