stm32cdcuart icon indicating copy to clipboard operation
stm32cdcuart copied to clipboard

SETUP EP0 intermittently overwrites CDC data EP

Open majbthrd opened this issue 6 years ago • 0 comments

This issue may afflict users who implement multiple serial ports AND open and close one of those ports whilst one or more others are open.

Intermittently (seemingly during heavy traffic), an outgoing (PC to device) EP0 USB SETUP message somehow corrupts some of the data in an IN (device to PC) endpoint associated with CDC data.

The test setup is a STM32F072 DISCOVERY running the stock firmware. PA9 is jumper-ed to PA10 (first UART) and PC4 is jumper-ed to PC5 (second UART).

Attached is C source code for a command-line test utility. Two instances are run, such as:

./cdcloop /dev/ttyACM0 ./cdcloop /dev/ttyACM1

On one of the instances (nominally the second), the user uses Ctrl-C to terminate the program and then runs it again. The user then repeats this until there is a "mismatch error" on the first instance.

Per the USB sniffer screenshot, the contents of the SETUP message at 0:54.246.463 previously appear earlier in time at 0:54:245.652 in the CDC data associated with first UART (EP1).

cdc3

It is not apparent how the message seemingly travels back in time, and user options (such as PMA memory mapping) have been exhausted. What is left is the domain of the ST stack. In addition to v1.2.1, I've tried the v1.5 stack, and this has the same behavior.

cdcloop.c.txt

majbthrd avatar Jul 09 '19 19:07 majbthrd