2025-02-16 09:02 AM - edited 2025-02-16 09:07 AM
Hey,
I am using the STM32f769NIH controller and my application has Touchgfx and freeRTOS enabled. The code downloading time is too slow and I want to speed it up.
I figured that turning off the external loaders in the debug configurations yields a smaller code size. Originally it was 6.08 MB and after the it became 256 KB.
This .srec file takes mere 6 seconds to download while the 6.08 MB file took 1 minute.
The issue is the IDE keeps waiting for debugger connection for almost 1.5 minutes before it finds it and then downloads the code (Image attached).
I need the command which can generate the .srec file with input elf file. It should exclude external loaders. I'll manually download this .srec file from the STMCubeprogrammer.
Currently I'm using this command which generates the file but the code doesn't work.
"%OBJCOPY%" -O srec --gap-fill 0xFF --strip-debug --srec-len=32 --srec-forceS3 --remove-section=.loader --remove-section=*FlashSection "%BUILD_DIR%\STM32F769I_DISCO.elf" "%BUILD_DIR%\STM32F769I_DISCO.srec"
Thanks
Solved! Go to Solution.
2025-02-16 10:46 AM
Okay I figured it out.
Just disable the external loaders by unchecking the enabled check mark.
Then create a .bat file and use this
@Echo off
echo STM32 Programming Script
echo ----------------------
REM Set paths
set "CUBE_PROGRAMMER=%ProgramFiles%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe"
set "PROJECT_DIR=%~dp0"
set "BUILD_DIR=%PROJECT_DIR%STM32CubeIDE\Debug"
set "OBJCOPY=C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954\tools\bin\arm-none-eabi-objcopy.exe"
echo Checking for ELF file...
if exist "%BUILD_DIR%\STM32F769I_DISCO.elf" (
echo Found ELF file: STM32F769I_DISCO.elf
REM Delete existing SREC file if it exists
if exist "%BUILD_DIR%\STM32F769I_DISCO.srec" (
echo Removing existing SREC file...
del "%BUILD_DIR%\STM32F769I_DISCO.srec"
)
echo Generating SREC file...
"%OBJCOPY%" -O srec --gap-fill 0xFF --strip-debug --srec-len=32 --srec-forceS3 ^
--remove-section=ExtFlashSection ^
--remove-section=FontFlashSection ^
--remove-section=TextFlashSection ^
"%BUILD_DIR%\STM32F769I_DISCO.elf" "%BUILD_DIR%\STM32F769I_DISCO.srec"
if errorlevel 1 (
echo Error: SREC generation failed!
echo Full command: "%OBJCOPY%" -O srec --gap-fill 0xFF --strip-debug --srec-len=32 --srec-forceS3 ^
--remove-section=ExtFlashSection ^
--remove-section=FontFlashSection ^
--remove-section=TextFlashSection ^
"%BUILD_DIR%\STM32F769I_DISCO.elf" "%BUILD_DIR%\STM32F769I_DISCO.srec"
pause
exit /b 1
)
echo Programming device with generated SREC...
"%CUBE_PROGRAMMER%" --connect port=SWD mode=UR reset=HWrst --write "%BUILD_DIR%\STM32F769I_DISCO.srec"
if errorlevel 1 (
echo Error: Programming failed!
pause
exit /b 1
)
echo Resetting device...
"%CUBE_PROGRAMMER%" --connect port=SWD mode=NORMAL --start
if errorlevel 1 (
echo Error: Reset failed!
pause
exit /b 1
)
echo Programming and reset successful!
) else (
echo Error: ELF file not found!
echo Expected: %BUILD_DIR%\STM32F769I_DISCO.elf
pause
exit /b 1
)
2025-02-16 10:46 AM
Okay I figured it out.
Just disable the external loaders by unchecking the enabled check mark.
Then create a .bat file and use this
@Echo off
echo STM32 Programming Script
echo ----------------------
REM Set paths
set "CUBE_PROGRAMMER=%ProgramFiles%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe"
set "PROJECT_DIR=%~dp0"
set "BUILD_DIR=%PROJECT_DIR%STM32CubeIDE\Debug"
set "OBJCOPY=C:\ST\STM32CubeIDE_1.11.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.100.202210260954\tools\bin\arm-none-eabi-objcopy.exe"
echo Checking for ELF file...
if exist "%BUILD_DIR%\STM32F769I_DISCO.elf" (
echo Found ELF file: STM32F769I_DISCO.elf
REM Delete existing SREC file if it exists
if exist "%BUILD_DIR%\STM32F769I_DISCO.srec" (
echo Removing existing SREC file...
del "%BUILD_DIR%\STM32F769I_DISCO.srec"
)
echo Generating SREC file...
"%OBJCOPY%" -O srec --gap-fill 0xFF --strip-debug --srec-len=32 --srec-forceS3 ^
--remove-section=ExtFlashSection ^
--remove-section=FontFlashSection ^
--remove-section=TextFlashSection ^
"%BUILD_DIR%\STM32F769I_DISCO.elf" "%BUILD_DIR%\STM32F769I_DISCO.srec"
if errorlevel 1 (
echo Error: SREC generation failed!
echo Full command: "%OBJCOPY%" -O srec --gap-fill 0xFF --strip-debug --srec-len=32 --srec-forceS3 ^
--remove-section=ExtFlashSection ^
--remove-section=FontFlashSection ^
--remove-section=TextFlashSection ^
"%BUILD_DIR%\STM32F769I_DISCO.elf" "%BUILD_DIR%\STM32F769I_DISCO.srec"
pause
exit /b 1
)
echo Programming device with generated SREC...
"%CUBE_PROGRAMMER%" --connect port=SWD mode=UR reset=HWrst --write "%BUILD_DIR%\STM32F769I_DISCO.srec"
if errorlevel 1 (
echo Error: Programming failed!
pause
exit /b 1
)
echo Resetting device...
"%CUBE_PROGRAMMER%" --connect port=SWD mode=NORMAL --start
if errorlevel 1 (
echo Error: Reset failed!
pause
exit /b 1
)
echo Programming and reset successful!
) else (
echo Error: ELF file not found!
echo Expected: %BUILD_DIR%\STM32F769I_DISCO.elf
pause
exit /b 1
)