C

Getting started on NXP

Overview

This topic provides all the necessary information to get started on the NXP platforms supported by Qt Quick Ultralite.

Note: Make sure you have all the prerequisites installed before setting up the development environment.

Setting up the development environment

Configuring the Qt Creator IDE

To develop for MCUs using the Qt Creator IDE, the MCU plugin is required. Qt Online Installer enables it by default when you install the Qt for MCUs SDK.

To build and run your application on MCUs, you must create a kit:

  1. Select Edit > Preferences > Devices > MCU.

    Note: If you cannot see the MCU tab, select Help > About Plugins, enable the McuSupport plugin, and restart Qt Creator to apply changes.

  2. If not already set, provide the path to the Qt for MCUs installation directory.

    {MCU preferences}

  3. Select a Target supported by the Qt for MCUs SDK. For example, Qt for MCUs 2.8.1 - MIMXRT1170-EVKB-FREERTOS 32BPP.
  4. In the Requirements section, ensure that the platform-specific requirements are met.
  5. Select Automatically create kits for all available targets on start to create kits automatically.

    Note: You can also create/update kits manually using Create Kit and Update Kit.

  6. Select Apply and restart Qt Creator if you choose to create kits automatically.

Configuring CMake variables

You can also set up the development environment from the command prompt. For more information on how to use CMake with Qt Quick Ultralite when developing applications for NXP boards, see CMake manual for NXP boards.

Flashing the firmware

Flashing and debugging NXP boards requires the board to have the OpenSDA firmware. If an incorrect firmware is flashed, the tools may fail to establish connection with the device.

To check the firmware, connect your device to your development host and open the provided USB storage device. In the DETAILS.TXT file, look for the line starting with "USB Interfaces". It has to list "CDC" and "HID". If these are missing, you are probably using an incorrect firmware.

NXP provides the firmware for download. On the download page, select the type of your type of board and download the "Default firmware application, DAPLink". After flashing this to your board by following the instructions from NXP, the CDC and HID interface should be listed.

Building applications with prebuilt Qt Quick Ultralite libraries

Building applications using Qt Creator IDE

  1. Open the CMake project file for the example you want to build.
  2. In the Configure Project window:
    1. Select the kit you created earlier. For example, Qt for MCUs 2.8.1 - MIMXRT1170-EVKB-FREERTOS 32BPP.
    2. Select Configure Project.

{MCU project configuration}

Once the project is configured, select Run or press Ctrl+r on your keyboard to build and flash the binary to the target.

Building applications using the command prompt

You can also build applications from the command prompt. The examples below illustrate how to build the minimal example for MIMXRT1170-EVKB.

QUL_ROOT and QUL_TOOLS are used in the command line examples below as if they were set as environment variables. For example:

export QUL_ROOT=$HOME/Qt/QtMCUs/2.8.1
export QUL_TOOLS=$HOME/Qt/Tools/QtMCUs
set QUL_ROOT=C:\Qt\QtMCUs\2.8.1
set QUL_TOOLS=C:\Qt\Tools\QtMCUs
cd $QUL_ROOT/examples/minimal
mkdir build
cd build
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DQul_ROOT=$QUL_ROOT -DCMAKE_TOOLCHAIN_FILE=$QUL_ROOT/lib/cmake/Qul/toolchain/armgcc.cmake -DQUL_TARGET_TOOLCHAIN_DIR=$QUL_TOOLS/arm_gcc_12_3_1 -DQUL_BOARD_SDK_DIR=$QUL_TOOLS/NXP/SDK_2_15_0_MIMXRT1170-EVKB -DQUL_PLATFORM=MIMXRT1170-EVKB-freertos -DMCUXPRESSO_IDE_PATH=/path/to/the/MCUXpressoIDE -DFREERTOS_DIR=$QUL_TOOLS/NXP/SDK_2_15_0_MIMXRT1170-EVKB/rtos/freertos/freertos-kernel
cmake --build .
cd %QUL_ROOT%\examples\minimal
mkdir build
cd build
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DQul_ROOT=%QUL_ROOT% -DCMAKE_TOOLCHAIN_FILE=%QUL_ROOT%\lib\cmake\Qul\toolchain\armgcc.cmake -DQUL_TARGET_TOOLCHAIN_DIR=%QUL_TOOLS%\arm_gcc_12_3_1 -DQUL_BOARD_SDK_DIR=%QUL_TOOLS%\NXP\SDK_2_15_0_MIMXRT1170-EVKB -DQUL_PLATFORM=MIMXRT1170-EVKB-freertos -DMCUXPRESSO_IDE_PATH=C:\path\to\the\MCUXpressoIDE -DFREERTOS_DIR=%QUL_TOOLS%\NXP\SDK_2_15_0_MIMXRT1170-EVKB\rtos\freertos\freertos-kernel
cmake --build .

Once you have successfully built the minimal example application, use the following command to flash it:

cmake --build . --target flash_minimal

The same procedure applies to any other application.

Debugging

Reading debug messages

By default, the output of printf calls are redirected to a virtual serial port, which is exposed on the host machine via USB.

Debugging via JTag

To debug application code, a hardware debugger can be connected to the board's JTag port, and J-Link software must be installed from here.

Note: The MIMXRT1170-EVKB board is used in the command examples below. For details on other NXP boards, follow the links under board-specific information.

The jumper JP5 must be enabled when debugging via JTag.

Warning: Enabling jumper JP5 prevents flashing via DAP-Link. It must be disabled before using DAP-Link again.

  • Start the gdb server
    JLinkGDBServer -endian little -noir -speed auto -port 2331 -vd -device MIMXRT1176xxxA_M7 -if SWD -halt -reportuseraction -JLinkScriptFile evkbmimxrt1170_connect_cm4_cm7side.jlinkscript
  • Run arm-none-eabi-gdb in a separate console
    c:\path\to\bin\arm-none-eabi-gdb.exe path\to\compiled.elf -ex "target remote localhost:2331"
    (gdb) monitor reset halt
    (gdb) continue

    Note: If the monitor reset gdb command does not reset the device, use the load command. JLink script file is delivered with SDK package.

Note: This method requires MCUXpresso IDE v11.8.0 or newer.

For convenience, you can set an environment variable that points to the Redlink tool, which is part of the MCUXpresso IDE.

export REDLINK=$MCUXPRESSO_IDE_PATH/ide/LinkServer/binaries/crt_emu_cm_redlink
set REDLINK=%MCUXPRESSO_IDE_PATH%\ide\LinkServer\binaries\crt_emu_cm_redlink

Where, MCUXPRESSO_IDE_PATH is an environment variable pointing to the MCUXpresso IDE installation directory.

Note: In MCUXpresso IDE versions 11.8 and older the crt_emu_cm_redlink binary is installed to the IDE itself and can be accessed from <MCUXPRESSO_IDE_PATH>/ide/binaries/crt_emu_cm_redlink.

  • Connect a USB cable to the board (to J11) and to the host PC. Open a terminal window and run the following command.

    Note: The MIMXRT1170-EVKB board is used in the command examples below. For details on other NXP boards, follow the links under board-specific information.

    $REDLINK --server :50032 --mi -2 -vc -p MIMXRT1176xxxxx --ConnectScript RT1170_connect_M7_wake_M4.scp --resetscript RT1170_reset.scp -x .\platform\boards\nxp\mimxrt1170-evkb-freertos\cmake
    %REDLINK% --server :50032 --mi -2 -vc -p MIMXRT1176xxxxx --ConnectScript RT1170_connect_M7_wake_M4.scp --resetscript RT1170_reset.scp -x .\platform\boards\nxp\mimxrt1170-evkb-freertos\cmake

    GDB Server is now listening for TCP connections on port, 50032.

    Note: To change TCP port used by redlink_server, change --server :50032 to different value.

  • Run arm-none-eabi-gdb in a separate console
    /path/to/bin/arm-none-eabi-gdb <PATH_TO>/your_app.elf
    C:\path\to\bin\arm-none-eabi-gdb.exe <PATH_TO>\your_app.elf
  • Connect to the target via the gdbserver in the arm-none-eabi-gdb console using
    (gdb) target remote :50032
  • Alternatively, flash the target device from the arm-none-eabi-gdb console using the following command:
    (gdb) load

Board-specific information

Hardware boardMCUCompilerOperating system(s)
MIMXRT1050-EVKBMIMXRT1052DVL6BGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40Bare Metal, FreeRTOS
MIMXRT1064-EVKMIMXRT1064DVL6AGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40Bare Metal, FreeRTOS
MIMXRT1170-EVKBMIMXRT1176DVMAAGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40FreeRTOS

Resource cache policy

By default, an application's resource data is copied to SDRAM on startup. In order to retain these resources in flash and not load them to RAM on startup, add the following QmlProject option to your qmlproject file:

MCU.Config {
    resourceCachePolicy: "NoCaching"
}

Alternatively, it can be enabled only for individual images like this:

ImageFiles {
    files: [
        "big/button.png"
    ]
    MCU.resourceCachePolicy: "NoCaching"
}

Available under certain Qt licenses.
Find out more.