第二篇 4G模块-USB串口驱动测试

来源:互联网 发布:java最简单的登录界面 编辑:程序博客网 时间:2024/05/16 07:33

一、编译内核

         在linux内核里边修改了对华为ME909S-821的支持,使用make uImage编译,然后下载到开发板上:上电开机,在系统启动过程会打印相关usb串口驱动的信息,但是,我们也可以使用dmesg随时查看,相关信息如下:
usb 1-1: new full-speed USB device number 2 using s3c2410-ohcicdc_ether 1-1:2.0: usb0: register 'cdc_ether' at usb-s3c24xx-1, CDC Ethernet Device, 02:1e:10:1f:00:00option 1-1:2.2: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB0option 1-1:2.3: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB1option 1-1:2.4: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB2option 1-1:2.5: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB3option 1-1:2.6: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB4option: option_instat_callback: error -2
最后出现错误: option_instat_callback error -2,尽管这个错误,目前还无法判断具体原因,开始测试在嵌入式开发板上打电话的功能(也就这个功能尤为吸引我)。
在这里我们要使用一个软件在ubuntu上,查看这个4G模块的信息,比如配置描述符、接口描述符、还有端点描述符等等,拥有这种功能的USB软件肯定有,幸运的是在内核大牛的网站看到这个usbview软件,下载网址:点击打开链接(感谢Greg K-H大牛
 下载代码,解压,可参考INSTALL文件编译安装usbview软件。
最后查看这个4G模块的信息如下:
Config Number: 1Number of Interfaces: 6Attributes: a0MaxPower Needed:   2mAInterface Number: 0Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 10Number of Endpoints: 3Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 10Interval: 32msEndpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 1Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 13Number of Endpoints: 2Endpoint Address: 83Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 02Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 2Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 12Number of Endpoints: 2Endpoint Address: 84Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 03Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 3Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 16Number of Endpoints: 1Endpoint Address: 86Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 3Name: Alternate Number: 1Class: ff(vend.) Sub Class: 06Protocol: 16Number of Endpoints: 3Endpoint Address: 86Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msEndpoint Address: 85Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 04Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 4Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 06Number of Endpoints: 2Endpoint Address: 87Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 05Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 5Name: Alternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 1bNumber of Endpoints: 2Endpoint Address: 88Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 06Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msConfig Number: 2  //实际使用的配置Number of Interfaces: 7Attributes: a0MaxPower Needed:   2mAInterface Number: 0Name:cdc_etherAlternate Number: 0Class: 02(comm.) Sub Class: 06Protocol: 00Number of Endpoints: 1Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 1 
Name: cdc_ether
Alternate Number: 0Class: 0a(data ) Sub Class: 06Protocol: 00Number of Endpoints: 2Endpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 2Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 10Number of Endpoints: 3Endpoint Address: 84Direction: inAttribute: 3Type: Int.Max Packet Size: 10Interval: 32msEndpoint Address: 83Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 02Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 3Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 13Number of Endpoints: 2Endpoint Address: 85Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 03Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 4Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 12Number of Endpoints: 2Endpoint Address: 86Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 04Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 5Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 06Number of Endpoints: 2Endpoint Address: 87Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 05Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msInterface Number: 6Name: optionAlternate Number: 0Class: ff(vend.) Sub Class: 06Protocol: 1bNumber of Endpoints: 2Endpoint Address: 88Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 06Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msConfig Number: 3Number of Interfaces: 2Attributes: a0MaxPower Needed:   2mAInterface Number: 0Name: Alternate Number: 0Class: 02(comm.) Sub Class: 0eProtocol: 00Number of Endpoints: 1Endpoint Address: 82Direction: inAttribute: 3Type: Int.Max Packet Size: 16Interval: 2msInterface Number: 1Name: Alternate Number: 0Class: 0a(data ) Sub Class: 00Protocol: 02Number of Endpoints: 0Interface Number: 1Name: Alternate Number: 1Class: 0a(data ) Sub Class: 00Protocol: 02Number of Endpoints: 2Endpoint Address: 81Direction: inAttribute: 2Type: BulkMax Packet Size: 512Interval: 0msEndpoint Address: 01Direction: outAttribute: 2Type: BulkMax Packet Size: 512Interval: 0ms
以上就是使用usbview软件查看的USB设备信息,这里对应这个ttyUSB0-ttyUSB4理解:
cdc_ether 1-1:2.0: usb0: register 'cdc_ether' at usb-s3c24xx-1, CDC Ethernet Device, 02:1e:10:1f:00:00option 1-1:2.2: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB0option 1-1:2.3: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB1option 1-1:2.4: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB2option 1-1:2.5: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB3option 1-1:2.6: GSM modem (1-port) converter detectedusb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
目前还没有拿到证据,但在观看这里的1-1.2.0到最后的1-1.2.6,估计2代表使用的配置2,就是上面的Config Number为2的配置描述符,后边的数字从0、2、3、4、5、6代表了上边的接口描述符,可以从接口描述符名字观察到,其中配置描述符2的接口描述符1没有使用上。



二、关于option_instat_callback error -2的原因

   【1】函数内容:
static void option_instat_callback(struct urb *urb){int err;int status = urb->status;struct usb_serial_port *port =  urb->context;struct option_port_private *portdata = usb_get_serial_port_data(port);dbg("%s", __func__);dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata);if (status == 0) {struct usb_ctrlrequest *req_pkt =(struct usb_ctrlrequest *)urb->transfer_buffer;if (!req_pkt) {dbg("%s: NULL req_pkt", __func__);return;}if ((req_pkt->bRequestType == 0xA1) &&(req_pkt->bRequest == 0x20)) {int old_dcd_state;unsigned char signals = *((unsigned char *)urb->transfer_buffer +sizeof(struct usb_ctrlrequest));dbg("%s: signal x%x", __func__, signals);old_dcd_state = portdata->dcd_state;portdata->cts_state = 1;portdata->dcd_state = ((signals & 0x01) ? 1 : 0);portdata->dsr_state = ((signals & 0x02) ? 1 : 0);portdata->ri_state = ((signals & 0x08) ? 1 : 0);if (old_dcd_state && !portdata->dcd_state) {struct tty_struct *tty =tty_port_tty_get(&port->port);if (tty && !C_CLOCAL(tty))tty_hangup(tty);tty_kref_put(tty);}} else {dbg("%s: type %x req %x", __func__,req_pkt->bRequestType, req_pkt->bRequest);}++++++}else if(status ==-ENOENT || status == -ESHUTDOWN) {++++++         dbg("%s: urb stopped: %d\n", __func__, status);         }else               err("%s: error %d", __func__, status);/* Resubmit urb so we continue receiving IRQ data */if (status != -ESHUTDOWN && status != -ENOENT) {err = usb_submit_urb(urb, GFP_ATOMIC);if (err)dbg("%s: resubmit intr urb failed. (%d)",__func__, err);}}



找了好久,在linux-usb的邮件里边找到了一个人提交的patch,里边描述的问题正好就是option: option_instat_callback: error -2,综合了他的修改,同时在option.c文件前边加上dbg函数:
#ifdef CONFIG_USB_DEBUGstatic int mydebug = 5;#elsestatic int mydebug = 1;#endif/* Use our own dbg macro */#undef dbg#define dbg(format, arg...) \do { \ if(mydebug > 3)\printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg);\} while (0)





1 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 楼开盘人多怎么办 低保取消廉租房怎么办 航空公司病退审核慢怎么办 江里水流大跑线怎么办 js逻辑好难怎么办 怀孕了好无聊怎么办 做表率我们怎么办心得 晚上左转逆行了怎么办 鼓浪屿船票买不到怎么办 信用卡逾期房贷批不下来怎么办 房贷逾期还款怎么办 网被垄断了怎么办? 百度搜索网页打不开怎么办? 原生家庭很糟糕怎么办 白色油漆变黄怎么办 白油漆家具泛黄怎么办 交通电子眼60分怎么办 被公司罚款了怎么办 公司对员工罚款怎么办 高一军训洗漱怎么办 吃精神病药发胖怎么办 神经病人不吃药怎么办 事故全责不赔钱怎么办 吃精神药物发胖怎么办 郑州出院限号怎么办 林场改革森林消防怎么办 网络课没有看完怎么办 福建省会计证未换怎么办 国税地税登记后怎么办 网上发票领不了怎么办 合肥餐饮怎么办环评 地税财务报表上传错误怎么办? 平安体检卡过期怎么办 到医院挂号后怎么办 一吹风就头痛怎么办 平安口袋e怎么办离职 学员学分卡号怎么办 华医网注册错了怎么办 医师继续教育学分不够怎么办 执业医师学分卡怎么办 护士学分5年没办怎么办