cancel
Showing results for 
Search instead for 
Did you mean: 

Flash and run without debug

Georgy Moshkin
Senior II

Here is my current approach to perform flash and run without debug:

  1. install st-link utility
  2. in stm32cubeide open Project->Properties->C/C++ Build->Settings-> tab "Tool Settings" -> MCU Post build outputs check "Convert to Intel Hex file"
  3. Run -> Debug Configurations double-click on first line "C/C++ Application" to create new configuration. Under the tab "Main" set "C/C++ Application" to C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility\ST-LINK_CLI.exe, under the tab "Arguments" set "Program arguments" to -c SWD -P ${project_loc}\${config_name:${project_name}}\${project_name}.hex -Rst, under the tab "Common" check "Display in favorites menu" - "Run"
  4. Window -> Preferences -> General -> Keys set Command "Run" Binding to Ctrl+F11

With this configuration it is possible to quickly perform build and run by pressing Ctrl+B and then Ctrl+F11. Maybe there are better methods to perform flash and run without debug? Also interested in performing reset without flash using SWD.

5 REPLIES 5
M0NKA
Senior

Hey,

Thank you! This is exactly what i need as well. But i use F7 to Build Project and F9 to flash the firmware to the board. As for reset only, it seems if you give wrong

file path, it will just reset the CPU, but not sure how to assign to separate command/key.

Next super useful feature would be SWO print in the Eclipse Console Tab and flashing the firmware with F7 press, without going through twenty buttons in the STLink Utility, same as when using an UART for printf() debugging.

I always wonder why would implement such good hardware debug feature as ITM debug via SWO pin, but not implement it seamlessly in the IDE.

K.

Georgy Moshkin
Senior II

Currently using stm32cube ide 1.0.2 with stm32_programmer_cli.exe (already exists in cubeide directory)

  1. added stm32_programmer_cli.exe to path (environment variables in windows settings)
  2. created myflash.cmd file stm32_programmer_cli.exe -c port=swd -d C:\Users\W10\STM32CubeIDE\workspace_1.0.2\test1\Debug\test1.elf -s
  3. added myflash.cmd to post-build options

It is not best way, because it flashes each time after build, so trick with "C/C++ Application" may be used (first message).

AReic.1
Associate

Thank you to the posters above for sharing some input, helping me the find some good workaround.

My setup: I'm using a Segger JLink Programmer which is already supported by CubeIDE but allows programming by debugging only.

My IDE is running in Win10.

For some strange reason CubeIDE does not allow the classic eclipse "Environment" menu ... therefore I'm using the following procedure to flash without debugging:

Preparations

  • STM32CubeIde: Project->Properties->C/C++Build->Settings->ToolSettings->MCUPostBuild: Check "Convert to Intel hex File".
  • Add a JLink configuration file with the following content: flashonly.jlink
device STM32L052K8
r
#erase
loadfile C:\Users\User1\Documents\git\STM32L052K8_MCU_Extension\STM32L052K8_MCU_Extension\Debug\STM32L052K8_MCU_Extension.hex
r
st
hwinfo
g
q
  • Add a Win-Executable file that runs the JLink-configuration file: flashonly.bat
"C:\Program Files (x86)\SEGGER\JLink\JLink.exe" -device STM32L052K8 -if SWD -speed 12000 -autoconnect 1 -CommanderScript C:\Users\User1\Documents\git\STM32L052K8_MCU_Extension\STM32L052K8_MCU_Extension\flashonly.jlink

Both files reside in the CubeIDE project path and are visible in the Project Explorer.

0690X00000Bux3tQAB.png

The flashonly.bat is once selected as "Open With System Editor".

When clicking on the flashonly.bat file afterwards, the .bat file is simply executed, loading the .hex file and flashing it to the target.

Georgy Moshkin
Senior II

Good example!

I am wondering maybe there is a way to assign some hotkey to run cmd/bat file in CubeIDE's Eclipse?

Or even an ability to create hotkey + sub-menu to executes batch-like script with access to Eclipse environment parameters.

Currently I use run C/C++ Application trick, and run programmer instead of c/c++ app:

C:\ST\STM32CubeIDE_1.1.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_1.1.0.201910081157\tools\bin\STM32_Programmer_CLI.exe

with program arguments set to

-c port=swd -d ${project_loc}\${config_name:${project_name}}\${project_name}.elf -rst

but it need to be written manually for each project

It would be great if any hotkey + sub-menu may be assigned to some script, for example

Ctrl+F11 runs:

some_flash.exe {path_to_flash_file}.hex

some_flash.exe reset

some_tool_gui_to_communicate_with_device {some_parameter_from_eclipse}

Once configured, it may be used for any project name saved in any directory, because {parameters} are replaced with actual values.

Current workarounds with bat/cmd files are still great. When project does not need to be debugged, and you want to see results fast in hardware, doing flash and run is the only option. I think many programmers still using "debug" button to perform flash and run, and then waiting to press "play" button, this procedure certainly wastes some time. When i do flash and run using hotkey, I am free to do next step, for example preparing to run GUI on PC side, or look at oscilloscope screen.

Ivaylo Ilchev
Associate III

Create file makefile.targets at the root of the project:

STM32CubeProgrammer := 'C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe'
 
flash: all
	-@echo 'Download hex/bin to MCU Flash ...'
#	$(STM32CubeProgrammer) -c port=SWD -d $(wildcard *.hex) -Rst
	$(STM32CubeProgrammer) -c port=SWD -d $(wildcard *.bin) 0x8000000 -Rst
 
.PHONY: flash

Click Debug, Release or project folder in Project explorer. Press Shift+F9. Add target "flash". Select new target. Click build. Now you can just press F9.

CubeIDE should have such a command!