Hey!
lately, I've been doing some embedded programming at work, and I got frustrated by the time it takes CubeIDE launch configuration to download my code to the microcontroller. It seems to use the GDB server on each code download, even when the intention is to only run the code, not debug it. Why not just create a launch configuration to simply download firmware using for example the ST-LINK CLI or the newer Cube Programmer CLI which takes like 10x less time? I don't know - I haven't found a way to set up such an option using the GUI in the launch configuration settings. There's even no option to modify the command output so that it could be replaced with a custom command.
Basically, I'd like to run a short script (the 0x5000 offset is due to the bootloader):
ST-LINK_CLI.exe -P %~dp0..\Debug\test.bin 0x08005000 -V
ST-LINK_CLI.exe -Rst
and build the project automatically before that in Debug or Release, depending on which launch configuration was selected from the popup.
Eclipse External Tools configuration you say! Not so fast (at least for me). It lets you run your custom script, even build the project before that, BUT there's no way of automatically changing the build configuration. This means I have to remember about pressing the hammer icon and selecting the right configuration (Debug / Release), or else I will upload an older binary if I forget to compile it. Example: currently selected build conf. is debug, but I select the External Tools script that uploads binary from Release - the project will still be built for debug and I'll end up downloading the older release binary. This is not acceptable.
Finally, after some thinking, I got an idea: what if I could trick Eclipse to run a C/C++ launch configuration but instead of providing the project binary I could just give him the script I want to execute? This seems hacky, but it turns out it works well! The steps if you'd like to create a configuration in your own project (and for future me in case I forget :) ):
1. Got to Run configurations:
2. Next create a new regular C/C++ Application (1), in the C/C++ Application window place the directive visible on the screenshot below (2), where downloadDebug.cmd is the script you'd like to execute after the build. Tick the "Enable auto build" radio button and select the appropriate build configuration (3).