cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX V4.20: VBUS sensing always enabled in FS mode STM32F407

Markus Rudolf
Associate II
Posted on March 15, 2017 at 09:59

I discovered CubeMX 4.20 always generates code where VBUS sensing is enabled, no matter if it is ticked in CubeMX or not. This caused enumeration fails in several projects where PA9 is not used by me (I use it in CDC Virtual Com Port mode)

Affected code file is usbd_conf.c line 299 (line 18 in snippet)

USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
{ 
 /* Init USB_IP */
 if (pdev->id == DEVICE_FS) {
 /* Link The driver to the stack */
 hpcd_USB_OTG_FS.pData = pdev;
 pdev->pData = &hpcd_USB_OTG_FS; 
 
 hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
 hpcd_USB_OTG_FS.Init.dev_endpoints = 4;
 hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
 hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;
 hpcd_USB_OTG_FS.Init.ep0_mps = DEP0CTL_MPS_64;
 hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
 hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;
 hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
 hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;
 hpcd_USB_OTG_FS.Init.vbus_sensing_enable = ENABLE; // <= IT SHOULD BE DISABLED !!!
 hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
 if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)
 {
 Error_Handler();
 }
 HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
 HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);
 }
 return USBD_OK;
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Took me a while. Please fix it, also fix the annoying RCC Init Bug and the 'does not build in STM32 System Workbench because we forgot to put the 'attribute weak' in hypens-bug'.

It is really annoying to correct this after each minor change in CubeMX.

Markus

#cube-mx #stm32cube-bug #usb-vbus
7 REPLIES 7
Nesrine M_O
Lead II
Posted on March 15, 2017 at 10:36

Hi

Rudolf.Markus

,

Thank you for your feedback. The issue has been reportedto our MX team for checking.

-Nesrine-

Markus Rudolf
Associate II
Posted on April 07, 2017 at 18:44

Is this by chance fixed in 4.20.1? The change log is basically worthless:

'Fixed regression in the management of peripherals parameters default value.'

That is so vacuous.

It would be really helpful to provide links to the discussed issues in the forum in the change log or provide some kind of bug tracking system for the CubeMX.

Posted on April 21, 2017 at 22:03

I can agree this - it's not fixed yet.

Posted on August 31, 2017 at 12:44

Hi,

Generating project from CubeMx with STM32F407ZETx mcu reference and STM32Cube FW_F4 V1.16.0 firmware package did not reproduce the issue.

vbus_sensing_enable is correctly set to DISABLE in accordance with 'VBUS sensing' selected as 'Disable' in USB_OTG_FS_Configuration UI panel.

Regards.

Cyril

Cyril FENARD
ST Employee
Posted on April 12, 2018 at 12:00

Hi

Rudolf.Markus

,

May you confirm that the problem is solved also your side?

Thanks in advance for helping to complete this thread.

Regards.

Cyril

Posted on April 12, 2018 at 12:06

I'm working on different projects right now, but I'm spinning a revision 2 of the affected board / firmware which is in production already. I will test then with the latest Cube and will report back. But it will take me some time.

Posted on April 12, 2018 at 12:07

Which CubeMX version did u test with so I can reproduce it's fixed? I think firmware version is a different story than CubeMx version?