主题 : usb_modeswitch转换模式 出错 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 22864
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2010-06-08
最后登录: 2017-09-13
楼主  发表于: 2010-06-11 11:59

 usb_modeswitch转换模式 出错

你好,我最近在做华为ET128的3G驱动,网上说第一次插进开发板时是被认作CD-ROM  所以就要转换成MODEOM模式 所以我移植了usblib usb_modeswitch工具,信息如下:

[root@296144646 /]# usb 1-1: new full speed USB device using s3c2410-ohci and address 4
lusb 1-1: New USB device found, idVendor=12d1, idProduct=1da1
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: HUAWEI Mobile System Solution
usb 1-1: Manufacturer: HUAWEI Mobile
usb 1-1: SerialNumber: 000000-00-000000
usb 1-1: configuration #2 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices

[root@296144646 /]# usb 1-1: reset full speed USB device using s3c2410-ohci and address 4
scsi 1:0:0:0: CD-ROM            HUAWEI   Mobile CMCC CD   1.25 PQ: 0 ANSI: 0
sr0: scsi-1 drive

[root@296144646/]# lsusb
Bus 001 Device 004: ID 12d1:1da1 Huawei Technologies Co., Ltd.
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@EmbedSky /]# usb_modeswitch -W
Reading config file: /etc/usb_modeswitch.setup

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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1da1
TargetVendor=   0x12d1
TargetProduct=  not set
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 enabled (default)
Success check enabled, max. wait time 20 seconds
System integration mode disabled

usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 001
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_devices: Found 004 on 001
usb_os_find_devices: Found 001 on 001
error obtaining child information: Inappropriate ioctl for device

Looking for target devices ...
  searching devices, found USB ID 0100:0201
No devices in target mode or class found
Looking for default devices ...
  searching devices, found USB ID 0100:0201
No devices in default mode or class found. Nothing to do. Bye.

我就是想问下found USB ID 0100:0201这个ID是啥啊 我没有这个ID的USB设备啊 他读的啥啊 (我用usb_modeswitch.c是1.1.2版本的)
希望研究过和做过这方面东西的高手指点下
补充:我将3G网卡拿掉,没有硬件时,信息如下(还是有个ID):
[root@296144646/]# lsusb
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@296144646/]# usb_modeswitch -W
Reading config file: /etc/usb_modeswitch.setup

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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1da1
TargetVendor=   0x12d1
TargetProduct=  not set
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 enabled (default)
Success check enabled, max. wait time 20 seconds
System integration mode disabled

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

Looking for target devices ...
  searching devices, found USB ID 0206:0203
No devices in target mode or class found
Looking for default devices ...
  searching devices, found USB ID 0206:0203
No devices in default mode or class found. Nothing to do. Bye.
(/etc/usb_modeswitch.setup内容如下:
DefaultVendor=  0x12d1
DefaultProduct=  0x1da1

TargetVendor=   0x12d1
#TargetProduct=  0x1001
#TargetClass= 0x01

# only for reference and 0.x versions
#MessageEndpoint=0x01
CheckSuccess=20
MessageContent="55534243123456780000000000000011060000000000000000000000000000"
HuaweiMode=0
[ 此帖被296144646在2010-06-11 12:31重新编辑 ]
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2010-06-11 12:30
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 新手上路
UID: 22864
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2010-06-08
最后登录: 2017-09-13
2楼  发表于: 2010-06-11 20:58
谢谢 我先去看看吧
级别: 新手上路
UID: 22864
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2010-06-08
最后登录: 2017-09-13
3楼  发表于: 2010-06-12 10:46
谢谢楼主,上面的问题不要看了 是我移植的东西有问题 以解决  关键是有出新问题啦
信息如下:
[root@296144646 /]# usb_modeswitch -W
Reading config file: /etc/usb_modeswitch.setup

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

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1da1
TargetVendor=   0x12d1
TargetProduct=  not set
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 enabled (default)
Success check disabled
System integration mode disabled

usb_set_debug: Setting debugging level to 15 (on)
usb_os_find_busses: Found 001
usb_os_find_busses: Skipping non bus directory devices
usb_os_find_devices: Found 002 on 001
usb_os_find_devices: Found 001 on 001
error obtaining child information: Inappropriate ioctl for device

Looking for target devices ...
  searching devices, found USB ID 12d1:1da1
   found matching vendor ID
  searching devices, found USB ID 1d6b:0001
No devices in target mode or class found
Looking for default devices ...
  searching devices, found USB ID 12d1:1da1
   found matching vendor ID
   found matching product ID
   adding device
  searching devices, found USB ID 1d6b:0001
Found devices in default mode or classzhe shi na a
(1)
Accessing device 002 on bus 001 ...
Ambiguous Class/InterfaceClass: 0x02/0x08Using endpoints 0x05 (out) and 0x85 (in)
Inquiring device details; driver will be detached ...
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
到这一步就停啦  我也不知道咋回事。。。。。。按照网上说的完整信息应如下:
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

SCSI inquiry data (for identification)
-------------------------
Vendor String: HUAWEI
Model String: Mass Storage
Revision String: 2.31
-------------------------

USB description usb 1-1: usbfs: process 1172 (usb_modeswitch) did not claim interface 0 before use
data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Setting up communication with interface 0 ...
Using endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
usb 1-1: usb_modeswitch timed out on ep0out
usb 1-1: USB disconnect, address 2
Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.
但我到OK, driver "usb-storage" detached这 一步之后再没反映啦 想请问下是啥原因啊
好像也没报错啊
级别: 新手上路
UID: 22864
精华: 0
发帖: 10
金钱: 50 两
威望: 10 点
综合积分: 20 分
注册时间: 2010-06-08
最后登录: 2017-09-13
4楼  发表于: 2010-06-13 11:54
我通过打印信息测试得知是如下过程出错:
在usb_modeswitch.c中的ret = usb_bulk_write(devh, MessageEndpoint, (char *)command, 31, 0);和ret = usb_bulk_read(devh, ResponseEndpoint, data, 36, 0);我的程序走过了usb_bulk_write,却在usb_bulk_read中进入了死循环。。。。。然后我在移植的libusb库中找到了(linux.c中附件提供)int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size,
        int timeout)
{
  /* Ensure the endpoint address is correct */
  return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
                timeout);
}

int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size,
        int timeout)
{
  /* Ensure the endpoint address is correct */
  ep |= USB_ENDPOINT_IN;
  return usb_urb_transfer(dev, ep, USB_URB_TYPE_BULK, bytes, size,
                timeout);
}

/*然后通过打印信息知道是在usb_urb_transfer中的    while (!urb.usercontext && ((ret = ioctl(dev->fd, IOCTL_USB_REAPURBNDELAY, &context)) == -1) && waiting) {
      tv.tv_sec = 0;
      tv.tv_usec = 1000; // 1 msec
      select(dev->fd + 1, NULL, &writefds, NULL, &tv); //sub second wait
  }   usb_bulk_write执行一次就退出来拉  而usb_bulk_read确实无限循环  网上有 人说是卡里没钱啦 但这段代码和卡里有没有钱好像没关系啊
[ 此帖被296144646在2010-06-13 12:03重新编辑 ]
描述:用到的两个文件
附件: 个人自愿.zip (17 K) 下载次数:11