Skip to main content

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
How to change the tool chain is described here.

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
Please note that this article describes only the setup procedure in general terms - support for all the various IDEs cannot be provided, but hopefully the information presented here is sufficient for you to use TouchGFX with your favorite IDE.

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 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437] (GNU Tools for ARM Embedded Processors 6-2017-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 folder and execute the following command:

$ make -f target/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:\<touchfx_installation_directory>\touchgfx\env\MinGW\bin
C:\<touchfx_installation_directory>\touchgfx\env\MinGW\msys\1.0\Ruby193\bin
C:\<touchfx_installation_directory>\touchgfx\env\MinGW\msys\1.0\bin
C:\<touchfx_installation_directory>\touchgfx\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 target/gcc/Makefile
Note
Please note that your current directory must be the root directory of the application you want to compile.

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 (here mentioned relative to the directory where you have unpacked TouchGFX):

<touchgfx_application_root_directory>/gui/include
<touchgfx_application_root_directory>/generated/gui_generated/include
<touchgfx_application_root_directory>/platform/os
<touchgfx_application_root_directory>/generated/fonts/include
<touchgfx_application_root_directory>/generated/images/include
<touchgfx_application_root_directory>/generated/texts/include
<touchgfx_application_root_directory>/touchgfx/framework/include
Tip
In addition to the above include paths, you also need to add include paths for the board specific code. Take a look in the target/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-M3 cores

-mcpu=cortex-m3 -march=armv7-m -Wno-psabi -DCORE_M3 -D__irq="" -fno-rtti -fno-exceptions -fno-strict-aliasing -fdata-sections -ffunction-sections

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

Linker

Core library

You must link with the TouchGFX core library. Depending on your MCU, this would be either

touchgfx/lib/core/cortex-m4f/gcc/libtouchgfx.a
touchgfx/lib/core/cortex-m7/gcc/libtouchgfx.a

Linker options

In addition, you will need a few linker options. The following options are what TouchGFX uses:

Cortex-M4f: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m4 -march=armv7e-m -Wno-psabi
Cortex-M7: -Wl,-static -nostartfiles -mthumb -mno-thumb-interwork -fno-exceptions -fno-rtti -Wl,--gc-sections -mcpu=cortex-m7 -Wno-psabi

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 <path_to_Makefile> assets

Another way to generate assets, is to use the imageconverter and text/font-converter directly.

Imageconverter The imageconverter can be found in your projects touchgfx folder 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 touchgfx\framework\tools\textconvert as a ruby file: main.rb.

usage: main.rb file.xlsx path/to/fontconvert.out path/to/fonts_output_dir path/to/localization_output_dir path/to/font/asset calling_path

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.