Using ARM DS-5 IDE with Cortex-M4 of a Colibri iMX7
This article describes how to build, run and debug firmwares for the Cortex-M4 using ARM's DS-5 IDE. The article is based on the Getting Started document of the NXP FreeRTOS BSP (see the doc/ sub-folder of the FreeRTOS source directory).
The article has tested with the following setup:
- 64-Bit Ubuntu 14.04.4 LTS (Trusty Tahr)
- ARM DS-5 v5.24.0
- Colibri Evaluation Board (v3.1a)
- Colibri iMX7S (V1.1A)
- ARM Keil ULINKpro D debug adapter
Arm DS-5 has been superseded by Arm Development Studio.
Connect the Debug Adapter to your host and to the JTAG connector X13 available on the Colibri Evaluation Board. For serial console output, it is recommended to connect UART_A and UART_B to your host:
- UART_A (Linux console): FTDI/USB on X27 or RS232 X25-Bottom
- UART_B (FreeRTOS default output): RS232 X25-Top
Download ARM DS-5 from the official website and install it according to the installation instructions in the provided readme.html file. Especially, note the required 32-bit libs.
Clone the FreeRTOS sources in a directory of your choice, e.g. your home directory:
$ git clone -b colibri-imx7-m4-freertos-v8 https://github.com/toradex/FreeRTOS-Colibri-iMX7
Note that the sources do not need to be within a DS-5 (Eclipse) workspace in order to compile and run the project. In fact, since the FreeRTOS BSP also supports other build systems, it is more appropriate to keep it in a separate folder, not directly related to DS-5.
Import and Build an Example
All examples include project description files (.project/.cproject) for DS-5. The project description files include all necessary source, headers and linker files to build FreeRTOS, middleware (rpmsg) and the application itself.
Start DS-5, create a new work space and click on Go to the workbench on the left menu
Use the File -> Import to import the project.
Choose General -> Existing Projects into Workspace in the Import Dialog and press Next.
Choose an example folder in the "Select root-directory" field e.g.
Select the project and click Finish
There are two project configurations (build targets) supported for each project. In this example we are going to use the Debug target.
- Int Ram Debug – Compiler optimization is set to low, and debug information is generated for the executable. This target should be selected for development and debug.
- Int Ram Release – Compiler optimization is set to high, and debug information is not generated. This target should be selected for final application deployment.
Use the hammer symbol to build the project. It should succeed without errors.
The main build output is the axf-File, which is a elf file binary for the target. DS-5 allows to open the file and shows elf header information.
Debug the Firmware using Hardware Debugging
This part has been tested with an ARM KEIL ULINKpro D debug adapter, but should work with other debug adapters likewise supported by DS-5. Make sure that the DS-5 debug adapter is connected and detected by the operating system:
Bus 004 Device 005: ID c251:2740 Keil Software, Inc.
In DS-5, create a Debug configuration as follows:
Go to Run -> Debug Configurations...
Click on DS-5 Debugger on the Left side and then on the New launch configuration symbol
Give the configuration a sensible name such as "Colibri iMX7 Debug configuration"
Enter i.MX7 in the target search field and select NXP -> i.MX7 SDB -> Bare Metal Debug -> Cortex-M4 (also for FreeRTOS development)
Select ULINKproD as Target Connection
Under Connections, click Browse... and select the target device (if it does not appear, check lsusb and whether the post-install script has been successful executed the udev rules should be in /etc/udev/rules.d/ARM_debug_tools.rules).
To let DS-5 start the Cortex-M4 core, use the Edit button under DTSL Options, switch to the Cortex-M4 tab and select Release Cortex-M4 from reset
In the Files tab, select the application to download using the Workspace... button (browse to the axf file).
In the OS Awareness tab, select FreeRTOS (or None in case you plan to build a bare-metal application). To use FreeRTOS OS Awareness some preprocessor defines need to be configured (see the information in that same tab). Refer to the chapter below how to configure the preprocessor defines.
Click on Apply and then Launch. The IDE will switch into the Debug perspective, connect to the target, download the firmware and reset/start the Cortex-M4 core. The debugger should halt at the main function.
Use F5/F6 to step by source line. To create a breakpoint at a certain location, double click on the left-hand margin.
Configure prepro FreeRTOS OS Awareness
- Go to Projects -> Properties
- Under C/C++ Build -> Settings choose the Preprocessor settings under ARM C Compiler.
- Set the preprocessor defines:
Build a Firmware for Deployment
Switch to the "Int Ram Release" configuration
Build the Release configuration using the hammer symbol
Open a terminal and browse to the build output file (in this example under ~/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/ds5/Int Ram Release)
Use the fromelf utility to create a binary file
~/DS-5_v5.24.0/sw/ARMCompiler5.06u2/bin/fromelf --bin --output=hello_world.bin
Transfer the file to the target e.g. by using a SD card
Use the serial console of U-Boot available on UART_A and type the following commands. With the last command the application should start.
Colibri iMX7 # fatload mmc 0:1 0x7F8000 hello_world.bin reading hello_world.bin 11660 bytes read in 19 ms (598.6 KiB/s) Colibri iMX7 # dcache flush Colibri iMX7 # bootaux 0x7F8000 .## Starting auxiliary core at 0x007F8000 ... Colibri iMX7 #
For the final deployment the firmware should either be stored inside the UBIFS root file system or a static UBI volume. U-Boot commands similar to those used to load the Linux kernel/device tree can be used to load the firmware. Making this sequence as part of the default bootcmd of U-Boot will make sure that the firmware gets started at system boot even before Linux starts.