設(shè)備枚舉獲取配置描述符時(shí)報(bào)錯(cuò)返回0x2E錯(cuò)誤,USB_PID_STALL 請(qǐng)問如何解決
調(diào)整復(fù)位后端口使能時(shí)間試試看,
這個(gè)10改成20,30試試看。
請(qǐng)問,我也是在使用官網(wǎng)下載的最新的?CH559操作掃馬槍直接字符輸出 這個(gè)例程時(shí),也是在插入條碼槍的時(shí)候提示錯(cuò)誤 2E ,我修改了延時(shí)200ms,也是有這個(gè)問題,這能解決嗎?? ?
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進(jìn)行測(cè)試:http://www.findthetime.net/downloads/CH559EVT_ZIP.html
注意一下USB_HOST例程中的延時(shí)函數(shù),增加下延時(shí)函數(shù)mDelayuS的延時(shí)時(shí)常,特別是高主頻的時(shí)候。
測(cè)試一下相同環(huán)境下是否能夠操作鍵盤鼠標(biāo)。
還有不能排除特定掃碼槍不支持USB全速功能。
用EVT里面的USBHOST,只能連接U盤,鼠標(biāo)和條碼槍都連不上,? 而用那個(gè)條碼槍直接輸出字符那個(gè)例程,可以連接u盤和鼠標(biāo),不能連接條碼槍,是在數(shù)據(jù)傳輸事務(wù)中出錯(cuò)
繼續(xù)查找問題點(diǎn)
插入條碼槍的時(shí)候,通訊數(shù)據(jù)第二段的時(shí)候,USB_INT_FG 的值是 2E,?U_TOG_OK=0 ,所以結(jié)果就是 接收出錯(cuò) 我已經(jīng)把前面的 延時(shí)加大了? ?WAIT_USB_TOUT_200US1000? // 等待USB中斷超時(shí)時(shí)間200uS@Fsys=12MHz 請(qǐng)問要怎么處理呢
well its my expieriance that delays often just mask bugs.
your device uses EP0MaxLen=0x40. (shown in byte7 of the Dev Descriptor)
for some reason you just get 8 bytes which may be legal if you request 8 bytes (linux for example does enum this way)
your vars show that you are still expect more which does violates the spec, your device might or might not respond correctly.?
并不是64字節(jié)的問題,從該條碼槍插在電腦USB上,和電腦之間的通訊看出,條碼槍也是返回18個(gè)字節(jié)的數(shù)據(jù),
USB主機(jī)常見的行為是先獲取8字節(jié)長(zhǎng)度描述符,然后復(fù)位一次設(shè)備,之后再獲取完整的設(shè)備描述符。
有可能設(shè)備的相應(yīng)不是特別完善,第一次只能夠回復(fù)前8字節(jié)描述符,需要復(fù)位后才會(huì)繼續(xù)響應(yīng)。
所以嘗試一下第一次只獲取8字節(jié)設(shè)備描述符,然后進(jìn)行總線復(fù)位,之后再正常的走枚舉流程。
s初始化的時(shí)候已經(jīng)復(fù)位過一次了,這里在獲取設(shè)備描述符的時(shí)候,前面8個(gè)獲得正確,后面的就出錯(cuò)了,你意思是在這里8個(gè)以后,直接再復(fù)位一次?再重新獲取?
嘗試一下
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
UsbReset
USBGetDescriptor(Device); wLength=0x40?
UsbReset
USBGetDescriptor(Device); wLength=sizeof(UsbDeviceDescriptor)
USBGetDescriptor(Config); wLength=sizeof(UsbConfigDescriptor)
USBGetDescriptor(Config); wLength=wtotalLength
UsbSetAddress()
here some more requests may occur depending on WinVer and descripors
Parse the Config Descriptor to learn about the device functions
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.
類似電腦軟件的抓包工具和實(shí)際USB物理層的數(shù)據(jù)傳輸還有有著不小的差距。
嘗試一下在首次獲取8字節(jié)設(shè)備描述符之后復(fù)位一次總線,再開始系列操作。
如此嘗試之后若還是無法正常通訊,可以直接聯(lián)系025-52632854,也可將設(shè)備寄過來,我們使用USB分析儀來看一下實(shí)際的傳輸情況。
我這里有2個(gè)品牌的條碼槍,其中一個(gè)報(bào)2E錯(cuò)誤,另一個(gè)能正常工作,我先進(jìn)行后面的工作。這個(gè)問題先放一下。
謝謝大家的指導(dǎo)。