Note: The methods described in this article apply to binaries that have been built using GCC, and to IAR/ Keil projects that do not offer built-in flash loader support (See the table in Overview: Boards And Flash Loaders).
ST provides a Windows based utility, ST-Link, for flashing the internal and external flash of STM32 based boards. This section applies to the following ST boards supported by TouchGFX:
For each board that lacks flash loader support for the external flash in it’s IAR and/or Keil project, an ST-Link compatible binary is produced:
- For IAR projects, additional output is converted (
intel extendedformat) to
- For Keil projects that do not have internal Flash loader support, the following post-build step is executed:
fromelf --only=ExtFlashSection --bin --output=binary .\Objects\keil5-2.axf, resulting in the binary
The process described in this article outlines how to use the ST-Link utility to program the internal and external flash of these boards. For the internal flash, ST-Link will automatically detect the type of device connected. The external flashloader, however, must be configured manually as we’ll see. ST-Link offers support for every flash chip found on boards supported by TouchGFX. When choosing which binaries to program, you have three options:
- Program internal flash only (
intflash.hexproduced by gcc builds)
- Program external flash only (
extflash.binproduced by gcc builds, or binaries produced by IAR/Keil as mentioned above)
- Program both internal and external flash (
target.hexproduced by gcc builds)
You have two options when it comes to programming either of the supported ST boards. Each have their own section:
1. ST-Link GUI: Requires manual configuration of external flash loader, but works with binaries from both IAR, Keil and gcc.
2. ST-Link CLI: No configuration of external flash loader required. Only works with gcc.
Flash using ST-Link GUI
Opening either binary file in ST-Link will automatically detect the memory ranges to program and select a suitable flashloaders to use, if so configured. In the example below,
target.hex for an application was opened in ST-Link and ranges from both internal and external flash were detected.
[target.hex] opened successfully. Address Ranges [0x08000000 0x08010364] [0x90000000 0x9000CA28]
As mentioned previously, the internal flash is always recognized by ST-Link for STM32 MCUs, but the flash loader for ranges starting at 0x90000000 must be configured manually. In the example below, we’ll configure the external flash for the
- Select “Add External Loader” from the “External Loader” menu.
- Select the appropriate flashloader in the list of supported boards (i.e.
STM32F746G-DISCO) and select Validate.
- Open the binary you wish to flash: The address ranges are automatically detected by ST-Link. As previously mentioned, different binaries are produced by IAR, Keil and gcc, respectively, and can be used by ST-Link.
- Select “Program” from the “Target” menu, and initiate the download.
The following is a complete list of external flashloaders to use for ST boards supported by TouchGFX (ST-Link version 3.9):
|STM32F429I-DISCO||Internal flash only|
make (ST-Link CLI)
Additionally, you can build and flash an application (using ST-Link CLI) through any
app/example/button_example/target/ST/STM32F746G-DISCO/gcc/Makefile) using the following command:
$ make flash
The makefile knows which external flash (refer to table above) to use for each of the supported ST boards. ST-LINK has built in support for the internal flash for each board and you can flash just the internal flash by using the following command:
$ make intflash
You may, on occasion, be unable to program your board using the above method, due to the following error:
STLink USB communication error Error during erase operation.
In this event, you may try to disable the USB device driver for that particular board in Windows Device Manager to fix the issue.