nRF5x: race condition in dcd_nrf5x.c
Operating System
Windows 10
Board
PCA10056 (nRF52840 Nordic DK)
Firmware
Firmware provides a USB-CDC and puts the received data onto BLE.
The host software opens the COM port, does some communication and closed the COM port. This in a loop.
What happened ?
The communication on device side hangs after a while (depending on luck after 5x the above loop or 200x). It seems that especially the disconnect causes the hangup condition.
Used compiler is clang. Several versions tested. No change. "Fun" fact: the bug shows up if optimization is turned on. I guess this increases error probability.
The issue disappears if dcd_edpt_xfer() is protected with disable/enable interrupt.
Another thing, which I guess belongs to the problem, I observed failed TU_ASSERTS(). Stack traces below.
How to reproduce ?
Sorry, don't have a simple example. With some support I will do my best to fix this with my application without the mentioned disable/enable interrupt.
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
Failed TU_ASSERT():
usbd_edpt_xfer() at usbd.c:1.243 0x2f3ae
_status_stage_xact() at usbd_control.c:70 0x2f63e
usbd_control_xfer_cb() at usbd_control.c:216 0x2f63e
tud_task_ext() at usbd.c:548 0x2e850
tud_task() at usbd.h:55 0x30a9e
main() at btsi_master_main.cpp:1.375 0x30a9e
dcd_edpt_xfer() at dcd_nrf5x.c:552 0x2cf4e # in my code this is the "TU_ASSERT(!xfer->started);"
usbd_edpt_xfer() at usbd.c:1.249 0x2f42a
_status_stage_xact() at usbd_control.c:70 0x2f6ce
usbd_control_xfer_cb() at usbd_control.c:216 0x2f6ce
tud_task_ext() at usbd.c:548 0x2e8e0
tud_task() at usbd.h:55 0x30b2e
main() at btsi_master_main.cpp:1.375 0x30b2e
Used TinyUSB 0.15.0
Screenshots
No response
I have checked existing issues, dicussion and documentation
- [X] I confirm I have checked existing issues, dicussion and documentation.