cancel
Showing results for 
Search instead for 
Did you mean: 

Known issues with STM32 USB CDC?

abaldur
Associate III

Hi

I use the STM32L452 configured as a USB CDC device which is connected to a host PC.

Once every 1-2 weeks the communication breaks down in the OUT direction as seen from the host.

In other words the host receives data, but it's not able to send anything?

Do you know of any USB CDC related issues that could explain this?

Thanks,

/abaldur

5 REPLIES 5
Pavel A.
Evangelist III

Do you have USB bus analyzer?

-- pa

abaldur
Associate III

Unfortunately not at the moment. Do you have recommendations for tools to debug an issue like this?

/ abaldur

abaldur
Associate III
Pavel A.
Evangelist III

AFAKI not fixed by ST, at least in older libraries (F0, F4). Users find their own solutions or workarounds. Or become customers of Segger.

-- pa

abaldur
Associate III

Update:

The problem happened again. I then tried to call USBD_CDC_ReceivePacket and this turned out to get reception started again. So far so good.

On various forum posts I have encountered that people describe that the problem happens when the USB receives data while it is transmitting. So I then tried to reproduce the problem by stress-testing the USB interface with a simple test setup:

- A python script writing data to the device in a while loop.

- The MCU receives the data in the CDC_Receive_FS callback and also writes data with CDC_Transmit_FS in a while loop in main.

10 hours later, it still runs fine. So does anyone know what I can do to reproduce the problem?

If I was able to detect the problem then I could call USBD_CDC_ReceivePacket and recover at runtime. At first, I thought I could just use the return value from USBD_CDC_ReceivePacket. But when I dive into the functions, I can see that the return codes are not properly propagated through:

USBD_CDC_ReceivePacket: Always returns USBD_OK.

USBD_LL_PrepareReceive: Returns proper error code.

HAL_PCD_EP_Receive: Always returns HAL_OK.

USB_EPStartXfer: Always returns HAL_OK.

Are there some status register I can read to detect if I need to call USBD_CDC_ReceivePacket?

By the way, my code is generated with: STM32CubeL4 Firmware Package V1.13.0 / 27-July-2018

Thanks

/ abaldur