-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USBTMC triggers assertion soon after configuration, due to extra CLEAR_FEATURE(ENDPT_HALT) #1529
Comments
Ok, USB 2.0 spec confirms that it's OK to send extra ClearFeature(ENDPOINT_HALT), and in that case, the data toggle should be reset, so that's what I'll do (implement by stalling and then unstalling endpoint): USB 2.0 spec 9.4.5:
It also states that the DTOG's should be reset if set_configuration is sent a second time, but I'll worry about that later....
|
@hathach This is starting to look more like a device stack issue. Would you mind looking into the stack, and then I can fix the USBTMC code in particular? When Lines 822 to 825 in 4639cac
But, Lines 1325 to 1341 in 4639cac
-- Based on the USB spec (previous comment), the DTOG should be reset in all cases. It may also make sense to abort any pending transfers (but I don't know how that fits into the current USBD API). USB 3.2 seems to specify that the streams be reset (so aborting/discarding pending transfers is consistant):
|
Thanks @pigrew for the analysis, since I am not familiar with usbtmc, can you provide the link to download/install the driver. I will try to reproduce this to have a closer look/fix on the issue. |
https://www.ni.com/en-us/support/downloads/drivers/download.ni-visa.html is the driver I'm using (on windows 10). Also, I'm working on some USBTMC changes including the high-speed patch, in my branch https://github.com/pigrew/tinyusb/tree/usbtmc_highspeed |
I discovered there was an intermittent failure also due to this same issue with the USBTMC interrupt-in endpoint, so I added that to my patch. |
One solution would be to modify usbd.c starting at: Line 817 in 4639cac
to be:
This may break existing classes, since they will need to re-issue any pending transfers on the endpoints. A class driver may want to choose to maintain an endpoint in a stalled state (if the class decides it is inappropriate for the halt to be cleared, as mentioned in the USBTMC spec....). However, I don't plan on immediately using this feature to leave an EP in the stalled state. |
Operating System
Windows 10
Board
stm32f070rb
Firmware
master
branch (ae8b8f0)Driver is NI VISA for windows v21.5
What happened ?
Summary: Soon after device configuration, the host sends a CLEAR_FEATURE(ENDPOINT_HALT) on the USBTMC bulk-out endpoint, triggering an assertion that a transfer is being started on a busy endpoint (usbd_edpt_xfer:1243).
At configuration, the class driver initiates a bulk-in transfer, so the endpoint is correctly being marked as busy. Then, the host sends CLEAR_FEATURE(ENDPOINT_HALT), and the class driver tries to initiate a second transfer on the already busy EP.
I'm not sure what the device should be doing:
I'm proposing the following, though additional input is appreciated:
I'm going to continue trying to figure out what the correct behavior should be, and propose a patch.... Triggering an assert is bad.
How to reproduce ?
Flash with usbtmc example, and connect to host...
Debug Log as txt file
log_clearFeature.txt
Screenshots
No response
The text was updated successfully, but these errors were encountered: