Since the GUI version of ST-LINK Utility made me some headaches like not automatic reload of the binary file after the file was changed, I was looking for an other more efficient way to flash the STM32 uC.
Atollic TrueStudio has no native support to program a STM32 device.
I’m going to present a simple solution how to embed ST-Link command line executable into TrueStudio.
For your Information, there is an AppNote from Atollic (see link below), how to do that, but my approach is a bit different.
My solution creates automatically backups of files you will use to program the ST32 device.
Step 1:
Create a folder inside you project named e.g. programmer
Step 2:
Copy the command line executable ST-LINK_CLI.exe of ST Link Utility into this folder
Step 3:
Inside the programmer folder, create another folder called compiled_firmware
Step 4:
Inside the programmer folder create a batch file with this name: execute_flash_programming.bat
Step 5:
Open execute_flash_programming.bat using notepad or silimal editor
Step 6:
Put following bat script inside the file, adapt the name of your *.HEX file and the name of your backuped *.HEX file and save
@echo off @echo: echo ************** STM32 Programming *************** @echo: set YYYY=%date:~-4% set MM=%date:~-7,2% set DD=%date:~-10,2% set hr=%time:~0,2% if "%hr:~0,1%" == " " SET hr=0%hr:~1,1% set min=%time:~3,2% set sek=%time:~6,2% set Folder=%~dp0 set source_file=%Folder%..\Debug\My_STM32_Project.hex set destination_file=%Folder%\compiled_firmware\My_STM32_Project_%DD%_%MM%_%YYYY%_%hr%_%min%.hex if not exist %source_file% ( @echo: @echo: echo !!!!!!!!!!!!!!!!!!! ERROR !!!!!!!!!!!!!!!!!!!!! echo Source file: %source_file% doesn't exist ) else ( @echo: @echo: echo off @copy /y %source_file% %destination_file%>NUL if exist %destination_file% ( REM Display uC Info ST-LINK_CLI.exe -rOB @echo: ST-LINK_CLI.exe -c SWD -P %destination_file% -V ST-LINK_CLI.exe -HardRst>NUL ) )
Step 7:
Make sure Atollic TrueStudio generates HEX Files:
Project > Properties > C/C++ Build > Settings > Tool Settings > Other > Output format
Select: convert output format
Format: Intel Hex
Step 8:
Now embed programming into TtrueStudio.
Select:
Run > External Tools > External Tools Configuration
Create new launch configuration named e.G. Program_device
Select location:
${workspace_loc:/My_STM32_Project/programmer/execute_flash_programming.bat}
Apply the new configuration
Add your new tool to menu:
Run > External Tools > Organize favorites and select Program_device
Step 9:
To Flash the device you can select Run > External Tools > Program_device
or just use the keyboar shortcuts:
Hold [ALT], press [R], press [E], release [ALT] anbd press [1]
Thats it!
Using ST-Link Utility inside Atollic TrueSTUDIO
Great article, thnx!