Tutorial: Building FreeRTOS Applications for ARM Cortex-M4 on i.MX7 with Eclipse

Command line tools to build applications are great. But productivity goes up if I can use the standard Eclipse environment with GNU tools. This tutorial is about how to use standard and free GNU and Eclipse tools to build my FreeRTOS application for the ARM Cortex-M4 on i.MX7 πŸ™‚ :

Eclipse used to build FreeRTOS applications for M4 on i.MX7

Eclipse used to build FreeRTOS applications for M4 on i.MX7


In my earlier article (see “Tutorial: Running FreeRTOS on NXP i.MX7Dual Cortex-M4F“) I used cmake, cygwin and the ARM Launchpad GNU toolchain to build a demo application. That’s fine, but to be really productive, an IDE like Eclipse is preferred. NXP and Toradex offer some examples for IAR Embedded Workbench and ARM DS-5. The IAR IDE and toolchain is proprietary (not Eclipse) and expensive (there is a free 32k Byte version). On the other side the ARM DS-5 is Eclipse based, but very expensive too. NXP offers the unlimited and free-of-charge Eclipse based Kinetis Design Studio (KDS), but for unknown reasons NXP does not provide any example projects with it for the i.MX parts :-(: so you either have to spend a lot of money or to use command line tools only. Time to change this πŸ™‚

I’m using in this tutorial KDS V3.2.0 which uses the GNU ARM Eclipse plugins and the GCC ARM Embedded (launchpad) tools. The cool thing is, because that KDS is using standard components, I can build such an IDE with the toolchain and plugins myself (see “Going to Mars: Building a DIY Eclipse IDE for ARM Embedded Microcontrollers“).

I’m showing the required project settings in the next steps for the ‘hello world’ project. This (and other) project can be found on my GitHub site: https://github.com/ErichStyger/freertos-toradex/tree/colibri-imx7-m4-freertos-v8/examples/imx7_colibri_m4/demo_apps/hello_world/kds


Project Creation

Create a new C/C++ project with the wizard, with the standard settings:

Creating Default Project with Eclipse

Creating Default Project with Eclipse


Add FreeRTOS and application files to the project. Below shows the files for the ‘hello world’ demo application where I’m using Eclipse Virtual Groups and linked files. But of course you can copy the files too.

Application and FreeRTOS Files

Application and FreeRTOS Files

Project Settings

In the project settings, configure the Target Processor as ARM Cortex-M4 with hardware floating point unit:

Target Processor Settings

Target Processor Settings

In the Optimization settings that the following are turned on:

  • -ffunction-section
  • -fdata-sections
  • -ffreestanding
  • -fno-builtin
Optimization Settings

Optimization Settings


In the compiler preprocessor settings, have the two following defines added:


For a ‘release’ build you can use __NDEBUG instead of __DEBUG.

Preprocessor Settings

Preprocessor Settings

In order for the compiler to find the header files, specify all the paths needed. How they are specified depends on how your organize the source files. For the ‘hello world’ demo I’m using relative paths to the project directory ({$ProjDirPath}). You can copy and past the paths below:

Include Paths

Include Paths


In the linker setting, specify the linker file to be used with the -T option (I’m using below the one using the tightly coupled memory (TCM)):

GNU Linker File

GNU Linker File

The path to linker file is specified with the -L option:

Path to Linker File

Path to Linker File

Use the newlib-nano library with the nosys option (–specs=nosys.specs):



Binary File

With u-boot we load a bin (binary) file. To create it, enable ‘Create Flash Image’ under the Toolchains tab. Press the ‘Apply’ button.

Create Flash Image

Create Flash Image

Back in the Tool Settings, specify to create a raw binary file:

Raw Binary File

Raw Binary File


Build it, and you should get the binary file you can load with u-boot (see Tutorial: Running FreeRTOS on NXP i.MX7Dual Cortex-M4F).

Binary File Created

Binary File Created

Enjoy πŸ™‚


Instead spending lots of money with commercial IDE’s, it is possible to build FreeRTOS applications for the ARM Cortex-M4 on the NXP i.MX with free-of-charge open source tools. All what it requires is a basic project setup and is easily done with the GNU ARM Eclipse plugins used in this article.

You can find everything on the following GitHub repository: https://github.com/ErichStyger/freertos-toradex

Happy Eclipsing πŸ™‚




15 thoughts on “Tutorial: Building FreeRTOS Applications for ARM Cortex-M4 on i.MX7 with Eclipse

  1. IDE is a good step forward ! Nice work :). But what about debugging ? I heard that Keil DS-5 have this function but unfortunately not include into free community edition. Also Viola and Iris carries board do not embed JTAG or SWD connectors. Do you have trick in mind ?


    • Still working on debugging. I have a SABRE board which has the debug connector on it. I will need a full eval board from Toradex which has the debug connector on it too. A trick would be to make my own debug adapter on the bottom side of the module (I already found that spring connector to the pins on the backside of the Colibri module).


  2. Theres a JTAG port on these modules but according to the datasheet its on PCB testpoints and connects using POGO pins on a carrier board. would be great if the jtag port would allow connection to the M4 as easy as it is to connect and to any Kinetis device. Is the M4 in the JTAG chain?


  3. Hi,

    I followed all the steps above but I’m getting this linker error:
    Building target: m4_on_imx.elf
    Invoking: Cross ARM C Linker
    arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-builtin -g3 -T MCIMX7D_M4_tcm.ld -Xlinker –gc-sections -LC:\Users\gador\Documents\test\m4_on_imx\platform\devices\MCIMX7D\linker\gcc -Wl,-Map,”m4_on_imx.map” –specs=nano.specs –specs=nosys.specs -o “m4_on_imx.elf” ./rtos/FreeRTOS/Source/portable/MemMang/heap_1.o ./rtos/FreeRTOS/Source/portable/MemMang/heap_2.o ./rtos/FreeRTOS/Source/portable/MemMang/heap_3.o ./rtos/FreeRTOS/Source/portable/MemMang/heap_4.o ./rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.o ./rtos/FreeRTOS/Source/croutine.o ./rtos/FreeRTOS/Source/event_groups.o ./rtos/FreeRTOS/Source/list.o ./rtos/FreeRTOS/Source/queue.o ./rtos/FreeRTOS/Source/tasks.o ./rtos/FreeRTOS/Source/timers.o ./platform/utilities/src/debug_console_imx.o ./platform/utilities/src/print_scan.o ./platform/drivers/src/adc_imx7d.o ./platform/drivers/src/ccm_analog_imx7d.o ./platform/drivers/src/ccm_imx7d.o ./platform/drivers/src/ecspi.o ./platform/drivers/src/flexcan.o ./platform/drivers/src/gpio_imx.o ./platform/drivers/src/gpt.o ./platform/drivers/src/i2c_imx.o ./platform/drivers/src/mu_imx.o ./platform/drivers/src/rdc.o ./platform/drivers/src/rdc_semaphore.o ./platform/drivers/src/sema4.o ./platform/drivers/src/uart_imx.o ./platform/drivers/src/wdog_imx.o ./platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.o ./platform/devices/MCIMX7D/startup/system_MCIMX7D_M4.o ./examples/imx7_colibri_m4/board.o ./examples/imx7_colibri_m4/clock_freq.o ./examples/imx7_colibri_m4/gpio_pins.o ./examples/imx7_colibri_m4/pin_mux.o ./hardware_init.o ./main.o
    c:/freescale/kds_v3/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file MCIMX7D_M4_tcm.ld: No such file or directory
    collect2.exe: error: ld returned 1 exit status
    makefile:49: recipe for target ‘m4_on_imx.elf’ failed
    make: *** [m4_on_imx.elf] Error 1

    Could you help me out?


  4. can you show me the set up for the right toolchains from KDS itself when creating the project, because I get an error ” arm-none-eabi-gcc not found in PATH” using toolchains at /opt/Freescale/KDS_v3/toolchain/


    • No need to setup any tool chain, that toolchain is included in KDS already. Generate a project as shown in the article, and things are correctly setup. Your message indicates that you have not used the KDS project wizard to create the project?


      • So sorry for late reply, but I’ve figured it out. Thank for the help. But now I am facing a new problem. I try to use this tutorial for UDOO neo Full which uses imX6solox. So I use FREE RTOS for imx6x, but there is some error in port.c file. the error message show : ../source/rtos/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c:263:7: error: expected ‘(‘ before ‘void’
        __asm void vPortSVCHandler( void )

        any idea why some of the assembly code isn’t successfully compiled?


What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s