使用Cypress USB-Serial SDK测试CY7C65215A遇libusb错误0求助
问题:Cypress USB-Serial SDK测试工具无法识别CY7C65215A设备
我正尝试使用Cypress USB-Serial SDK附带的测试工具,最终为CY7C65215A开发Linux USB串口应用。已完成以下操作:
- 通读顶层README文件
- 按说明构建SDK所需的libusb-1.0.9库
- 编译测试工具
错误现象
使用sudo运行测试工具后,输出如下SDK调试信息,但无设备被列出:
CY:Kernel driver active on the interface number 0 CY:Info The total number of endpoints are 2 CY:Info The Endpoints are in 131 and out 1 and interrup 138 CY:Info The device type is 0 CY: Error in function CyGetSignature ...libusb error is 0! CY:Kernel driver active on the interface number 0 CY:Kernel driver active on the interface number 0 CY:Kernel driver active on the interface number 0 CY:Kernel driver active on the interface number 0 CY:Kernel driver active on the interface number 0 CY:Kernel driver active on the interface number 0
代码定位
通过GDB定位到错误来自CY: Error in function CyGetSignature ...libusb error is 0!,对应cymisc.c中的CyGetSignature函数:
CY_RETURN_STATUS CyGetSignature ( CY_HANDLE handle, UCHAR *signature ) { UINT16 wValue, wIndex, wLength; UINT8 bmRequestType, bmRequest; int rStatus, ioTimeout = CY_USB_SERIAL_TIMEOUT; CY_DEVICE *device; libusb_device_handle *devHandle; if (handle == NULL) return CY_ERROR_INVALID_HANDLE; device = (CY_DEVICE *)handle; devHandle = device->devHandle; bmRequestType = CY_VENDOR_REQUEST_DEVICE_TO_HOST; bmRequest = CY_GET_SIGNATURE_CMD; wValue = 0x00; wIndex = 0x00; wLength = CY_GET_SIGNATURE_LEN; rStatus = libusb_control_transfer (devHandle, bmRequestType, bmRequest, wValue, wIndex, (unsigned char*)signature, wLength, ioTimeout); if (rStatus > 0){ return CY_SUCCESS; } else if (rStatus == LIBUSB_ERROR_TIMEOUT){ CY_DEBUG_PRINT_ERROR ("CY:Time out error ..function is %s \n", __func__); return CY_ERROR_IO_TIMEOUT; } else { CY_DEBUG_PRINT_ERROR ("CY: Error in function %s ...libusb error is %d!\n", __func__, rStatus); return CY_ERROR_REQUEST_FAILED; } }
错误具体来自返回0的libusb_control_transfer,无法通过GDB进入该函数查看内部原因。
libusb调试输出
在主函数中添加putenv( "LIBUSB_DEBUG=4" );开启libusb调试,得到以下信息:
CY:Info The total number of endpoints are 2 CY:Info The Endpoints are in 131 and out 1 and interrup 39 [ 0.202464] [0000374a] libusb: debug [libusb_get_config_descriptor] index 0 CY:Info The device type is 0 [ 0.202479] [0000374a] libusb: debug [libusb_alloc_transfer] transfer 0x5572788007c8 [ 0.202486] [0000374a] libusb: debug [libusb_submit_transfer] transfer 0x5572788007c8 [ 0.202494] [0000374a] libusb: debug [add_to_flying_list] arm timer for timeout in 5000ms (first in line) [ 0.202528] [0000374a] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling [ 0.202535] [0000374a] libusb: debug [handle_events] event sources modified, reallocating event data [ 0.202544] [0000374a] libusb: debug [usbi_wait_for_events] poll() 3 fds with timeout in 60000ms [ 0.202704] [0000374a] libusb: debug [usbi_wait_for_events] poll() returned 1 [ 0.202711] [0000374a] libusb: debug [reap_for_handle] urb type=2 status=0 transferred=0 [ 0.202714] [0000374a] libusb: debug [handle_control_completion] handling completion status 0 [ 0.202717] [0000374a] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer [ 0.202721] [0000374a] libusb: debug [usbi_handle_transfer_completion] transfer 0x5572788007c8 has callback 0x7fc6a5b16dd0 [ 0.202724] [0000374a] libusb: debug [sync_transfer_cb] actual_length=0 [ 0.202728] [0000374a] libusb: debug [libusb_free_transfer] transfer 0x5572788007c8 CY: Error in function CyGetSignature ...libusb error is 0! [ 0.202738] [0000374a] libusb: debug [libusb_close]
设备状态确认
当前怀疑libusb-1.0.9的构建或安装存在问题,但无法确定。设备已正常连接,在lsusb中可见:
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 002: ID 27c6:609c Shenzhen Goodix Technology Co.,Ltd. Goodix USB2.0 MISC Bus 003 Device 003: ID 8087:0032 Intel Corp. Bus 003 Device 004: ID 04b4:0005 Cypress Semiconductor Corp. USB-Serial (Dual Channel) Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 004: ID 090c:3350 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) USB DISK Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
内容的提问来源于stack exchange,提问作者misguidedsquid
相关产品推荐
相关产品推荐

