cancel
Showing results for 
Search instead for 
Did you mean: 

USB device library. CDC behavior at USB host reset

SVely.1
Associate

Hi all,

We are using the en.stm32_f105-07_f2_f4_usb-host-device_lib_2.2.0 library for CDC functionality. Our STM32 ist USB device connected with host. Everything working fine till the host gets HW reset. Then sometimes after host booted again the STM32 does not send data. Do you know why it could happened and do you know reliable fix for this case?

Thanx,

Sergey

2 REPLIES 2
Pavel A.
Evangelist III

When the host reboots it must re-enumerate connected devices (reset, assign address etc).

Make sure you handle this correctly and can repeat enumeration several times.

-- pa

SVely.1
Associate

Hi Pavel,

Thank you for answer! We are using en.stm32_f105-07_f2_f4_usb-host-device_lib_2.2.0

As host we are using PC running with Linux 4.19. The host after reboot finds our board connected as CDC ACM. Enumeration etc. seems to be ok. But there are something wrong in data sending. Because sometimes device sends no data. In this error case I saw in debugger, that data comes via CDC into device. I found already one deadlock in usbd_cdc_core.c sending logic:

  • the sending organized as state machine with checking at SOF in Handle_USBAsynchXfer() whether the sending possible (USB_Tx_State != USB_CDC_BUSY ) and needed (APP_Rx_ptr_out != APP_Rx_ptr_in)
  • If sending needed and possible then the state machine will be set in USB_CDC_BUSY and one initial sending called from this function
  • All other sending until the APP_Rx_length != 0 implemented via IN Endpoint interrupt
  • if USB host gets reset during this sending, then there are no IN endpoint interrupts received and state machine forever is in USB_Tx_State = USB_CDC_BUSY

we implemented resetting of this state machine onto USB Reset interrupt and error comes now very seldom. But sometimes we still see that the device receives and does not send data.

I'm asking me: "what is still wrong here? are we alone who got this error? Probably this error already known and ST knows solution for it"

Thanx,

Sergey