cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072 USB device spews bogus data

Pavel A.
Evangelist III
Posted on June 16, 2018 at 00:50

Has anyone seen a similar issue?

STM32F072CBT with USB 'Custom HID' based application (mix of 'HID' and 'Custom HID'), on a 100% custom board.

With many hosts (desktop PCs and laptops) it works as intended.

But with certain hosts sometimes the HID data IN endpoint starts spewing a lot of garbage, right after successful enumeration, reading all descriptors etc. Every read from the IN endpoint produces 200+ bytes. My code is not sending this data.

This is seen on a Ellisys analyzer.

I understand that this may be caused by our hardware (USB power suppy and so on) but no idea how.

Any clues? 

Thanks, 

-- pa

#usb-device #usb-hid #stm32f0
1 REPLY 1
Pavel A.
Evangelist III
Posted on June 28, 2018 at 15:57

It seems like the root cause of this is gratituos 'clear halt' requests sent by the host.

When the device's endpoint is not stalled, HAL_PCD_EP_ClrStall (

https://github.com/pavel-a/stm32f0_libs/blob/389cc3c20de72e529038442027d65dd652863305/STM32Cube_FW_F0/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_pcd.c#L1023

) does something horrible to the USB controller or the driver.

After the next IN transaction to this EP, somehow the data pointer and transfer length registers become filled with random values.

The interrupt handler then continues to feed the garbage (so the EP data structures in memory become corrupt too).

I cannot afford digging into it further, so just check whether the EP is stalled in the request handler:

if (!

ep->

is_stall) // bail out

Would be grateful for any comments from people knowledgeable in the STM32F0 USB device controller 

Regards,

Pavel A