Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Building FreeRTOS Apps for the ARM Cortex-M4 on i.MX7 With Eclipse

DZone's Guide to

Building FreeRTOS Apps for the ARM Cortex-M4 on i.MX7 With Eclipse

Instead spending lots of money with commercial IDEs, it is possible to build FreeRTOS applications for the ARM Cortex-M4 on the NXP i.MX with free, open source tools.

· IoT Zone
Free Resource

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

Outline

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 also very expensive. 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. Time to change this.

In this tutorial, I'm using KDS V3.2.0, which uses the GNU ARM Eclipse plugins and the GCC ARM Embedded (launchpad) tools. The cool thing is, because 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 project (and others) can be found on my GitHub site.

Prerequisites

Project Creation

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

Creating Default Project with Eclipse

Creating Default Projects with Eclipse

Files

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

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

Compiler

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

CPU_MCIMX7D_M4
__DEBUG

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 paste the paths below:

${ProjDirPath}/../../../../../examples/imx7_colibri_m4/demo_apps/hello_world
${ProjDirPath}/../../../../../examples/imx7_colibri_m4
${ProjDirPath}/../../../../../platform/CMSIS/Include
${ProjDirPath}/../../../../../platform/devices
${ProjDirPath}/../../../../../platform/devices/MCIMX7D/startup
${ProjDirPath}/../../../../../platform/devices/MCIMX7D/include
${ProjDirPath}/../../../../../platform/drivers/inc
${ProjDirPath}/../../../../../platform/utilities/inc
${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/include
${ProjDirPath}/../../../../../rtos/FreeRTOS/Source/portable/GCC/ARM_CM4F
Include Paths

Include Paths

Linker

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)):

"MCIMX7D_M4_tcm.ld"
GNU Linker File

GNU Linker File

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

"${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc"
Path to Linker File

Path to Linker File

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

nano-library

Nano-library

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

Building

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!

Topics:
freertos ,arm cortex-m ,ide ,iot

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}