cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with USB_Host_Library

FrankNatoli
Associate III

Have STM32H7B3 Discovery Kit.

Used CubeMX to create IAR project.

Integrated USB_Host_Library.

Have USB mouse connected to OTG HS port.

Find that USB initialization eventually triggers a configASSERT(pxUnblockedTCB) in source tasks.c function xTaskRemoveFromEventList.

Observe the following sequence:

  1. USBH_Process is called for switch case HOST_IDLE
  2. USBH_Process is called for switch case HOST_DEV_WAIT_FOR_ATTACHMENT
  3. USBH_Process is called for switch case HOST_DEV_ATTACHED
  4. USBH_Process is called for switch case HOST_ENUMERATION
  5. which calls USBH_HandleEnum
  6. which in switch case ENUM_IDLE calls USBH_Get_DevDesc
  7. which calls USBH_GetDescriptor
  8. which calls USBH_CtlReq
  9. which in switch case CMD_SEND calls osMessageQueuePut
  10. which calls xQueueSendToBack
  11. which checks listLIST_IS_EMPTY is pdFALSE
  12. which calls xTaskRemoveFromEventList
  13. which calls listGET_OWNER_OF_HEAD_ENTRY which returns NULL
  14. which triggers configASSERT

It would appear the "if" at step #11 is contradicting the configASSERT at step #14.

Suggestions?

Edit: what is happening is the queue structure is becoming corrupted, not with random garbage, but with USBH related pointers.

Specifically, when HAL_HCD_HC_Init is called, which itself calls USB_HC_Init, field ucQueueNumber in the queue structure mysteriously is overwritten with 0x20004878, which coincidentally is the contents of field pData in structure hUsbHostHS, pointing just beyond the end of hUsbHostHS.

If I single step through HAL_HCD_HC_Init, the corruption does not occur.

But if I let it rip through HAL_HCD_HC_Init, the corruption does occur, which I infer is interrupt related.

Further execution results in more corruption, including xTasksWaitingToReceive field uxNumberOfItems, and it is that corrupted count that causes the configASSERT mentioned above.

But I have not yet been able to identify who is doing the corruption.

Please note, this is 100% STM code, from CubeMX and FreeRTOS.

No code of mine is in the project.

1 REPLY 1
icher.1
Associate

The isuue is not reproduced. 

No configASSERT is triggered!  

Note: The user should be aware that the GPIO for the VBus should be configured and the API for the Enable USB Voltage Detector should be added manually. 

Could you please upload your code or at least give more info ( are you working with cmsis os1 or 2 / lib version...)

Thank you