Search by Tags

Using ARM DS-5 IDE with Cortex-M4 of a Colibri iMX7

 
Applicable for

Article updated at 11 Nov 2019
Compare with Revision




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

Note: Arm DS-5 has been superseded by Arm Development Studio.

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

  • UART_A (Linux console): FTDI/USB on X27 or RS232 X25-Bottom
  • UART_B (FreeRTOS default output): RS232 X25-Top

Installation

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.

Build FreeRTOS

Downloading Source

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.

  1. Start DS-5, create a new work space and click on Go to the workbench on the left menu
  2. Use the File -> Import to import the project.
  3. Choose General -> Existing Projects into Workspace in the Import Dialog and press Next.
  4. Choose an example folder in the "Select root-directory" field e.g.

    ~/freertos-toradex/examples/imx7_colibri_m4/demo_apps/hello_world/ds5
    

    • DS-5 Import

      DS-5 Import

  5. Select the project and click Finish

  6. 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.

    • DS-5 Build Configuration

      DS-5 Build Configuration

  7. Use the hammer symbol to build the project. It should succeed without errors.
  8. 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:

$ lsusb
...
Bus 004 Device 005: ID c251:2740 Keil Software, Inc. 
...

In DS-5, create a Debug configuration as follows:

  1. Go to Run -> Debug Configurations...
  2. Click on DS-5 Debugger on the Left side and then on the New launch configuration symbol


    • DS-5 New Launch Configuration

      DS-5 New Launch Configuration

  3. Give the configuration a sensible name such as "Colibri iMX7 Debug configuration"
  4. Enter i.MX7 in the target search field and select NXP -> i.MX7 SDB -> Bare Metal Debug -> Cortex-M4 (also for FreeRTOS development)
  5. Select ULINKproD as Target Connection
  6. 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).


    • DS-5 Connection Browse

      DS-5 Connection Browse

  7. 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


    • DS-5 Debug and Trace Services Layer

      DS-5 Debug and Trace Services Layer


    • DS-5 Debug Connection - Configuration

      DS-5 Debug Connection - Configuration

  8. In the Files tab, select the application to download using the Workspace... button (browse to the axf file).


    • DS-5 Debug Connection - Files

      DS-5 Debug Connection - Files

  9. 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.

  10. 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.


  • DS-5 Debugging

    DS-5 Debugging


  • DS-5 Debugging and Serial Output

    DS-5 Debugging and Serial Output

Configure prepro FreeRTOS OS Awareness

  1. Go to Projects -> Properties
  2. Under C/C++ Build -> Settings choose the Preprocessor settings under ARM C Compiler.
  3. Set the preprocessor defines:
    • portREMOVE_STATIC_QUALIFIER
    • INCLUDE_xTaskGetIdleTaskHandle
    • configQUEUE_REGISTRY_SIZE=8

  • DS-5 OS Awareness Preprocessor Configuration

    DS-5 Preprocessor Configuration for OS Awareness


  • DS-5 OS Awareness

    DS-5 OS Awareness

Build a Firmware for Deployment

  1. Switch to the "Int Ram Release" configuration
  2. Build the Release configuration using the hammer symbol
  3. 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)
  4. Use the fromelf utility to create a binary file

    ~/DS-5_v5.24.0/sw/ARMCompiler5.06u2/bin/fromelf --bin --output=hello_world.bin
    
  5. Transfer the file to the target e.g. by using a SD card

  6. 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.

Video Demonstration of advanced debugging on Heterogeneous ARM® Cortex