CH559 USB 枚举 返回0x2E错误

设备枚举获取配置描述符时报错返回0x2E错误,USB_PID_STALL 请问如何解决

调整复位后端口使能时间试试看,

这个10改成20,30试试看。



image.png


请问,我也是在使用官网下载的最新的 CH559操作扫马枪直接字符输出 这个例程时,也是在插入条码枪的时候提示错误 2E ,我修改了延时200ms,也是有这个问题,这能解决吗?   

Start @ChipID=59

Wait Device In

HUB 1 dev in

0000 5465 

EnumAllRootDev01 

Reset root hub 1# port

GetDevDescr: A00003 1 

A00003 1 

A00004 1 

endp_pid=90

USB_INT_FG=2E

USB_INT_ST=2E

USB_MIS_ST=AA

USB_RX_LEN=7E

UH_TX_LEN=01

UH_RX_CTRL=50

UH_TX_CTRL=50

UHUB0_CTRL=08

UHUB1_CTRL=09

A00222 E09 

A00004 3593 

endp_pid=90

USB_INT_FG=2E

USB_INT_ST=2E

USB_MIS_ST=2A

USB_RX_LEN=7E

UH_TX_LEN=01

UH_RX_CTRL=50

UH_TX_CTRL=50

UHUB0_CTRL=08

UHUB1_CTRL=09

A00222 E09 

A00004 3593 

endp_pid=90

USB_INT_FG=2E

USB_INT_ST=2E

USB_MIS_ST=2A

USB_RX_LEN=7E

UH_TX_LEN=01

UH_RX_CTRL=50

UH_TX_CTRL=50

UHUB0_CTRL=08

UHUB1_CTRL=09

A00222 E09 

00014 20

00011 20

InitRootDev Err = 20

EnumAllRootDev err = 20

HUB 1 dev out




使用CH559EVT进行测试:http://www.wch.cn/downloads/CH559EVT_ZIP.html

注意一下USB_HOST例程中的延时函数,增加下延时函数mDelayuS的延时时常,特别是高主频的时候。

测试一下相同环境下是否能够操作键盘鼠标。
还有不能排除特定扫码枪不支持USB全速功能。


用EVT里面的USBHOST,只能连接U盘,鼠标和条码枪都连不上,  而用那个条码枪直接输出字符那个例程,可以连接u盘和鼠标,不能连接条码枪,是在数据传输事务中出错


继续查找问题点


插入条码枪的时候,通讯数据第二段的时候,USB_INT_FG 的值是 2E, U_TOG_OK=0 ,所以结果就是 接收出错 我已经把前面的 延时加大了   WAIT_USB_TOUT_200US1000  // 等待USB中断超时时间200uS@Fsys=12MHz 请问要怎么处理呢

1648041644.jpg


well its my expieriance that delays often just mask bugs.


  1. your device uses EP0MaxLen=0x40. (shown in byte7 of the Dev Descriptor)

  2. for some reason you just get 8 bytes which may be legal if you request 8 bytes (linux for example does enum this way)

  3. your vars show that you are still expect more which does violates the spec, your device might or might not respond correctly. 


并不是64字节的问题,从该条码枪插在电脑USB上,和电脑之间的通讯看出,条码枪也是返回18个字节的数据,1648084227(1).jpg


USB主机常见的行为是先获取8字节长度描述符,然后复位一次设备,之后再获取完整的设备描述符。

有可能设备的相应不是特别完善,第一次只能够回复前8字节描述符,需要复位后才会继续响应。

所以尝试一下第一次只获取8字节设备描述符,然后进行总线复位,之后再正常的走枚举流程。


image.pngs初始化的时候已经复位过一次了,这里在获取设备描述符的时候,前面8个获得正确,后面的就出错了,你意思是在这里8个以后,直接再复位一次?再重新获取?


尝试一下


What does the GetDevDescriptor() request send to your device? (wLength field)

Remember the CH559 is host so it can send anything. All OS have more or less tests to handle faulty devices. 

Example: A Host can decite to cancel a pending request. Often this not correctly implemented in device firmware


Here is a short list how Win since the early times does the enum

  1. UsbReset

  2. USBGetDescriptor(Device); wLength=0x40 

  3. UsbReset

  4. USBGetDescriptor(Device); wLength=sizeof(UsbDeviceDescriptor)

  5. USBGetDescriptor(Config); wLength=sizeof(UsbConfigDescriptor)

  6. USBGetDescriptor(Config); wLength=wtotalLength

  7. UsbSetAddress()

  8. here some more requests may occur depending on WinVer and descripors

  9. Parse the Config Descriptor to learn about the device functions

  10. UsbSetConfig(); this is actually not part of the enum

Now the device is in working state and can be used as intented.

Note: the CH559 hostfirmware is responsible for dividing the descriptors into Ep0MaxSize packets.

 

Linux and Mac OS just issue a USbGetDescriptor(Device) with wLength=0x08 to read Ep0MaxSize and omit the extra reset. 

I have used the CH559 in the past to enum various devices for differnt classes. It might be a good idea to put the enum code in an extra function.


类似电脑软件的抓包工具和实际USB物理层的数据传输还有有着不小的差距。
尝试一下在首次获取8字节设备描述符之后复位一次总线,再开始系列操作。
如此尝试之后若还是无法正常通讯,可以直接联系025-52632854,也可将设备寄过来,我们使用USB分析仪来看一下实际的传输情况。


我这里有2个品牌的条码枪,其中一个报2E错误,另一个能正常工作,我先进行后面的工作。这个问题先放一下。

谢谢大家的指导。


只有登录才能回复,可以选择微信账号登录