2021-05-24 03:55 AM
Hi community,
I meet an issue when I try to build my project.
I'm trying to implement a tflite ANN on STM32H745XI disco board, and validate him on target.
My model is too heavy to embedded FLASH, so I configure for an external FLASH use thanks to QSPI.
I let ANN model on M4 core, FMC & QSPI on M4 runtime.
Same think for clock configuration, I let M4 & M7 Core clock to 64MHz.
When I build project, compiler found many errors due to FMC and QSPI definition...
Someone have already meet the same situation ?
I tried to move FMC, QSPI & ANN on M7 runtime but fail again...
BR,
Benjamin
2021-05-24 04:23 AM
There is an issue in the board definition database.
Please edit the boardExternalMem.xml file located in
C:\Users\xxxxx\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-AI\6.0.0\db\boardExternalMem.xml
and replace the STM32H745I-DISCO board definition by this one:
<board name="STM32H745I-DISCO" die="450"> <!-- DF next board to do -->
<memory name="External NOR Flash" type="Flash" size="4" ip="QSPI">
<file halversion="1.6.0" name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_qspi.c"/>
<file name="Drivers/BSP/Components/mt25tl01g/mt25tl01g.h"/>
<file halversion="1.6.0" name="Drivers/BSP/Components/mt25tl01g/mt25tl01g.c"/>
<file name="Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_qspi.c"/>
<file name="Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_qspi.h"/>
<template name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_conf_template.h" dest="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_conf.h"/>
<template name="Drivers/BSP/Components/mt25tl01g/mt25tl01g_conf_template.h" dest="Drivers/BSP/Components/mt25tl01g/mt25tl01g_conf.h">
<replace token="stm32xxxx.h" value="stm32h7xx.h"/>
<replace token="stm32xxxx_hal.h" value="stm32h7xx_hal.h"/>
</template>
<include name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_qspi.h"/>
<include name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_errno.h"/>
<init>
BSP_QSPI_Init_t qspiInit;
qspiInit.InterfaceMode=MT25TL01G_QPI_MODE;
qspiInit.TransferRate= MT25TL01G_DTR_TRANSFER ;
qspiInit.DualFlashMode= MT25TL01G_DUALFLASH_ENABLE;
BSP_QSPI_Init(0,&qspiInit);
BSP_QSPI_EnableMemoryMappedMode(0);
</init>
<define name="HAL_QSPI_MODULE_ENABLED"/>
<flasher>MT25TL01G_STM32H745I-DISCO.stldr</flasher>
</memory>
<memory name="External SDRAM" type="Ram" size="8" ip="FMC">
<file name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_sdram.c"/>
<file name="Drivers/BSP/Components/mt48lc4m32b2/mt48lc4m32b2.h"/>
<file name="Drivers/BSP/Components/mt48lc4m32b2/mt48lc4m32b2.c"/>
<file name="Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sdram.c"/>
<file name="Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_sdram.h"/>
<file name="Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_ll_fmc.h"/>
<file name="Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_fmc.c"/>
<template name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_conf_template.h" dest="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_conf.h"/>
<template name="Drivers/BSP/Components/mt48lc4m32b2/mt48lc4m32b2_conf_template.h" dest="Drivers/BSP/Components/mt48lc4m32b2/mt48lc4m32b2_conf.h">
<replace token="stm32xxxx_hal.h" value="stm32h7xx_hal.h"/>
</template>
<include name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_sdram.h"/>
<include name="Drivers/BSP/STM32H745I-DISCO/stm32h745i_discovery_errno.h"/>
<init name="BSP_SDRAM_Init" parameters="0"/>
<define name="HAL_SDRAM_MODULE_ENABLED"/>
</memory>
</board>
You can then generate again your project, I recommend that you delete all files under CM4\Drivers and Drivers before.
Regards
Daniel
2021-05-24 06:19 AM
Hi Daniel,
Thanks you for this modification, however errors appears again after *.xml modifications.
<command-line>: note: this is the location of the previous definition
arm-none-eabi-gcc -o "Test_AI_CM7.elf" @"objects.list" -l:NetworkRuntime600_CM7_GCC.a -mcpu=cortex-m7 -T"C:\Users\xxxx\Desktop\Manticore\STM32H745XI-Disco\Test_AI\CM7\STM32H745XIHX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Test_AI_CM7.map" -Wl,--gc-sections -static -Wl,--start-group -l:NetworkRuntime600_CM7_GCC.a -Wl,--end-group -L../../Middlewares/ST/AI/Lib --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: Drivers/STM32H7xx_HAL_Driver/stm32h7xx_hal_qspi.o: in function `HAL_QSPI_Init':
C:/Users/xxxxx/Desktop/Manticore/STM32H745XI-Disco/Test_AI/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_qspi.c:307: multiple definition of `HAL_QSPI_Init'; Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_qspi.o:C:/Users/benja/Desktop/Manticore/STM32H745XI-Disco/Test_AI/CM7/Debug/../Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_qspi.c:307: first defined here
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: Drivers/STM32H7xx_HAL_Driver/stm32h7xx_hal_qspi.o: in function `HAL_QSPI_SetTimeout':
[......]
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: Test_AI_CM7.elf section `.bss' will not fit in region `RAM'
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: region `RAM' overflowed by 205752 bytes
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:71: Test_AI_CM7.elf] Error 1
"make -j12 all" terminated with exit code 2. Build might be incomplete.
15:15:12 Build Failed. 127 errors, 82 warnings. (took 6s.607ms)
2021-05-24 06:31 AM
In order for the patch to work the QSPI in MX should be disabled. I think this is why you have the 2 files.
Regards
Daniel
2021-05-24 06:39 AM
My neural network is too heavy to run (2.49MB of weights) on internal FLASH, so that I wish to use QSPI.
2021-05-24 06:58 AM
Same situation if I didn't change configuration from original *.ioc suplied by CubeMX for STM32H745 discovery board.
I let QSPI, FMC and CubeAI configuration on M4 (all define on M4 runtime).
ANN weights are seperated on bin file, no memory mapping change.
No clock configuration change, set to 64MHz (just for test, will update on the futur)
2021-05-24 07:10 AM
sorry I wasn't clear, in X-Cube-AI when you set in the extra settings to use the external flash, it will automatically add the necessary files to the project and call the BSP of the board to do the initialization.
That's why the peripheral used by the external memory should not be enabled in MX and only on the X-Cube-AI part. Everything is done behind the scene and you don't want to have 2 conflicting initializations
I've put in attachment an sample project that uses external memory on the H745 disco (generated with CubeMX 6.2 for CubeIDE and CubeAI 6.0)
2021-05-24 07:43 AM
Thanks you for the project.
CubeIDE found again an error on both project (yours and mine) :
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: Test_AI_CM7.elf section `.bss' will not fit in region `RAM'
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: region `RAM' overflowed by 199552 bytes
I disable QSPI and FMC on CubeMX and let CubeAI manage them and let start RAM start adress define to 0xD0000000.
2021-05-24 07:51 AM
for you RAM section issue, the default ld script is not using the full available RAM, you can edit the STM32H745XIHX_FLASH.ld and put 512K instead of 256K in this line
RAM (xrw) : ORIGIN = 0x24000000, LENGTH = 256K /* Memory is divided. Actual start is 0x24000000 and actual length is 512K */
2021-05-24 09:10 AM
Now, firmware is built with success.
I'm really sure to understand why with AXI-SRAM size length upgrade, we are able to build this program without errors.
Thanks a lot for your support,
BR
Benjamin