cancel
Showing results for 
Search instead for 
Did you mean: 

[Bug] STM32CubeMX generate wrong USB LL code conflict to both software/hardware

Banxian
Associate II

CubeMX version 5.6.1, newest F7_FW_1.16.0, use board selector to create an STM32F723e-discovery project, and turn off usb fs host in connectivity and middle ware, only leave usb hs host enabled.

then click generate.

in generate srcs, navigate to line 386 in usb_core.c

USBH_StatusTypeDef  USBH_Start(USBH_HandleTypeDef *phost)
{
  /* Start the low level driver  */
  USBH_LL_Start(phost);
 
  /* Activate VBUS on the port */
  USBH_LL_DriverVBUS(phost, TRUE);
 
  return USBH_OK;
}

it activate vbus with "1"(True). jump in to implementation of USBH_LL_DriverVBUS, you can see it simple invoke MX_DriverVbusHS in usbh_platform.c. document comment for these two functions saying the "0"(FALSE) is used for activate. it's the first mismatch.

lookup into schematic for F723 board (mb1260_schematics.pdf), the FS and HS use different polarize for VBUS out enable signal.

for HS usb host schematic, MX_DriverVbusHS in usbh_platform.c should modify like this:

/**
  * @brief  Drive VBUS.
  * @param  state : VBUS state
  *          This parameter can be one of the these values:
  *          - 1 : VBUS Active
  *          - 0 : VBUS Inactive
  */
void MX_DriverVbusHS(uint8_t state)
{ 
  uint8_t data = state; 
  /* USER CODE BEGIN PREPARE_GPIO_DATA_VBUS_HS */
  if(state == 1)
  {
    /* Drive high Charge pump */ 	     
    data = GPIO_PIN_SET;
  }
....
}

there still other bugs cause hs and fs host can not working simultaneously but it's need report later

2 REPLIES 2

Hello @Banxian​ 

Thanks for the feedback, issue known, it will be fixed as soon as possible.

Best regards,

Nesrine

OHu.1
Associate

Hello, ST help desk:

10 months passed, this issue is still there in F7_FW_1.16.1, I spent two days to check and find this bug. Please fix it soon.

This issue is come form your boards design, as below pictures, some boards' VBUS control use Low enable ((32F746GDISCOVERY) and some use High enable(Nucleo-F767ZI). They are both F7 series but use different VBUS control chip.

0693W000008y4NuQAI.jpg0693W000008y4NpQAI.jpgThanks.