Skip to main content
MMerc.1
Associate III
Nov 19, 2020 8:54 AM UTC
Solved

How can I update the software on STM32F7 ?

Hi,

I want to update the software of the STM32F746BGT via a USB stick or Ethernet connexion.

Firstly, how can I use the USB stick to update the software inside the MCU ?

How can I use the Internet connexion (via UART : Lantronix XPORT) to update the software inside the MCU ?

Best regards

This topic has been closed for replies.
KnarfB
KnarfBBest answer
Super User
Nov 19, 2020 9:44 AM UTC

Partition your code into a bootloader and the real application. The bootloader normally just starts the real app. When some condition is set to true, the bootloader instead communicates with the peripheral(s), downloads + flashes a new version of the app into the flash and finally reboots.

11 replies

KnarfB
KnarfBBest answer
Super User
Nov 19, 2020 9:44 AM UTC

Partition your code into a bootloader and the real application. The bootloader normally just starts the real app. When some condition is set to true, the bootloader instead communicates with the peripheral(s), downloads + flashes a new version of the app into the flash and finally reboots.

MMerc.1
MMerc.1Author
Associate III
Nov 23, 2020 9:21 AM UTC

Hi,

Do you think the example of "STM32Cube_FW_F7_V1.16.0\Projects\STM32756G_EVAL\Applications\USB_Host\FWupgrade_Standalone" works ?

MMerc.1
MMerc.1Author
Associate III
Dec 1, 2020 8:19 AM UTC

Hi,

I try to use the example of "STM32Cube_FW_F7_V1.16.0\Projects\STM32756G_EVAL\Applications\USB_Host\FWupgrade_Standalone" but when I add "#include <usbh_def.h>" in order to use the structure for "extern USBH_HandleTypeDef hUsbHostFS" in main.h I have the following error :

make -j12 all 
arm-none-eabi-gcc "../USB_HOST/Target/usbh_conf.c" -mcpu=cortex-m7 -std=gnu11 -g3 -DUSE_HAL_DRIVER -DSTM32F746xx -DDEBUG -c -I../TouchGFX/gui/include -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../USB_HOST/App -I../TouchGFX/generated/fonts/include -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FreeRTOS/Source/include -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FatFs/src -I../TouchGFX/generated/texts/include -I../TouchGFX/generated/images/include -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 -I"C:/Users/ozone/STM32CubeIDE/workspace_1.3.0/OZONEX_IHM_208/Components/ft5336" -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc -I../Core/Inc -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/CMSIS/Include -I../TouchGFX/generated/gui_generated/include -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/STM32F7xx_HAL_Driver/Inc -I../FATFS/App -I"C:/Users/ozone/STM32CubeIDE/workspace_1.3.0/OZONEX_IHM_208/Components/Common" -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/CMSIS/Device/ST/STM32F7xx/Include -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/CMSIS/Device/ST/STM32F7xx/Include -I"C:/Users/ozone/STM32CubeIDE/workspace_1.3.0/OZONEX_IHM_208/STM32746G-Discovery" -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FatFs/src -IC:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc -I../Middlewares/ST/touchgfx/framework/include -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FreeRTOS/Source/include -I../TouchGFX/target/generated -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/STM32F7xx_HAL_Driver/Inc -I../FATFS/Target -I../TouchGFX/App -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I../USB_HOST/Target -I../TouchGFX/target -IC:/Users/Stef/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"USB_HOST/Target/usbh_conf.d" -MT"USB_HOST/Target/usbh_conf.o" --specs=nano.specs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -o "USB_HOST/Target/usbh_conf.o"
In file included from ../Core/Inc/main.h:38:0,
 from ../USB_HOST/Target/usbh_conf.h:33,
 from C:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h:28,
 from ../USB_HOST/Target/usbh_conf.c:23:
C:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h:280:44: error: 'USBH_MAX_NUM_ENDPOINTS' undeclared here (not in a function); did you mean 'USB_DESC_ENDPOINT'?
 USBH_EpDescTypeDef Ep_Desc[USBH_MAX_NUM_ENDPOINTS];
 ^~~~~~~~~~~~~~~~~~~~~~
 USB_DESC_ENDPOINT
C:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h:295:45: error: 'USBH_MAX_NUM_INTERFACES' undeclared here (not in a function); did you mean 'USBH_MAX_NUM_ENDPOINTS'?
 USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES];
 ^~~~~~~~~~~~~~~~~~~~~~~
 USBH_MAX_NUM_ENDPOINTS
C:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h:422:49: error: 'USBH_MAX_SIZE_CONFIGURATION' undeclared here (not in a function); did you mean 'USB_REQ_SET_CONFIGURATION'?
 uint8_t CfgDesc_Raw[USBH_MAX_SIZE_CONFIGURATION];
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
 USB_REQ_SET_CONFIGURATION
C:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h:423:42: error: 'USBH_MAX_DATA_BUFFER' undeclared here (not in a function); did you mean 'USBH_MAX_PIPES_NBR'?
 uint8_t Data[USBH_MAX_DATA_BUFFER];
 ^~~~~~~~~~~~~~~~~~~~
 USBH_MAX_PIPES_NBR
C:/Users/ozone/STM32Cube/Repository/STM32Cube_FW_F7_V1.16.0/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h:460:32: error: 'USBH_MAX_NUM_SUPPORTED_CLASS' undeclared here (not in a function); did you mean 'USBH_NOT_SUPPORTED'?
 USBH_ClassTypeDef *pClass[USBH_MAX_NUM_SUPPORTED_CLASS];
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 USBH_NOT_SUPPORTED
make: *** [USB_HOST/Target/subdir.mk:18: USB_HOST/Target/usbh_conf.o] Error 1
"make -j12 all" terminated with exit code 2. Build might be incomplete.
 
09:16:05 Build Failed. 6 errors, 0 warnings. (took 13s.12ms)

Do you have any idea about this error ?

Best regards

Frak.1
Associate II
Dec 1, 2020 12:21 PM UTC

For me it is too less information. Can you share your project or this library? How this variables are declared? For example "USBH_MAX_NUM_ENDPOINTS". Are they as #define? Looks like the compiler can't find their declarations.

MMerc.1
MMerc.1Author
Associate III
Dec 1, 2020 2:36 PM UTC

Hi,

I fixed the error. But now, I am trying to figure out how it works.

I call the function "HCD_Port_IRQHandler" and I have to call the function "HAL_HCD_PortEnabled_Callback". Unfortunately, the variable "hprt0" does not have a "USB_OTG_HPRT_PENA" bit... So function "HAL_HCD_PortEnabled_Callback" is never called.

Do you know why ?

Edit 1 :

I fixed the error. Now in case "HOST_CHECK_CLASS" in the function "USBH_Process", I don't have "USBH_OK" when I use "phost->pActiveClass->Init(phost)".

Do you know why ?

Edit 2 :

The problem is in the function "static USBH_StatusTypeDef USBH_MSC_InterfaceInit(USBH_HandleTypeDef *phost)" :

phost->pActiveClass->pData = (MSC_HandleTypeDef *)USBH_malloc(sizeof(MSC_HandleTypeDef));
 MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;

MSC_Handle return NULL value.

Frak.1
Associate II
Dec 1, 2020 10:17 PM UTC

From this little part of the code I conclude that USBH_malloc can't allocate memory. Malloc returns NULL when it can't allocate enough space.