Last edited 2 weeks ago

How to load and start STM32CubeMP13 applications via microSD card

Applicable for STM32MP13x lines

This article explains how to load and start STM32CubeMP13 applications via microSD card using the "SD external loader firmware utility" provided with the STM32CubeMP13 package. This use case is useful in production mode.

1. SD external loader firmware utility[edit | edit source]

1.1. Introduction[edit | edit source]

The SD external loader firmware utility contains multiple applications which can be collectively used to load and start STM32CubeMP13 applications programmed into a microSDTM card.

  • It allows the programming of embedded software applications on external microSDTM cards for the STM32MP135x-DK Discovery kit More info green.png.
  • This package contains all the prebuild binaries and source code necessary to program the microSDTM card through the serial interface and boot from the microSDTM card.
  • This package version supports the UART and USB DFU serial protocol.
Info white.png Information
This package has been tested on STM32MP135F-DK board and can be easily tailored to any other supported device and development board.

1.2. Contents[edit | edit source]

The SD External Loader utility folder structure and details are described as below -:

├── Projects
    ├── STM32MP135C-DK
       ├── External_Loader
          ├── External_Mem_Loader
          ├── Prebuild_Binaries
          ├── SD_Ext_Loader
          ├── LICENSE.md
          ├── LICENSE.txt
          ├── readme.txt
       ├── Applications
          ├── FSBLA
             ├── FSBLA_Sdmmc1

External_Mem_Loader
This project initializes UART or USB interface whichever is used for flashing binaries in serial boot mode. Refer to serial boot mode in Set boot switches. When this project is built External_Mem_Loader_A7.stm32 binary is generated, and it can then be copied to Prebuild_Binaries folder. This project is available for both EWARM and STM32CubeIDE. This project also contains readme.txt for more information.


SD_Ext_Loader

This project provides init, read, write, and erase APIs for microSD card. When this project is built SD_Ext_Loader.bin binary is generated, and it can then be copied to Prebuild_Binaries folder. External_Mem_Loader flashes this into RAM and uses its APIs for programming other binaries onto the microSD card. This project is available for both EWARM and STM32CubeIDE. This project also contains readme.txt for more information.


FSBLA_Sdmmc1

This project is the first-stage bootloader (FSBLA). It is programmed via External_Mem_Loader on the microSD™ card. It is used to load and execute the test application from the microSD™ card to DDR. When this project is built FSBLA_Sdmmc1_A7_Signed.bin binary is generated, and it can then be copied to Prebuild_Binaries folder. This project is available for both EWARM and STM32CubeIDE. This project also contains readme.txt for more information.


Prebuild_Binaries

It contains prebuilt binaries from the above compiled projects and a FlashLayout_OpenBL_ExtLoaderSDMMC_SerialBoot.tsv file.This tsv file defines flash memory partitions, binaries, and the corresponding partition ID. Refer to the STM32CubeProgrammer_flashlayout article for more details.

It also contains MP13_BSP_TemplatesA7_DISCO_Signed.bin, a test application binary which is programmed via External_Mem_Loader on the microSD™ card and is loaded into DDR for execution by FSBLA. This application can be replaced with any customer test application. The application must be built for DDR (refer to build test application for DDR) and then properly signed with the STM32CubeProgrammer signing tool (or via postbuild steps and scripts)). In this test application, the blue LED is initialized and after successful execution, it is toggled at 200ms and the logs shown below are printed on the serial console:

TestApp Execution 1.png

LICENSE.md and LICENSE.txt

License details for the project.


readme.txt

Read this file carefully; it provides all the information for the example setup and verdict.

2. Hardware and software prerequisites[edit | edit source]

  • STM32MP135x-DK Discovery kit More info green.png with a micro-USB cable connected to the ST-Link port.
  • USB Type-C cable for powering the board.
  • A microSD card plugged into the microSD card slot in the board.
  • STM32CubeProgrammer PC tool installed (v2.14.0 minimum).

3. How to run the utility[edit | edit source]

3.1. Set boot mode to serial[edit | edit source]

  • Set the boot pins to the b000 (BOOT0/1/2 to OFF) position to select serial mode. Refer to Set boot switches.
  • Connect the micro-USB cable between the PC and ST-Link connector on the board. The PC should detect the UART interface.
Warning DB.png Important
ST-Link provides a UART interface via Virtual COM port on the board, like STM32MP135x-DK Discovery kit More info green.png.
Warning white.png Warning
ROM CODE gives preference to USB DFU if the USB cable is connected to other places than the ST-Link USB port.
If you want to use UART, the USB cable should NOT be connected to any other ports on the board than ST-Link USB.

3.2. Program the microSD card in serial boot[edit | edit source]

3.2.1. Program the microSD card using the STM32CubeProgrammer GUI[edit | edit source]

Read the STM32CubeProgrammer articles for more details.

  • Click on UART and then select COM port:
CubeProgrammer GUI Flashing 1.png


  • Click on the Connect button:
STM32CubeProgrammer is now connected to ROM Code and the logs show the chip ID, bootloader version, and other details.
CubeProgrammer GUI Flashing 2.png


  • Click on the "+" icon, then on Open file and select the TSV file FlashLayout_OpenBL_ExtLoaderSDMMC_SerialBoot.tsv
CubeProgrammer GUI Flashing 3.png


  • Select the Binaries path with the Browse button (Firmware\Projects\STM32MP135C_DK\External_Loader\Prebuild_Binaries\SD_Ext_Loader):
CubeProgrammer GUI Flashing 4.png


  • Click on the Download button:
STM32CubeProgrammer now starts downloading the binaries. Once they've been successfully downloaded, a pop-up message indicates Flashing service completed successfully.
CubeProgrammer GUI Flashing 5.png

3.2.2. Program the microSD card using the STM32CubeProgrammer CLI[edit | edit source]

  • Browse to the installed STM32CubeProgrammer binary directory (STM32CubeProgrammer\bin).
  • Open a command prompt from this directory.
  • Execute the command to load the SD external loader binaries:
$STM32_Programmer_CLI.exe -c port=COM 
<num> -w 
<YourDirectoryPath>\Projects<STM32device>\External_Loader\SD_Ext_Loader\FlashLayout_OpenBL_ExtLoaderSDMMC_SerialBoot.tsv
  • DO NOT reset the board until the command has been fully completed.
  • STM32CubeProgrammer now starts downloading all binaries listed in the TSV file. When all binaries have been downloaded successfully, a message indicates Flashing service completed successfully.

3.3. Run the test application[edit | edit source]

  • When the binaries have been programmed onto the microSD card successfully, set the boot pins to the b101 (BOOT0 and BOOT2 to ON and BOOT1 to OFF) position to select SD mode. Refer to Set boot switches for more details.
  • The MP13_BSP_TemplatesA7_DISCO_Signed.bin test application toggles the blue LED at 200ms, indicating that it has been loaded and executed successfully from DDR. It also prints the following logs on the serial console:
TestApp Execution 1.png