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.
Join the DZone community and get the full member experience.
Join For FreeCommand 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:
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
- Eclipse based IDE (e.g. Kinetis Design Studio V3.2.0) for ARM Development.
- GCC ARM Embedded Toolchain (launchpad) toolchain (included in KDS).
- GNU ARM Eclipse plugins (included in KDS).
- BSP with FreeRTOS for i.MX (e.g. from Toradex or from my GitHub).
Project Creation
Create a new C/C++ project with the wizard, with the standard settings:
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:
In the Optimization settings that the following are turned on:
- -ffunction-section
- -fdata-sections
- -ffreestanding
- -fno-builtin
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.
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
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"
The path to linker file is specified with the -L option:
"${ProjDirPath}/../../../../../platform/devices/MCIMX7D/linker/gcc"
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.
Back in the Tool Settings, specify to create a 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).
Enjoy!
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
Merge GraphQL Schemas Using Apollo Server and Koa
-
Alpha Testing Tutorial: A Comprehensive Guide With Best Practices
-
Knowing and Valuing Apache Kafka’s ISR (In-Sync Replicas)
-
How To Use Geo-Partitioning to Comply With Data Regulations and Deliver Low Latency Globally
Comments