Skip to content
Browse files

drivers: usb_dc_stm32: Reinitialize the write semaphores on bus reset

If the user attempts to send data before the USB connection is
established (see the HID sample for an example of such code), the
DataInCallback never gets called which leaves the write semaphore in a
taken state forever.

Signed-off-by: Josef Gajdusek <>
  • Loading branch information...
atx authored and galak committed Aug 13, 2018
1 parent 29ffcae commit f01a7250f0baacd6076fed5c81712fc9388dfc67
Showing with 9 additions and 0 deletions.
  1. +9 −0 drivers/usb/device/usb_dc_stm32.c
@@ -880,12 +880,21 @@ int usb_dc_reset(void)

void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
int i;


HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_IN, EP0_MPS, EP_TYPE_CTRL);
HAL_PCD_EP_Open(&usb_dc_stm32_state.pcd, EP0_OUT, EP0_MPS,

/* The DataInCallback will never be called at this point for any pending
* transactions. Reset the IN semaphores to prevent perpetual locked state.
* */
for (i = 0; i < DT_USB_NUM_BIDIR_ENDPOINTS; i++) {

if (usb_dc_stm32_state.status_cb) {
usb_dc_stm32_state.status_cb(USB_DC_RESET, NULL);

0 comments on commit f01a725

Please sign in to comment.
You can’t perform that action at this time.