Skip to main content
BarryWhit
Lead
June 27, 2024
Question

HOWTO: Download programs 30x faster to STM32 from STM32CubeIDE

  • June 27, 2024
  • 2 replies
  • 3134 views

I recently started a thread called

Why is programming flash with STM32CubeIDE so much slower than with Cube32Programmer? 

Hoping to spur ST to make improvements in this area. Are you sick of 

 

run0.jpg

...crawling its way to completion 50 times a day, like I am?

 

If you need to start a debug session in CubeIDE, I'm afraid I don't have any good news for you.

But, if you want to download a new release version of the design, so you can see a LED blink, talk to it over

a UART, see it enumerate over USB etc, prepare to be amazed.

 

The solution is simple. First, install the standalone STM32CubeProgrammer.

Once installed, you will find that the installation dieectory also includes a CLI version. This is is neither java based, nor does it rely on establishing a debug monitor on the board, so it is very fast. On my STM32G4, downloading a simple "Hello World"  example to my chip with this CLI takes a fraction of a second from launch to completion (the GUI version is similarly fast compared to CubeIDE and probably just launches the CLI in the background).

If you use an st-link, the command you need:

 

 

 

 

<STM32Cube>\STM32CubeProgrammer\bin>STM32_Programmer_CLI.exe -c port=SWD -d PATH_TO_ELF_FILE -rst

 

 

This connects to your ST-LINK, downloads the program, and does a reset.

You can get fancier if you need to, the tool accepts various arguments, but to get started, this is all you need.

 

Now, you can create create a batch/shell script for your project which launches a specific binary. test that script in the command line to make sure it works.

Then, in CubeIDE go to run/Run Configurations, and create a new "C/C++ Application" (NOT a "STM32 C/C++ Application", as that launches the GDB based downloader), and choose your shell script as the program.

Choose your desired project/build type. Whenever you make changes, the associated build will be triggered and will generate a new elf binary for download.

 

That's it, now you can lunch your shell script as a run target. It will compile the project if necessary, and download it to your chip in the blink of an eye. No more "Waiting... Waiting...... Waiting.......................".

 

P.S.

You can instead use the programmer cli binary file as the executable program for the run target, and setup the command line arguments as part of the run target config. 

 

run1.jpg

run2.jpg

This topic has been closed for replies.

2 replies

Associate II
June 28, 2024

Thanks for the tutorial!

Most of the times I am debugging, but when the firmware is already in a "stable state", but I am still developing it, this seems to be appropriate to use in terms of time saving.

I'll give it a try.

BarryWhit
BarryWhitAuthor
Lead
June 29, 2024

[Sorry. Moved to other thread]

"- If someone's post helped resolve your issue, please thank them by clicking ""Accept as Solution"".- Please post an update with details once you've solved your issue. Your experience may help others."