-
Notifications
You must be signed in to change notification settings - Fork 1k
CDC_ReceiveQueue fails after CPU halt #804
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
Comments
Hi @adammunich |
My understanding is that the host will receive NACKs when the 64 byte endpoint buffer is full, but send them after core resumes and empties the buffer. So, something must becoming out-of-sync on resume. I have not figured out what yet. But the behavior i encountered, is that the rxqueue size may be zero, but there are still "ghost" packet in the EP rx buffer which is not emptied until you send another packet from the host. |
I think I fixed it after a solid 10 hours of late night troubleshooting. We have to change the following line in usbd_ep_conf.c {CDC_OUT_EP, PMA_CDC_OUT_ADDR, PCD_DBL_BUF}, To use single buffer mode. {CDC_OUT_EP, PMA_CDC_OUT_ADDR, PCD_SNG_BUF}, The (ST hal?) software is otherwise unable to keep track of the ping-pong state of the double buffer when debugging with GDB (or if the core is halted some other way). If I halt the STM32 and let the computer send two packets and timeout, when it resumes the USB is always one packet behind unless it is hardware reset by kernel. This ghost in the shell that doesn't make it out until you send another packet, which then takes place of the ghost packet. Note: this is a really serious error that makes the microcontroller unrecoverable even in soft reset. It must be physically disconnected from the computer which is really bad news for reliability, so I suggest we push this fix to the arduino core. |
@adammunich |
Defining USBD_CDC_USE_SINGLE_BUFFER will set endpoint kind as single buffer instead of double one per default. Fixes stm32duino#804 Signed-off-by: Frederic Pillon <[email protected]>
This problem has re appeared as someone had over-written the fix fpistm@90b75cc had committed It was very troublesome to figure out the source of garbage serial data again. |
To fix it we must update const ep_desc_t ep_def[] to:
|
As stated, this commit is part of my fork and was never merged in the official repo. |
I have not pinned down the source of this bug yet, but it is reproducible on both windows and linux.
CDC_ReceiveQueue_ReadSize and other CDC_ReceiveQueue functions will now be out-of-sync with received packets until the device undergoes a host-initiated USB reset or unplug event.
The text was updated successfully, but these errors were encountered: