2021-06-22 10:16 PM
I started a STM32 framework project here: https://github.com/FBergemann/STM32-FreeRTOS-Framework/tree/dev-usb-host-msd. And i am currently busy to set up logging to console and USB FS (as Host to USB stick). But i didn't manage to enable USB OTG FS. I think it's due to an error in enable VBUS. Because in https://github.com/FBergemann/STM32-FreeRTOS-Framework/blob/dev-usb-host-msd/USB_HOST/Target/usbh_conf.c there is
#79 GPIO_InitStruct.Pin = USB_VBUS_Pin;
#80 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; /* wrong?! */
#81 GPIO_InitStruct.Pull = GPIO_NOPULL;
#82 HAL_GPIO_Init(USB_VBUS_GPIO_Port, &GPIO_InitStruct);
I followed instructions according http://evenlund.blogspot.com/2016/10/usb-storage-with-stm32f4-discovery-and_58.html
and https://www.youtube.com/watch?v=uIOb5sSFyUY.
Can you please tell me, what i am doing wrong here?
- thanks!
regards,
Frank
Solved! Go to Solution.
2021-06-30 02:06 AM
Hello,
Your .ioc file generation code does not contain MX_DriverVbusFS(uint8_t state) function. Same case with your user code.
There are two examples available in STM32CubeF7 that manages reading/writing to USB stick with and without RTOS:
Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_RTOS : with RTOS
Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_Standalone : without RTOS
Hope this is what you are looking for.
STM32
2021-06-23 01:36 AM
Hello,
Tips: please refer to the example provided in STM32CubeF7 under : Projects\STM32F767ZI-Nucleo\Applications\USB_Host\MSC_Standalone
STM32
2021-06-23 09:30 AM
Hi,
thanks! - i was using another example as reference: FatFs_USBDisk (which works).
But both - FatFs_USBDisk and MSC_Standalone - don't use *.ioc file for the project.
Is there a reference project with *.ioc? I would like to use that device configuration tool.
regards,
Frank
2021-06-23 09:46 AM
Hello,
I think the simple way to generate USB_FS by using CubeMx with NUCLEO STM32F767ZI is to start your project from "Home" and select "Access to board selector" instead of MCU. Then let CubeMx initialize the board. You can add your code after ..
STM32
2021-06-25 10:38 PM
I think there is an error in the generated code here:
/**
* @brief Drive VBUS.
* @param state : VBUS state
* This parameter can be one of the these values:
* - 1 : VBUS Active
* - 0 : VBUS Inactive
*/
void MX_DriverVbusFS(uint8_t state)
{
uint8_t data = state;
/* USER CODE BEGIN PREPARE_GPIO_DATA_VBUS_FS */
if(state == 0)
{
/* Drive high Charge pump */
data = GPIO_PIN_SET;
}
else
{
/* Drive low Charge pump */
data = GPIO_PIN_RESET;
}
/* USER CODE END PREPARE_GPIO_DATA_VBUS_FS */
HAL_GPIO_WritePin(GPIOG,GPIO_PIN_6,(GPIO_PinState)data);
}
The state evaluation is inverse.
2021-06-25 10:57 PM
its wrong in the framework code:
plugins/com.st.stm32cube.common.mx_6.2.1.202103241236/db/templates/usbh_platform_c.ftl
2021-06-28 04:49 AM
Hello,
Could you please attach the .ioc file that generates the above code of "void MX_DriverVbusFS(uint8_t state)"?
STM32
2021-06-29 11:20 AM
Hello,
it's available in the link i shared, initially: https://github.com/FBergemann/STM32-FreeRTOS-Framework/tree/dev-usb-host-msd.
In concrete here: https://github.com/FBergemann/STM32-FreeRTOS-Framework/blob/dev-usb-host-msd/STM32-FreeRTOS-Framework.ioc
For your convenience also attached.
I have a question:
You know, logging data is essential for applications. The 1st option is the console, another e.g. USB Stick (more data can be recorded here per second).
Is there some example/demo program available, which demonstrates logging to console and USB stick - in 2 variants: without FreeRTOS and with FreeRTOS?
Because also the use of FreeRTOS is a good option. And logging is essential for applications structured in separate FreeRTOS tasks, as well.
Such examples would be really helpful for lots of users of your STM32 boards.
best regards,
Frank
2021-06-30 02:06 AM
Hello,
Your .ioc file generation code does not contain MX_DriverVbusFS(uint8_t state) function. Same case with your user code.
There are two examples available in STM32CubeF7 that manages reading/writing to USB stick with and without RTOS:
Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_RTOS : with RTOS
Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_Standalone : without RTOS
Hope this is what you are looking for.
STM32
2021-07-02 01:06 PM
Hello,
> Your .ioc file generation code does not contain MX_DriverVbusFS(uint8_t state) function. Same case with your user code.
In my implementation in usbh_conf.c there is some USBH_LL_DriverVBUS() which delegates to MX_DriverVbusFS(), and it is implemented in my usbh_platform.c.
But the image created by STM32CubeIDE was wrong - until i fixed that manually.
And it is also wrong in the base image in /opt/st/stm32cubeide_1.6.1/plugins/com.st.stm32cube.common.mx_6.2.1.202103241236/db/templates/usbh_platform_c.ftl
from the installation of st-stm32cubeide_1.6.1_9958_20210326_1446_amd64.deb_bundle.sh (https://www.st.com/en/development-tools/stm32cubeide.html)
But thanks for pointing at the
> Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_RTOS : with RTOS
as a reference :thumbs_up:
However, this reference is for a different board: STM32F769
And it does not have a *.ioc file, in which i could try to change the setting to make it usable for STM32F767.
(Btw, if "Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_RTOS" would have some *.ioc file: would STM32CubeIDE support changing the board type for that? And do the adjustments for my board STM32F767 via *.ioc file?)
Moreover, this reference "Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_RTOS" has some different USBH_LL_DriverVBUS() implementation - in usbh_conf.c:
USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state)
{
#ifdef USE_USB_FS
if(state == 0)
{
/* Configure Low Charge pump */
BSP_IO_WritePin(OTG_FS1_POWER_SWITCH_PIN, BSP_IO_PIN_RESET);
}
else
{
/* Drive High Charge pump */
BSP_IO_WritePin(OTG_FS1_POWER_SWITCH_PIN, BSP_IO_PIN_SET);
}
#endif
#ifdef USE_USB_HS_IN_FS
if(state == 0)
{
/* Configure Low Charge pump */
BSP_IO_WritePin(OTG_FS2_POWER_SWITCH_PIN, BSP_IO_PIN_RESET);
}
else
{
/* Drive High Charge pump */
BSP_IO_WritePin(OTG_FS2_POWER_SWITCH_PIN, BSP_IO_PIN_SET);
}
#endif
HAL_Delay(200);
return USBH_OK;
}
I.e. this one does not use (delegate to) some MX_DriverVbusFS() function.
Instead, it implements itself. And it does this correct (while the MX_DriverVbusFS() implementation is wrong).
Is it possible, to have a version of "Projects\STM32F769I_EVAL\Applications\USB_Host\MSC_RTOS", that used *.ioc file?
thanks in advance!
regards,
Frank