Using IDEs with TouchGFX
When creating a new TouchGFX project, either through the TouchGFX Designer or STM32CubeMX, the following project files and libraries for using proprietary IDEs are available:
- Keil uVision (Target only)
- IAR Embedded Workbench (Target only)
- STM32CubeIDE (Target only)
- Microsoft Visual Studio (Simulator only)
Note that not all project files are present in your project at the same time. The tool chain selected in STM32CubeMX is the one that will be generated, by default STM32CubeIDE is selected.
Further reading
In addition makefiles and libraries for shell-based compilation with a GCC cross compiler for ARM targets are also provided. This article will help you configure third-party GCC-based IDEs for TouchGFX application development. Basically any IDE which is able to invoke the GCC cross compiler should be useable.
Note
This article will describe two different approaches to getting TouchGFX to work with other IDEs. One approach is to invoke the TouchGFX Makefile from within the IDE. This is probably the easiest approach, but is not always desirable if you want to have more control over the compilation process and file locations. Alternatively you can manually add the necessary TouchGFX files and configuration options to your existing project.
Prerequisite: GCC version
This article assumes that you will use either the GCC cross compiler toolchain distributed with the TouchGFX environment shell, or alternatively your own GCC toolchain of a flavor that is able to link with the TouchGFX core library compiled using the environment shell toolchain.
The GCC compiler used:
$ arm-none-eabi-gcc.exe -v
Target: arm-none-eabi
Thread model: single
gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)
The compiler can be obtained from https://launchpad.net/gcc-arm-embedded.
Invoke TouchGFX Makefile from IDE
A hopefully quick-and-dirty way of compiling TouchGFX applications from within your IDE is to simply invoke the Makefile included in the projects created by the TouchGFX Designer. To use the TouchGFX environment shell to compile an application for target, you must navigate to the TouchGFX application root directory and execute the following command:
$ make -f gcc/Makefile
Now, instead of invoking the make command from the TouchGFX environment shell, it is also possible to invoke it from within your IDE. The executables used by the shell (make, arm-none-eabi-gcc, ..) are actually normal Windows x86 executables, so the make application can be executed by a normal command prompt, provided that the following environment variables have been configured.
C:\TouchGFX\4.18.0\env\MinGW\bin
C:\TouchGFX\4.18.0\env\MinGW\msys\1.0\Ruby30-x64\bin
C:\TouchGFX\4.18.0\env\MinGW\msys\1.0\bin
C:\TouchGFX\4.18.0\env\MinGW\msys\1.0\gnu-arm-gcc\bin
After setting up the needed Windows environment variables it is now possible to invoke the make
command on the appropriate TouchGFX makefile directly from within your IDE. The exact command you need to execute is the same as when compiling from the shell, namely:
$ make -f gcc/Makefile
Note
Add TouchGFX code files to your own project
If you instead wish to have more control over the build process and file locations, you can instead integrate the relevant TouchGFX code files into your own existing project, and add the necessary include paths and compiler switches in order to make it compile.
Required files
Basically you will need to add the same TouchGFX files to your IDE project as are compiled when building with make from the TouchGFX environment shell. Exactly which files to include depend on your target board, since the low-level drivers are different for each board. In order to determine what files you need, the recommended approach is to simply try compiling the application using the TouchGFX environment shell for the appropriate board. The compilation process will mention each file being compiled, thereby giving you a list of exactly the files you need to add.
Include paths
You will need to add the following include paths to your compilation:
.../TouchGFX/gui/include
.../TouchGFX/generated/gui_generated/include
.../TouchGFX/platform/os
.../TouchGFX/generated/fonts/include
.../TouchGFX/generated/images/include
.../TouchGFX/generated/texts/include
.../TouchGFX/generated/videos/include
.../Middlewares/ST/touchgfx/framework/include
Tip
gcc/Makefile
for this information.Compiler switches
Like with include paths, there are some generic compiler switches which must be enabled, and also some that are specific for the processor core and concrete board. The compiler switches used to compile the TouchGFX core library are listed below, for each core. Some of these options will be mandatory for the compilation of your code as well in order for the linker to work, and some are optional. Those that are known to be mandatory are marked in bold.
Cortex-M0 cores
-fno-rtti -fno-exceptions -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mcpu=cortex-m0plus -D__irq="" -mthumb -mno-thumb-interwork -std=c99 -Os -fno-strict-aliasing -fdata-sections -ffunction-sections -Wno-psabi -DCORE_M0PLUS
Cortex-M4f cores
-fno-rtti -fno-exceptions -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mcpu=cortex-m4 -D__irq="" -mthumb -mno-thumb-interwork -std=c99 -Os -fno-strict-aliasing -fdata-sections -ffunction-sections -Wno-psabi -DCORE_M4 -march=armv7e-m
Cortex-M7 cores
-fno-rtti -fno-exceptions -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mcpu=cortex-m7 -D__irq="" -mthumb -mno-thumb-interwork -std=c99 -Os -fno-strict-aliasing -fdata-sections -ffunction-sections -Wno-psabi -DCORE_M7
Cortex-M33 cores
-fno-rtti -fno-exceptions -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mcpu=cortex-m33 -D__irq="" -mthumb -mno-thumb-interwork -std=c99 -Os -fno-strict-aliasing -fdata-sections -ffunction-sections -Wno-psabi -DCORE_M33
Linker
Core library
You must link with the TouchGFX core library. Depending on your MCU, this would be either
.../Middlewares/ST/touchgfx/lib/core/cortex-m0/gcc/libtouchgfx.a
.../Middlewares/ST/touchgfx/lib/core/cortex-m4f/gcc/libtouchgfx.a
.../Middlewares/ST/touchgfx/lib/core/cortex-m7/gcc/libtouchgfx.a
.../Middlewares/ST/touchgfx/lib/core/cortex-m33/gcc/libtouchgfx.a
Linker options
In addition, you will need a few linker options. The following options are what TouchGFX uses:
Cortex-M0: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m0plus -Wno-psabi -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
Cortex-M4f: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m4 -march=armv7e-m -Wno-psabi -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
Cortex-M7: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m7 -Wno-psabi -mfpu=fpv5-sp-d16 -mfloat-abi=softfp
Cortex-M33: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m33 -Wno-psabi -mfpu=fpv5-sp-d16 -mfloat-abi=softfp
Asset generation
To compile a project, assets must be generated as well. This can be done either by invoking the generated Makefile with the option 'assets':
make -f TouchGFX/simulator/gcc/Makefile assets
Another way to generate assets, is to use the image-, text/font- and video-converter directly.
Imageconverter
The imageconverter can be found in your projects touchgfx folder Middlewares/ST/touchgfx/framework/tools/imageconvert/build
built for Linux and Windows.
usage: imageconvert [-c configfile] [-f inputfile -o outputfile | -r inputdir -w outputdir]
When calling the imageconvert.out executable, it will look for a configfile (application.config
) file in the folder it is called from.
Textconverter
The textconverter can be found in your projects touchgfx folder Middlewares/ST/touchgfx/framework/tools/textconvert
as a ruby file: main.rb
.
usage: main.rb file.xml path/to/fontconvert.out path/to/fonts_output_dir path/to/localization_output_dir path/to/font/asset calling_path
Videoconverter
The videoconverter can be found in your projects touchgfx folder Middlewares/ST/touchgfx/framework/tools/videoconvert
as a ruby file: videoconvert.rb
.
usage: videoconvert.rb path/to/project_root_dir path/to/video_assets_dir path/to/generated_output_dir
Flashing and debugging
Depending on your linker settings, you will most likely get an .elf
or .hex
file produced as output. It is possible to deploy and debug TouchGFX applications from within most IDEs, typically using a GDB server, or whichever other approach your IDE provides. Concrete pointers for each available IDE cannot be provided, but you might find inspiration in the Compiling & Flashing article, which explains how to flash a board with a GCC-produced ELF/HEX file.