STM32L4R9I Discovery Kit Setup Instructions

This topic helps you setup the development environment for STM's STM32L4R9I-Disco.

板特征

  • STM32L4R9AII6 MCU featuring ARM® Cortex®-M4, 2-MBytes Flash, 640-kbytes RAM
  • 1.2” 390x390 round Touch Display
  • 16-Mbit PSRAM memory
  • 512-Mbit Octo-SPI Flash memory

设置开发环境

先决条件

Use the Qt online installer to install the following prerequisites. You can download the installer from your Qt account .

  • Qt for MCUs SDK
  • Qt Creator v4.12.4 或更高版本
  • CMake 3.15 或更高版本
  • Ninja 1.10.0 或更高版本

    注意: Ninja is an optional build tool and can be replaced with others like JOM or NMake. It is not needed when using Qt Creator.

  • ARM Toolchain 8-2019-q3-update or IAR Build Tools for Arm V8.50, depending on which toolchain you are using
  • STM32CubeL4 SDK 1.15.0 or newer
  • STM Cube Programmer 2.4.0 or newer

    注意: Ensure that it is installed in the default location ( C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\ ).

注意: The Qt online installer does not install the STM Cube Programmer by default. You must select it explicitly from the list of third-party tools and SDKs.

Qt Creator IDE

  • 发起 Qt Creator 并选择 工具 > 选项 > 设备 > MCU .
  • 选择 Qt for MCUs 1.7 - STM32L4R9I-DISCOVERY-BAREMETAL 24bpp from the drop-down list for Target supported by the Qt for MCUs SDK .
  • Provide the STM32CubeProgrammer install path if it is not installed in the default location.
  • 要求 section, ensure that the platform-specific requirements are met.
  • 选择 Automatically create kits for all available targets on start to create kits automatically.

    注意: You could also manually create/remove kits using Create Kit and Remove Kit .

  • 点击 Apply and restart Qt Creator if you choose to create kits automatically.

注意: Automatically create kits for all available targets on start option is available from Qt Creator v4.14 onwards. On older versions of Qt Creator, you have to explictly create or remove kits using Create kit or Remove kit .

命令行设置

To get started from the command line, ensure that the following these instructions:

  • Qul_DIR to the Qt for MCUs SDK install path.
    <QT_INSTALL_PATH>\QtMCUs\<VERSION>
    									

    其中,

    • <QT_INSTALL_PATH> is the Qt install directory,
    • and <VERSION> is the directory containing the Qt Quick Ultralite version you are using, for example 1.1.0 .
  • Toolchain install path, depending on which toolchain is being used

    OR

    • 对于 IAR 工具链 , set IAR_ARM_COMPILER_DIR to the IAR Build Tools install path.
  • Add the CMake and Ninja tools to your system PATH . If you installed these tools using the Qt online installer, they are installed under <QT_INSTALL_PATH>\Tools .
  • 添加 STM32CubeProg 安装目录到 System PATH 若它未安装在默认位置。
  • 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
    									

    其中, <STM32_CUBE_IDE_INSTALL_PATH> is the Cube IDE install path.

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

  • 创建 STM32Cube_FW_L4_SDK_PATH environment variable and set it to:
    <QT_INSTALL_PATH>\Tools\QtMCUs\STM\STM32Cube_FW_L4_V<version>
    									

    where, <QT_INSTALL_PATH> points to the Qt install directory.

构建配置

Qt Creator provides a build configuration with the kit that you created earlier for the Qt for MCUs 1.7 - STM32L4R9I-DISCOVERY-BAREMETAL 24bpp target. If you are using a command-line setup, configure using the following CMake variables. For more information, see the CMake 手册 .

  • QUL_PLATFORM

    The platform to build must be set to stm32l4r9i-discovery-baremetal for this board.

    -DQUL_PLATFORM=stm32l4r9i-discovery-baremetal
    									
  • CMAKE_TOOLCHAIN_FILE

    此平台支持 armgcc and IAR 工具链。

    -DCMAKE_TOOLCHAIN_FILE=%Qul_DIR%\lib\cmake\Qul\toolchain\armgcc.cmake
    									

    OR

    -DCMAKE_TOOLCHAIN_FILE=%Qul_DIR%\lib\cmake\Qul\toolchain\iar.cmake
    									
  • QUL_COLOR_DEPTH

    The supported color depth by this platform is 24-bit.

    注意: If this variable is not set, default color depth is used while configuring for the platform.

    -DQUL_COLOR_DEPTH=24
    									
  • QUL_COPY_TO_RAM

    By default, the asset data for application is copied to SDRAM on application startup. In order to keep resources in external flash, and not load it to RAM on startup, use the QUL_COPY_TO_RAM CMake option with the value Never when adding assets to the application with qul_add_resource .

预构建演示和范例

The package for STM32L4R9I_DISCO board comes with a prebuilt watch demo binary. You can find it in the demos_images 目录。

Flashing Instructions for ST boards , for information about flashing the device.

For this board, select MX25LM51245G_STM32L4R9I-DISCO as the external loader.

采用预构建 Qt Quick Ultralite 库构建应用程序

Qt Creator IDE

Open the CMake project file for the example you want to build and configure it with the kit you created earlier. Once the project is configured, select 运行 or press Ctrl+r on your keyboard to build and flash the binary to the target.

命令行

以下范例构建 watch demo for this board:

cd %Qul_DIR%\demos\watch
mkdir build
cd build
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=%Qul_DIR%\lib\cmake\Qul\toolchain\armgcc.cmake -DQUL_PLATFORM=STM32L4R9I-DISCOVERY-baremetal
cmake --build .
							

Once you have successfully built the watch demo, you can flash it from the command line:

cmake --build . --target flash_watch
							

The same procedure applies to any other application.

读取调试消息

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

调试

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

    其中, <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 .

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

  • 运行 arm-none-eabi-gdb in a separate console
    %ARMGCC_DIR%\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 127.0.0.1:61234
    									

故障排除

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 工具。

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

已知局限性

STM32L4R9AII6 MCU does not have double-precision floating-point support. Care should be taken to avoid using them.