C

Getting started on NXP (Zephyr)

Overview

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

Note: These instructions apply when you are working with NXP targets that run on Zephyr®. For information on how to get started with NXP targets that run on BareMetal, FreeRTOS or Linux, see Getting started on NXP (BareMetal and FreeRTOS) and Getting started on NXP (Linux).

Compatible versions

Qt Quick Ultralite for Zephyr® has been tested on Zephyr® 3.6.0, which is the officially supported version for NXP IMXRT1060-EVKB.

Note: Zephyr® 3.7.0 LTS is currently not supported.

Installing prerequisites

Make sure you have all the prerequisites installed before preparing the Zephyr® environment.

NXP i.MX RT1060 EVKB

NXP i.MX RT1064 EVK

Flashing prebuilt binaries

Qt for MCUs offers a selection of prebuilt binaries showing various demos and examples. To flash these, follow the flashing instructions.

Preparing the Zephyr® environment

Setting up Zephyr®

Follow the getting started guide from Zephyr. This will set up the environment for development. You should be able to build and flash the blinky example from the guide.

Setting up the environment

Before building the application, set the following environment variables:

export QUL_ROOT=$HOME/Qt/QtMCUs/2.9.0
export ZEPHYR_DIR=/path/to/zephyrproject
set QUL_ROOT=C:\Qt\QtMCUs\2.9.0
set ZEPHYR_DIR=C:\path\to\zephyrproject

Patching Zephyr®

You need a patch for Zephyr 3.6.0 to compile a Zephyr application using Qt Quick Ultralite. This patch is provided with the Qt Quick Ultralite Zephyr platform port and you can apply it using git am:

cd $ZEPHYR_DIR/zephyr
git am $QUL_ROOT/platform/boards/nxp/common/zephyr/0001-Fix-the-z_impl_k_usleep-argument-type.patch
cd %ZEPHYR_DIR%\zephyr
git am %QUL_ROOT%\platform\boards\nxp\common\zephyr\0001-Fix-the-z_impl_k_usleep-argument-type.patch

Building the application

Exporting the Qt Quick Ultralite application

Export the application code using the qmlprojectexporter:

$QUL_ROOT/bin/qmlprojectexporter \
/path/to/your/project.qmlproject \
--boarddefaults=$QUL_ROOT/platform/boards/nxp/mimxrt1060-evkb-zephyr/cmake/BoardDefaults_16bpp.qmlprojectconfig \
--toolchain GNU \
--platform mimxrt1060-evkb-zephyr \
--outdir /path/to/project_output_dir \
--project-type zephyr \
--generate-entrypoint \
--platform-metadata $QUL_ROOT/platform/boards/nxp/mimxrt1060-evkb-zephyr/mimxrt1060-evkb-zephyr_16bpp_Linux_armgcc-metadata.json
%QUL_ROOT%\bin\qmlprojectexporter ^
C:\path\to\your\project.qmlproject ^
--boarddefaults=%QUL_ROOT%\platform\boards\nxp\mimxrt1060-evkb-zephyr\cmake\BoardDefaults_16bpp.qmlprojectconfig ^
--toolchain GNU ^
--platform mimxrt1060-evkb-zephyr ^
--outdir C:\path\to\project_output_dir ^
--project-type zephyr ^
--generate-entrypoint ^
--platform-metadata %QUL_ROOT%\platform\boards\nxp\mimxrt1060-evkb-zephyr\mimxrt1060-evkb-zephyr_16bpp_Windows_armgcc-metadata.json

Note: This export is needed only once per application project. CMake will automatically detect changes to QML files and update the generated code after the initial export.

If the Qt Quick Ultralite application uses selectors for different variants, the --selector argument needs to be provided to the qmlprojectexporter. For example, the thermo demo can be configured with the following selectors:

--selector normal,small

See the qmlprojectexporter documentation, QmlProject Manual, and Generating projects for Zephyr for more information about qmlprojectexporter, qmlprojects and Zephyr project generation.

Building the Zephyr® application

Activate the Python virtual environment to make the west command available:

source $ZEPHYR_DIR/.venv/bin/activate
%ZEPHYR_DIR%\.venv\Scripts\activate.bat

Make the flashing tool available in the PATH environment variable to enable flashing with west:

export PATH=$PATH:/path/to/flashing_tool
set PATH=%PATH%;C:\path\to\flashing_tool

Build and flash the application:

export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
export GNUARMEMB_TOOLCHAIN_PATH=$HOME/Qt/Tools/QtMCUs/arm_gcc_12_3_1

cd $ZEPHYR_DIR/zephyr
west build -b mimxrt1060_evkb /path/to/project_output_dir
west flash
set ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
set GNUARMEMB_TOOLCHAIN_PATH=C:\Qt\Tools\QtMCUs\arm_gcc_12_3_1

cd %ZEPHYR_DIR%\zephyr
west build -b mimxrt1060_evkb C:\path\to\project_output_dir
west flash

Note: By default, west expects J-Link to be used. The used flashing tool can be changed to NXP MCUXpresso LinkServer by specifying --runner linkserver. For more info, see Zephyr documentation.

Debugging

Zephyr supports debugging with west by either debugging directly or launching a debug server and connecting to it with a debugger. The steps below show how to run a debug server with west and how to connect to it using GNU Project Debugger (GDB).

Make the debug server (such as the J-Link gdbserver) available in the PATH environment variable to enable debugging with west:

export PATH=$PATH:/path/to/debug_server
set PATH=%PATH%;C:\path\to\debug_server

Launch the debug server:

west debugserver

Note: By default, west expects the J-Link gdbserver to be used. The used debug server can be changed by specifying --runner <debug_server>. For more info, see Zephyr documentation.

The default debug server sets up a TCP socket listening to port 2331, which you can connect with the GDB in another terminal:

cd $ZEPHYR_DIR/zephyr/build
$GNUARMEMB_TOOLCHAIN_PATH/bin/arm-zephyr-eabi-gdb -tui -ex "target remote localhost:2331" zephyr/zephyr.elf
cd %ZEPHYR_DIR%\zephyr\build
$GNUARMEMB_TOOLCHAIN_PATH\bin\arm-zephyr-eabi-gdb -tui -ex "target remote localhost:2331" zephyr\zephyr.elf

Board-specific information

Tier 1: Reference Targets

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, Zephyr
MIMXRT1170-EVKBMIMXRT1176DVMAAGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40FreeRTOS

Tier 2: Verified Targets

Hardware boardMCU / MPUCompilerOperating system(s)
MIMXRT1060-EVKBMIMXRT1060DVL6B MCUGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40Bare Metal, Zephyr
MCIMX93-EVKi.MX 93 MPUGNU Arm GCC 12.3.rel1Linux

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.