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. Example IDEs include Eclipse, Raissonance, TrueSTUDIO, Rowley Crossworks and LPCXPresso.
Please note that this article describes only the setup procedure in general terms - we are not able to provide support for all the various toolchains, but hopefully the information presented here is sufficient for you to get it up and running.
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 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 227977] (GNU Tools for ARM Embedded Processors)
The compiler we use is obtained from https://launchpad.net/gcc-arm-embedded. In our experience, pretty much any GCC 4.x ARM cross-compiler should be compatible, however.
Furthermore, in able to successfully link with our core library, you must use compatible compiler switches. These are detailed later in this article.
- In case you wish to use a non-compatible compiler or compiler switches, you have the option of obtaining a full source code license of TouchGFX
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 we distribute with each of the example applications and the empty template project. There are Makefiles for all the supported evaluation boards, for each example application. Recall that in order to use the TouchGFX environment shell to compile an application for target, you must navigate to an example application and execute the following command:
$ make -f target/<vendor>/<board>/gcc/Makefile
Where vendor and board points out your target board.
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 standard windows x86 executables, so the make process 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: https://touchgfx.zendesk.com/hc/en-us/articles/204765032. This article explains how to call the makefile from within IAR or Keil, but should hopefully provide enough information to be applicable in other IDEs.
After this 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/<vendor>/<board>/gcc/Makefile
Please note that your current directory must be within 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 will be 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):
app/yourapp/gui/include app/yourapp/platform/os app/yourapp/generated/fonts/include app/yourapp/generated/images/include app/yourapp/generated/texts/include touchgfx/framework/include
In addition to the above include paths, you also need to add include paths for the board specific code. To see exactly what board specific include paths you need, look in the appropriate options.mk file for your board, located here:
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 and textconverters run when your assets change. In order to make your IDE able to generate assets, please follow the steps in this article: https://touchgfx.zendesk.com/hc/en-us/articles/204765032
Deploying 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 program the individual boards with a GCC-produced ELF/HEX file.