C

Getting started on STM

Overview

This topic provides all the necessary information to get started on the STM 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.2 - STM32F469I-DISCOVERY-BAREMETAL 24bpp.
  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 STM boards, see CMake manual for STM boards.

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.2 - STM32F469I-DISCOVERY-BAREMETAL 24bpp.
    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

Command line setup

To get started from the command line, make the following changes to System PATH.

  • Add STM32CubeProg install directory to System PATH if it is not installed in the default location.
  • Add ST-LINK_gdbserver.exe directory to your System PATH
    <STM32_CUBE_IDE_INSTALL_PATH>\stm32cubeide_1.3.0\plugins\com.st.stm32cube.ide.mcu.externaltools.stlink-gdb-server.win32_1.3.0.202002181050\tools\bin

    where, <STM32_CUBE_IDE_INSTALL_PATH> is the Cube IDE install path.

    Note: STM32CubeIDE is optional and required only for on-chip debugging purposes.

Building a minimal example from the command prompt

You can also build applications from the command prompt. The examples below illustrate how to build the minimal example for the STM32F469I discovery board.

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.2
export QUL_TOOLS=$HOME/Qt/Tools/QtMCUs
set QUL_ROOT=C:\Qt\QtMCUs\2.8.2
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/STM/STM32Cube_FW_F4_V1.28.0 -DQUL_PLATFORM=STM32F469I-DISCOVERY-baremetal
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%\STM\STM32Cube_FW_F4_V1.28.0 -DQUL_PLATFORM=STM32F469I-DISCOVERY-baremetal
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 other STM boards that are supported by Qt Quick Ultralite.

Debugging

  1. Open terminal window and run the following command:
    ST-LINK_gdbserver -d -cp "<STM32_CUBE_PROG_INSTALL_PATH>/bin"
    ST-LINK_gdbserver.exe -d -cp "<STM32_CUBE_PROG_INSTALL_PATH>\bin"

    where, <STM32_CUBE_PROG_INSTALL_PATH> is the directory where you've installed the Cube Programmer tool.

    GDB Server is now listening for TCP connections on the default port, 61234.

    Note: Actual TCP port used by ST-LINK_gdbserver is printed out on gdbserver's console.

  2. Run arm-none-eabi-gdb in a separate console
    $QUL_TOOLS/arm_gcc_12_3_1/bin/arm-none-eabi-gdb <PATH_TO>/your_app.elf
    %QUL_TOOLS%\arm_gcc_12_3_1\bin\arm-none-eabi-gdb.exe <PATH_TO>\your_app.elf
  3. Connect to the target via the gdbserver in the arm-none-eabi-gdb console using
    (gdb) target remote 127.0.0.1:61234

Troubleshooting

ST-LINK_gdbserver requires up-to-date ST-LINK firmware to be installed. If you see the following error:

Error in initializing ST-LINK device. Reason: ST-LINK firmware upgrade required.

you must upgrade the firmware to the latest version using the STM32CubeProgrammer tool.

If the problem persists after upgrade, retry with ST-LINK Upgrade tool from the ST webpage ( Download ).

Supported STM boards

Tier 1: Reference Targets

Hardware boardMCUCompilerOperating system(s)
STM32F769I-DISCOVERYSTM32F769NIGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40Bare Metal, FreeRTOS
STM32H750B-DISCOVERYSTM32H750XBGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40Bare Metal

Tier 2: Verified Targets

Hardware boardMCUCompilerOperating system(s)
STM32F469I-DISCOVERYSTM32F469NIGNU Arm GCC 12.3.rel1, IAR Build Tools for Arm V9.40Bare Metal

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"
}

Note: Resources used for blending/blitting operations can be stored on the fast external flash if available, without copying them to RAM.

Available under certain Qt licenses.
Find out more.