Skip to main content
Version: 4.16

Compiling & Flashing

This section describes how to go from TouchGFX application code to executing program, that is how to compile and flash in a specific setup.

Compiling TouchGFX Applications#

When compiling a TouchGFX application, there are two options; compiling for the PC simulator or compiling for the target hardware.

Compiling for PC Simulator#

There are two options for compiling projects for the PC Simulator; GCC and Visual Studio.
Both of these options are always available, since they are generated by TouchGFX Designer.

GCC#

The makefile is located at <touchgfx_application_root_folder>/simulator/gcc/Makefile

TouchGFX includes a MinGW environment, that comes preinstalled with a GCC compiler and GNU Make, making it easy to execute the generated Makefile for the PC simulator.

The TouchGFX Environment can be launched either from <touchgfx_installation_directory>/env/MinGW/msys/1.0/msys.bat or from the shortcut added to the Windows start menu, named "TouchGFX x.y.z Environment" where x, y and z describe the version number.

After launching the TouchGFX Environment and navigating to the TouchGFX Application root folder, the simple command below can be executed to produce a simulator.exe file.

make -f simulator/gcc/Makefile

The simulator executable can then be launched from the TouchGFX Environment with the following command.

./build/bin/simulator.exe

The PC Simulator can also be compiled and launched from TouchGFX Designer, by using the Run Simulator command.

Visual Studio#

To compile the PC Simulator using Visual Studio, simply open the generated solution file located at <touchgfx_application_root_folder>/simulator/msvs/Application.sln using Visual Studio.

The PC Simulator can be launched directly from Visual Studio, enabling code debugging.

Note
Before being able to compile with GCC or Visual Studio, Run the Generate command from TouchGFX Designer.

Compiling for Target Hardware#

Compiling projects for STM32 Evaluation Kits is quite simple for Application Template based applications.

Each application template contains project files for GCC, CubeIDE, IAR and Keil:

  • GCC: <project_root_folder>/gcc/MakeFile
  • CubeIDE: <project_root_folder>/STM32CubeIDE/.cproject
  • IAR: <project_root_folder>/EWARM/Project.eww
  • Keil: <project_root_folder>/MDK-ARM/<STM32_evaluation_kit_name>.uvprojx

The active tool chain is set from CubeMX and is set to CubeIDE by default. Please note that all project files are not present at the same time. The generated project file depends on the selected tool chain in CubeMX

TouchGFX includes a MinGW environment, that comes preinstalled with the GNU Embedded Toolchain for Arm and GNU Make, making it easy to execute the included Makefile for the target hardware.

The TouchGFX Environment can be launched either from <touchgfx_installation_directory>/env/MinGW/msys/1.0/msys.bat or from the shortcut added to the Windows start menu "TouchGFX x.y.z Environment"

After launching the TouchGFX Environment and navigating to the project root folder, the simple command below can be executed to compile the project for the target hardware.

make -f gcc/Makefile
Note
Before being able to compile with GCC, CubeIDE, IAR or Keil, run the Generate command from TouchGFX Designer.

Flashing STM32 Evaluation Kits#

Flashing projects to STM32 Evaluation Kits is quite simple with projects based on a premade Application Template.

Each project, when built, produces a binary that can be flashed by either ST Link Utility or Cube Programmer

Therefore these tools must be installed to proceed with flashing.

It is suggested to install these tools to their default location.

  • ST Link Utility default install location:
    C:/Program Files (x86)/STMicroelectronics/STM32 ST-LINK Utility/ST-LINK Utility
  • Cube Programmer default install location:
    C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer
Note
The Application Templates do not provide any flash loaders for flashing directly from within IAR, Keil, CubeIDE or other IDEs.

GCC & TouchGFX Designer#

The Makefile included with an Application Template located at <project_root_folder>/gcc/MakeFile has a built-in flash command, as shown below, that uses either ST Link Utility or Cube Programmer (depending on the AT) to flash the STM32 Evaluation Kit. You can of course also use the desktop version of the flash tools to flash the boards with the generated .hex files.

make -f gcc/Makefile flash

The .hex file is located at <project_root_folder>/TouchGFX/build/bin/target.hex

It is also possible to only write to the internal flash and thus skipping the external part. This can reduce the flash time considerably if you have a large set of images. However, you need to be sure that the content for the external flash has not changed since you wrote the external flash last time. If it has, and you do not reflash it, you will see strange behaviour. In this case reflash both the internal and external flash.

make -f gcc/Makefile intflash

The .hex file is located at <project_root_folder>/TouchGFX/build/bin/inttarget.hex

The Application Template also provides the configuration for TouchGFX Designer to be able to flash projects via the Run Target Command. The command used by TouchGFX Designer to flash can be seen and overridden in the Build Section of the Config View in TouchGFX Designer.

CubeIDE#

Application Templates provide support for flashing project compiled with CubeIDE, by using the .elf file output by CubeIDE, with the Cube Programmer.

The .elf file is located at <project_root_folder>/STM32CubeIDE/Debug/<STM32_evaluation_kit_name>.elf

e.g. C:/TouchGFXProjects/MyApplication/STM32CubeIDE/Debug/STM32F746G_DISCO.elf

IAR#

The Application Templates provide support for flashing project compiled with IAR, by using the .hex file output by IAR, with the Cube Programmer.

The .hex file is located at <project_root_folder>/EWARM/<STM32_evaluation_kit_name>/Exe/<STM32_evaluation_kit_name>.hex

e.g. C:/TouchGFXProjects/MyApplication/MDK-ARM/STM32F469I-DISCO/STM32F469I-DISCO.hex

Keil#

The Application Templates provide support for flashing project compiled with Keil, by using the .hex file output by Keil, with the Cube Programmer.

The .hex file is located at <project_root_folder>/MDK-ARM/<STM32_evaluation_kit_name>/<STM32_evaluation_kit_name>.hex

e.g. C:/TouchGFXProjects/MyApplication/MDK-ARM/STM32F469I-DISCO/STM32F469I-DISCO.hex

Flashing Custom Hardware#

If instead what needs to be flashed is custom hardware, and not a predefined hardware setup like an STM32 Evaluation Kit, you can still use STM32CubeProgrammer. STM32CubeProgrammer does not necessarily come with a flash loading mechanism for your specific external memory. It is however possible to create a custom flash loader. Read the user manual on developing customized loaders for your external memory to find more info.