Binary flashing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-15 3:50 AM
How to flash a binary file to the microcontroller with script only ie without STM32Cube IDE & Stm32cube programmer. Please provide a detailed script to flash a given binary saved at a known location
- Labels:
-
STM32H5 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-15 3:56 AM
Would the CubeProgrammer command-line version be OK?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-15 4:01 AM
Thanks for the reply. We need a bat file or script to flash a binary to stm32h503rbt6 using st link ie jtag or RS232
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-15 4:31 AM
Hello @GHM ,
I recommend checking the STM32Cube command-line toolset quick start guide, specifically UM3088 on page 4. It provides helpful information on using the STM32CubeProgrammer as a command-line tool. This should guide you through the necessary steps and commands.
BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-15 4:41 AM
you can follow a bat file used to flash Demo binary for STM32H747I-DK boards , download the demo package in ST.com from this link : https://www.st.com/resource/en/compiled_demos/stm32h747i-disco_demo.zip ,
After downloading, navigate to the following path within the package: stm32h747i-disco_demo.zip\STM32H747I-DISCO_demo\Binary. There, you will find the program_hexfile.bat file, which is specifically designed for the STM32H747I-DK Demo binary. Reviewing this batch file can assist you with your specific case.
Br
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-15 7:04 AM
The STLINK-V3SET offers a windows drive, if you connect it to your destination board, you can use a simple windows batch file to copy to this drive, the ST-Link then writes it to the destination STM32.
So it's basically only this in the *.bat file in the project folder, if "F:" is the ST-Link drive:
copy Release\STM32H733_work.bin F:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-16 2:02 AM
Thanks all. However, neither of the solution is loading the binary to the MCU. Request for a dedicated bat file/script to load the binary to STM32H503RBT6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-16 2:05 AM
So show what you've tried.
Are you getting any error messages?
You need to give full details: we don't have crystal balls to see what's going on in your setup - or even what your setup is!
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-16 2:10 AM
1) Added the below jlink & bat to the source folder & then ran the bat file but no flashing happened
jlink file-"C:\Program Files (x86)\STMicroelectronics\stlink_server\stlinkserver.exe" STM32h503RBT6 -if SWD -speed 4000 -autoconnect 1 -CommanderScript C:\SSB\Develop\SSB_ALPHA\SSB_ALPHA\Debug\flashonly.jlink
flashonly.bat-"C:\Program Files (x86)\STMicroelectronics\stlink_server\stlinkserver.exe" STM32h503RBT6 -if SWD -speed 4000 -autoconnect 1 -CommanderScript C:\SSB\Develop\SSB_ALPHA\SSB_ALPHA\Debug\flashonly.jlink
2) Other .bat files containing the bin files in the same folders
a)
@Echo off
REM Change these paths according to your setup
SET BINARY_FILE=SSB_1.bin
SET CUBE_PROG_PATH="C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
SET STLINK_SN= REM (Optional: specify ST-LINK serial number if needed)
REM Set address for STM32H503RB6 (usually 0x08000000 for main flash)
SET FLASH_ADDR=0x08000000
REM Go to CubeProgrammer directory
cd /d %C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin%
REM Flash binary using STM32CubeProgrammer CLI
STM32_Programmer_CLI.exe ^
-c port=SWD 40000
-d %~dp0%BINARY_FILE% %FLASH_ADDR% ^
-rst
b)
:: STM32CubeProgrammer Utility flash script
@Echo OFF
@setlocal
::COLOR 0B
:: Current Directory
@SET CUR_DIR=%CD%
:: Chip Name
@SET CHIP_NAME=STM32H503RBT6
:: Main Board
@SET MAIN_BOARD=-DISCO
:: Demo Name
@SET DEMO_NAME=STM32Cube_Demo
:: Demo Version
@SET DEMO_VER=V1.0.0
:: Hex filename
@SET HEX_FILE="%SSB_1%.hex"
@IF NOT EXIST "%HEX_FILE%" @SET HEX_FILE=%SSB_1%.hex"
@IF NOT EXIST "%HEX_FILE%" @Echo %HEX_FILE% Does not exist !! && GOTO goError
:: Board ID
@SET BOARD_ID=0
:: External Loader Name
@SET EXT_LOADER=MT25TL01G_%CHIP_NAME%%MAIN_BOARD%
@SET STM32_PROGRAMMER_PATH="%Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
@IF NOT EXIST %STM32_PROGRAMMER_PATH% @SET STM32_PROGRAMMER_PATH="%ProgramW6432%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
@IF NOT EXIST %STM32_PROGRAMMER_PATH% @SET STM32_PROGRAMMER_PATH="%ProgramFiles%\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
@IF NOT EXIST %STM32_PROGRAMMER_PATH% @Echo STM32CubeProgrammer is not installed !! && GOTO goError
@IF NOT EXIST %STM32_PROGRAMMER_PATH% @Echo %STM32_PROGRAMMER_PATH% Does not exist !! && GOTO goError
@SET STM32_EXT_FLASH_LOADER=%C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\api\lib\ExternalLoader%.stldr
@IF NOT EXIST %STM32_EXT_FLASH_LOADER% @Echo %STM32_EXT_FLASH_LOADER% Does not exist !! && GOTO goError
@SET STM32_EXT_FLASH_LOADER=%C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\api\lib\ExternalLoader%.stldr
TITLE STM32CubeProgrammer Utility for %CHIP_NAME%%MAIN_BOARD%
:: Add STM32CubeProgrammer to the PATH
@SET PATH=%STM32_PROGRAMMER_PATH%;%PATH%
@Echo.
@Echo =================================================
@Echo Erase and Flash all memories and reboot the board
@Echo =================================================
@Echo.
STM32_Programmer_CLI.exe -c port=SWD index=%BOARD_ID% reset=HWrst -el %STM32_EXT_FLASH_LOADER% -e all -d %HEX_FILE% -HardRst
@IF NOT ERRORLEVEL 0 (
@GOTO goError
)
@GOTO goOut
:goError
@SET RETERROR=%ERRORLEVEL%
@COLOR 0C
@Echo.
@Echo Failure Reason Given is %RETERROR%
@PAUSE
@COLOR 07
@EXIT /b %RETERROR%
:goOut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-16 2:18 AM
Again, do you get any errors messages with that?
Before going to a .bat file, have you got it working by typing manually?
@GHM wrote:cd /d %C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin%
That doesn't look right: the %...% should enclose a symbol name for expansion.
Did you mean:
cd /d "C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
A complex system designed from scratch never works and cannot be patched up to make it work.
