2020-10-13 06:46 PM
Hi, my USB host (CDC class) enumeration get stalled when the device is attached and enumeration status is ENUM_IDLE. The "IF then" test statement "if ( USBH_HandleEnum(phost) == USBH_OK)" should call the routine USBH_HandleEnum() but it does not and the calling routine exits immediately. I'm single stepping the code in debug mode within my IDE.
In USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost) (USBH_Core.c)
....
case HOST_ENUMERATION: // The case is host enumeration so that is correctly found
/* Check for enumeration status */
if ( USBH_HandleEnum(phost) == USBH_OK) // this does not test USBH_HandleEnum and heads straight to exit....
{
/* The function shall return USBH_OK when full enumeration is complete */
USBH_UsrLog ("Enumeration done.");
phost->device.current_interface = 0;
... etc
The routine that should be called is (same lib USBH_Core.c)
**
* @brief USBH_HandleEnum
* This function includes the complete enumeration process
* @param phost: Host Handle
* @retval USBH_Status
*/
static USBH_StatusTypeDef USBH_HandleEnum (USBH_HandleTypeDef *phost)
{
USBH_StatusTypeDef Status = USBH_BUSY;
switch (phost->EnumState)
{
case ENUM_IDLE:
/* Get Device Desc for only 1st 8 bytes : To get EP0 MaxPacketSize */
if ( USBH_Get_DevDesc(phost, 8) == USBH_OK)
{
phost->Control.pipe_size = phost->device.DevDesc.bMaxPacketSize;
phost->EnumState = ENUM_GET_FULL_DEV_DESC;
...etc
Why is that happening? Is it a compiler error or setting? I don't get compiler errors or warning for this code.
Both routines are within USBH_Core.c so it should be able to call this routine.
edits: I can't set a breakpoint in static USBH_StatusTypeDef USBH_HandleEnum (USBH_HandleTypeDef *phost)
I can set breakpoints in other parts of USBH_Core.c
Thanks,
Paul
Solved! Go to Solution.
2020-10-14 03:19 AM
Hi Paul,
it looks like you're using old firmware (STM32CUbe FW_F1 V1.21.0), please upgrade to latest STM32Cube_FW_F4_V1.25.0
and it should work
Thanks
Dan
2020-10-14 03:19 AM
Hi Paul,
it looks like you're using old firmware (STM32CUbe FW_F1 V1.21.0), please upgrade to latest STM32Cube_FW_F4_V1.25.0
and it should work
Thanks
Dan
2020-10-15 05:21 AM
Thanks Dan, I upgraded to the latest STMCube 1.25 firmware and the method
if ( USBH_HandleEnum(phost) == USBH_OK)
is replaced by
if (phost->device.is_connected)
The new generated code did not had a systick handler implemented, so that was easy fixed by adding
void SysTick_Handler(void)
{
HAL_IncTick();
}
The process now just hangs on statement if (phost->device.is_connected) since the device.is_connected bit is not set. I tried to configure the GPIO as pull up but only when the device is removed, it is detected as disconnected. I will try some physical pull up resistors and see if that helps. Maybe the delays must be increased as well to give the device a chance to respond.
Thanks