cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7+FREERTOS+FATFS+USB_HOST USB enumeration get device descriptor return USBH_BUSY

zjia.938
Associate

Hello:

Problem Description:

 When I run STM32H7 + USB_HOST bare metal, the USB HOST peripheral of STM32H7 can work normally. 

 When I add USB_HOST to Free RTOS, the program will get stuck in the USB enumeration process to get the device descriptor.

 at this time:USBH_Process ()-> USBH_HandleEnum ()-> USBH_Get_DevDesc ();The function USBH_Get_DevDesc () returns USBH_BUSY, causing the USB HOST to fail to work properly.

Before change:

usbh_conf.h:

#ifndef __USBH_CONF_H

#define __USBH_CONF_H

/* Includes ------------------------------------------------------------------*/

#include "stm32h7xx_hal.h"

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

/* Exported types ------------------------------------------------------------*/

#define USBH_MAX_NUM_INTERFACES        2

#define USBH_MAX_NUM_CONFIGURATION      1

#define USBH_MAX_NUM_SUPPORTED_CLASS     1

#define USBH_KEEP_CFG_DESCRIPTOR       0

#define USBH_MAX_SIZE_CONFIGURATION      256U

#define USBH_MAX_DATA_BUFFER         512U

#define USBH_DEBUG_LEVEL           2

-> #define USBH_USE_OS              0

/* Exported constants --------------------------------------------------------*/

/* Exported macro ------------------------------------------------------------*/

/* CMSIS OS macros */

#if (USBH_USE_OS == 1)

 #include "cmsis_os.h"

 //#define  USBH_PROCESS_PRIO  osPriorityNormal

 #define  USBH_PROCESS_PRIO  osPriorityRealtime

 #define USBH_PROCESS_STACK_SIZE  ((uint16_t)128)

#endif

After changes:

usbh_conf.h:

#ifndef __USBH_CONF_H

#define __USBH_CONF_H

/* Includes ------------------------------------------------------------------*/

#include "stm32h7xx_hal.h"

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

/* Exported types ------------------------------------------------------------*/

#define USBH_MAX_NUM_INTERFACES        2

#define USBH_MAX_NUM_CONFIGURATION      1

#define USBH_MAX_NUM_SUPPORTED_CLASS     1

#define USBH_KEEP_CFG_DESCRIPTOR       0

#define USBH_MAX_SIZE_CONFIGURATION      256U

#define USBH_MAX_DATA_BUFFER         512U

#define USBH_DEBUG_LEVEL           2

-> #define USBH_USE_OS              1

/* Exported constants --------------------------------------------------------*/

/* Exported macro ------------------------------------------------------------*/

/* CMSIS OS macros */

#if (USBH_USE_OS == 1)

 #include "cmsis_os.h"

 //#define  USBH_PROCESS_PRIO  osPriorityNormal

 #define  USBH_PROCESS_PRIO  osPriorityRealtime

 #define USBH_PROCESS_STACK_SIZE  ((uint16_t)128)

#endif

keil debug info:

0690X00000DBqTxQAL.png

I don't know why such a problem occurs, please help me.

thank you very much.

jack zeng

1 REPLY 1
Vito Marolda
Associate III

Hello just having the same problem: did you manage to solve it?