tinyusb
tinyusb copied to clipboard
STM32L475 will not send ACK packets after data stage finished
Operating System
Windows 10
Board
STM32L475VET6
Firmware
custom firmware, basically CDC.
What happened ?
During device enumeration, after data stage of SET_LINE_CODING
, it won't send ACK packet. After checking the log, I think the XFRC
bit should not be cleared when OTEPSPR
is set but STPKTRX
is cleared.
https://github.com/hathach/tinyusb/blob/fa895ed3dc46d5aa5e11b19ff07beb6fcfc62655/src/portable/synopsys/dwc2/dcd_dwc2.c#L1028-L1040
By changing line 1038 to if (doepint & DOEPINT_STPKTRX)
, it works fine for me. But after I compile it with -O2
, it occurs some assert failed. Maybe we can have a better way to handle it?
How to reproduce ?
TinyUSB v0.13.0
. Use CDC on STM32L475VET6.
Debug Log as txt file
USBD init
CDC init
dwc2->guid = 2000
dwc2->gsnpsid = 4F54310A
dwc2->ghwcfg1 = 0
...
handle_rxflvl_irq: 970:
EP 00, Byte Count 8, Setup Data Received
daint = 00000000, doepint = A010
handle_rxflvl_irq: 970:
EP 00, Byte Count 0, Out Transfer Complete (ISR)
daint = 00010000, doepint = A011
FIX extra transfer complete on setup/data compete
handle_rxflvl_irq: 970:
EP 00, Byte Count 0, Setup Complete (ISR)
daint = 00010000, doepint = A018
daint = 00010000,on EP 80 with 0 bytes
Set Control Line State: DTR = 0, RTS = 0
USBD Setup Received 21 20 00 00 00 00 07 00
CDC control request
Set Line Coding
Queue EP 00 with 7 bytes ...
handle_rxflvl_irq: 970:
EP 00, Byte Count 7, Out Data Received
daint = 00000000, doepint = 2010
handle_rxflvl_irq: 970:
EP 00, Byte Count 0, Out Transfer Complete (ISR)
daint = 00010000, doepint = 2011
handle_rxflvl_irq: 970:
EP 00, Byte Count 0, Out Transfer Complete (ISR)
daint = 00010000, doepint = 2031
FIX extra transfer complete on setup/data compete // should not be skipped
Screenshots
stuck on status stage:
assert failed after changing:
this is mostly tested with my L476 discovery board. These line of codes are done when doing generic dwc2 driver #1163 with tons of testing (trial/error). Maybe I didn't fully resolve this issue with L4 series just yet (possibly an race condition that is less likely to happen on my L476 discovery board due to clock/hw set up etc..). I don't have official dwc2 specs and the stm manual are not very helpful on this particular issue.
I kind of forget the detail, #126 may contain some useful info with links to stm32 cube driver. Unfortunately I don't have any L475 to test/fix this, but I will try to pull out L476 to test along your suggested changes later on.