In the TouchGFX distribution we provide project files and libraries for using the two proprietary IDEs Keil uVision and IAR Embedded Workbench. In addition we also provide makefiles and libraries for shell-based compilation with a GCC cross compiler for ARM targets. 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.
Please note that this article describes only the setup procedure in general terms - we are not able to provide support for all the various IDEs, 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 we use is:
$ 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 we use is obtained from https://launchpad.net/gcc-arm-embedded.
Method 1: 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 an example application and execute the following command:
$ cd /c/TouchGFXProjects/MyApplication
$ make -f target/gcc/Makefile
Now, instead of invoking the make command from the TouchGFX environment shell, we want 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 some environment variables are configured. The process of configuring your environment variables are described in detail here: Generating assets from within IAR and Keil. That article explains how to call the makefile from a Windows Command Shell.
After setting up the needed Windows environment variables you should be able 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
Please note that your current directory must be the root directory of the application you want to compile.
Method 2: 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.
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.
You will need to add the following include paths to your compilation (here mentioned relative to the directory where you have unpacked TouchGFX):
yourapp/gui/include yourapp/platform/os yourapp/generated/fonts/include yourapp/generated/images/include yourapp/generated/texts/include yourapp/touchgfx/framework/include
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.
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.
-mcpu=cortex-m3 -march=armv7-m -Wno-psabi -DCORE_M3 -D__irq="" -fno-rtti -fno-exceptions -fno-strict-aliasing -fdata-sections -ffunction-sections
-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
-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
You must link with the TouchGFX core library. Depending on your MCU, this would be either
In addition, you will need a few linker options. The following options are what we use:
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
Even when using “Method 2”, it might still be desirable to invoke the TouchGFX makefile as a pre-build step in order to generate assets. This way, you will automatically get the image, font, and text converters run when your assets change. In order to make your IDE able to generate assets, please follow the steps in this article again: Generating assets from within IAR and Keil
Flashing and debugging
Depending on your linker settings, you will most likely get an .ELF 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. We are not able to provide concrete pointers for each available IDE, but you might find inspiration in the Deploying your application section of the knowledge base, which explains how to flash a board with a GCC-produced ELF/HEX file.