As a major Linux fan, I was pleased to find out that ST developed their recently released STM32CubeProgrammer as a cross-platform application. The STM32CubeProgrammer is a convenient tool for flashing firmware onto your STM32 microcontroller, utilizing either an ST-Link debugger interface or the STM32 on-chip bootloader. The goal of this article is to assist you with getting the STM32CubeProgrammer running on your Linux system.
I am the developer and maintainer of the open source OpenBLT bootloader. When working on OpenBLT, I try to work from my Linux machine as much as I can. Fortunately, this has gotten much easier ever since I added support of Atollic TrueSTUDIO to the bootloader demo programs.
When experimenting with and testing out new features in OpenBLT, I often need to quickly flash the bootloader onto the microcontroller. Some of these test programs are built without an IDE, so just GCC for ARM with plain Makefiles. Since the STM32 ST-Link utility is not available under Linux, I resorted to running OpenOCD from the terminal to flash the bootloader onto the microcontroller. Although this solution works, it is far from optimal. I had to interrupt my development work to look-up the correct command-line options for invoking OpenOCD every time I switched microcontroller targets.
Thanks to the STM32CubeProgrammer, I now finally have a quality tool with a convenient user interface for quickly flashing firmware files onto STM32 microcontrollers. The only downside was that it took me a little while to figure out how to get the STM32CubeProgrammer running on my Linux system. Here are step-by-step instructions that will hopefully save you some time.
Start by downloading the installer of the STM32CubeProgrammer from the ST website. You now have the file en.stm32cubeprog.zip. After extracting this zip-archive, you’ll see the installer SetupSTM32CubeProgrammer-1.0.0.linux. You can start the installation either by double-clicking this file from your file manager or by starting it from the terminal. Root privileges are not needed, because STM32CubeProgrammer can install itself into your home directory. From here on, simply follow the instructions from the installation wizard. The default settings work just fine.
After completing the installation, you can start STM32CubeProgrammer by selecting it from the program menu in your desktop environment or by starting it from the terminal. Unfortunately, the chances are high that the program doesn’t start. Here is what I saw after starting STM32CubeProgrammer from the terminal:
voorburg@debian ~/STM32CubeProg/bin $ ./STM32CubeProgrammer
Error: Could not find or load main class com.st.app.Main
Luckily, there is a simple solution to resolve this error by installing some missing dependencies. The STM32CubeProgrammer is developed in Java and based on the JavaFX graphical user interface toolkit library. This means that both OpenJDK and OpenJFX need to be installed on your Linux system. Most Linux distributions install OpenJDK by default, but not OpenJFX. So the secret sauce for getting STM32CubeProgrammer running is to install OpenJFX. Here is how you install OpenJFX on a Debian/Ubuntu system:
sudo apt install openjfx
The approach is similar for other Linux distributions that have a different package manager. On Fedora the package is also called openjfx, on Arch the package is called java-openjfx, and on openSUSE the package is called java-1_8_0-openjfx.
After installing OpenJFX, you’ll see that the STM32CubeProgrammer runs without problems and that you now have access to a great tool for quickly flashing firmware onto your STM32 microcontroller.
If you are interested in a more customizable bootloader solution, compared to the STM32 on-chip bootloader, have a look at the OpenBLT project. By default, it ships with GUI and CLI tools for making firmware updates. Additionally, it comes with a host programming library (LibOpenBLT) that gives you a powerful and easy to use API for quickly building your own firmware update tool.