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:
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:
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 git://git.toradex.com/freertos-toradex.git
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.
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.
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.
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:
$ lsusb ... Bus 004 Device 005: ID c251:2740 Keil Software, Inc. ...
In DS-5, create a Debug configuration as follows:
Click on DS-5 Debugger on the Left side and then on the New launch configuration symbol
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.
Use F5/F6 to step by source line. To create a breakpoint at a certain location, double click on the left-hand margin.
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.