cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 USB Host Driver - Unreliable cleanup after disconnecting a device?

holger2
Associate
Posted on February 16, 2016 at 11:03

Hello Everybody,

Hello ST,

We've implemented some USB class for communicating with an Android device. 

The application is working fine when plugging it in for the first time. But when disconnecting the USB cable and reconnecting it once again, it seems to be messing up an internal state of the USB Host Driver ending up in a deadlock.

Mikrocontroller: STM32F401xB/C

USB Host Driver: V3.2.2

HAL Driver: V1.3.2

Compiler: gcc version 5.2.1 20151202 (release) [ARM/embedded-5-branch revision 231848]

We are following the init procedures as descriped in the examples. 

Mikrocontroller: STM32F401xB/C

USB Host Driver: V3.2.2

HAL Driver: V1.3.2

Compiler: gcc version 5.2.1 20151202 (release) [ARM/embedded-5-branch revision 231848]

We are following the init procedures as descriped in the examples. 

1. We init the pipes in the ''init'' class function

a. USBH_FindInterface(...)

b. USBH_SelectInterface(...)

c. AllocPipe(...)

d. OpenPipe(...)

e. USBH_LL_SetToggle(...)

2. Application statemachine magic following.. and working

3. After disconnecting the usb device its calling the ''deinit'' class functions

a. Check if Pipe exists (!=0)

b. USBH_ClosePipe(...)

c. USBH_FreePipe

d. Cleaning up pdata

After re-attaching the device once again the complete implementation seems to choke. I still see some (hand written) debug output pulling following functions in an endless loop (even after detaching it once again after hanging).

DBG USBH_Get_DevDesc(114): 

DBG USBH_GetDescriptor(216): 

DBG USBH_CtlReq(560): 

DBG USBH_HandleControl(610): 

Is there some known problem and/or a workaround?

Best Regards,

Holger

Configuration of the basic USB functionality:

hhcd.Instance = USB_OTG_FS;

hhcd.Init.Host_channels = 8;

hhcd.Init.dma_enable = 0;

hhcd.Init.low_power_enable = 0;

hhcd.Init.phy_itface = HCD_PHY_EMBEDDED;

hhcd.Init.Sof_enable = 0;

hhcd.Init.speed = HCD_SPEED_FULL;

#bug #usb #adams.holger #stm32cube
1 REPLY 1
Moamen Ayman
Associate III
Posted on November 24, 2016 at 10:40

Hello Adams,

I'm also trying to connect stm32f4 as host to android through USB,

my Microcontroller is stm32f407vgt6. I can't find available driver for stm32 USB on android, could you share how you you implemented the driver on android to exchange data with the stm32 microcontroller?