C
Using Zephyr on NXP IMXRT1060-EVKB
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.
Prerequisites
- Qt Quick Ultralite 2.11.2
- Qt Quick Ultralite NXP i.MX RT1060 EVKB platform package
- NXP i.MX RT1060 EVKB
- RK043FN66HS-CTG
- Zephyr RTOS 3.6.0
- Either Segger J-Link debug probe or MCUXpresso IDE
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.11.2
export ZEPHYR_DIR=/path/to/zephyrprojectset QUL_ROOT=C:\Qt\QtMCUs\2.11.2
set ZEPHYR_DIR=C:\path\to\zephyrprojectPatching 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.patchcd %ZEPHYR_DIR%\zephyr
git am %QUL_ROOT%\platform\boards\nxp\common\zephyr\0001-Fix-the-z_impl_k_usleep-argument-type.patchBuilding 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 \
--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 ^
--platform-metadata %QUL_ROOT%\platform\boards\nxp\mimxrt1060-evkb-zephyr\mimxrt1060-evkb-zephyr_16bpp_Windows_armgcc-metadata.jsonNote: 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.
Note: Some examples do not have main() function in the code. When exporting these examples, use the --generate-entrypoint argument, unless you are writing your own main() function. For more info about writing a main() function initializing Qt Quick Ultralite, see Running Qt Quick Ultralite in applications.
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,smallThe default configuration for Zephyr platforms is to export Qt Quick Ultralite libraries that are built with MinSizeRel configuration. If you have built Qt Quick Ultralite libraries with a different build configuration (such as Debug), you can override the exported library build type by adding --qul-build-type to qmlprojectexporter command:
--qul-build-type DebugWhen exporting examples with --include-metadata-extra-target argument, make sure the --outdir is not inside the example source directory.
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.batMake the flashing tool available in the PATH environment variable to enable flashing with west:
export PATH=$PATH:/path/to/flashing_toolset PATH=%PATH%;C:\path\to\flashing_toolBuild 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 flashset 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 flashNote: 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_serverset PATH=%PATH%;C:\path\to\debug_serverLaunch the debug server:
west debugserverNote: 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.elfcd %ZEPHYR_DIR%\zephyr\build
$GNUARMEMB_TOOLCHAIN_PATH\bin\arm-zephyr-eabi-gdb -tui -ex "target remote localhost:2331" zephyr\zephyr.elfAvailable under certain Qt licenses.
Find out more.