Description
Did you test the latest bugfix-2.1.x
code?
Yes, and the problem still exists.
Bug Description
Unlike their more expensive STM32F407 cousins, the STM32F4x1Cx MCUs do not have a luxury of secondary USB controller.
USB_FLASH_DRIVE_SUPPORT on STM32 requires custom framework-arduinoststm32 https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc-cdc-msc-3.zip
USB Host initialization function expects both USB_OTG_FS
(Full Speed) and USB_OTG_HS
(High Speed) to be defined at compilation time.
STM32F401CC MCU only has USB_OTG_FS
which leads to compilation errors due to undefined USB_OTG_HS
macro.
USBH_LL_Init()
function should be updated to exclude HOST_HS
code when USB_OTG_HS
is not defined.
https://github.com/rhapsodyv/Arduino_Core_STM32/blob/usb-host-msc-cdc-msc-3/cores/arduino/stm32/usb_host/usbh_conf.c#L237
Here is the corrected code where the #ifdef USB_OTG_HS
check is used to block unused section of the code.
@rhapsodyv, please apply this fix to usb-host-msc-cdc-msc-3 branch.
USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
{
/* Init USB_IP */
if (phost->id == HOST_FS) {
/* Link the driver to the stack. */
g_hhcd.pData = phost;
phost->pData = &g_hhcd;
g_hhcd.Instance = USB_OTG_FS;
g_hhcd.Init.Host_channels = 8;
g_hhcd.Init.speed = HCD_SPEED_FULL;
g_hhcd.Init.dma_enable = DISABLE;
g_hhcd.Init.phy_itface = HCD_PHY_EMBEDDED;
g_hhcd.Init.Sof_enable = DISABLE;
if (HAL_HCD_Init(&g_hhcd) != HAL_OK) {
// Error_Handler( );
return USBH_FAIL;
}
USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&g_hhcd));
}
#ifdef USB_OTG_HS
else if (phost->id == HOST_HS) {
/* Link the driver to the stack. */
g_hhcd.pData = phost;
phost->pData = &g_hhcd;
g_hhcd.Instance = USB_OTG_HS;
g_hhcd.Init.Host_channels = 12;
g_hhcd.Init.speed = HCD_SPEED_FULL;
g_hhcd.Init.dma_enable = DISABLE;
#ifdef USE_USB_HS_IN_FS
g_hhcd.Init.phy_itface = USB_OTG_EMBEDDED_PHY;
#else
g_hhcd.Init.phy_itface = USB_OTG_ULPI_PHY;
#endif
g_hhcd.Init.Sof_enable = DISABLE;
g_hhcd.Init.low_power_enable = DISABLE;
g_hhcd.Init.vbus_sensing_enable = DISABLE;
g_hhcd.Init.use_external_vbus = DISABLE;
if (HAL_HCD_Init(&g_hhcd) != HAL_OK) {
Error_Handler();
}
USBH_LL_SetTimer(phost, HAL_HCD_GetCurrentFrame(&g_hhcd));
}
#endif // USB_OTG_HS
return USBH_OK;
}
Expected behavior
Marlin can be compiled for STM32F401CC with USB_FLASH_DRIVE_SUPPORT
and USE_OTG_USB_HOST
options enabled.
Actual behavior
Enabling USB_FLASH_DRIVE_SUPPORT
and USE_OTG_USB_HOST
causes compilation errors.
Version of Marlin Firmware
bugfix-2.1.x
Electronics
STM32F401CCU6 and STM32F411CEU6 boards a.k.a black pill