Installing FreeRTOS to STM32H7 SOM via UART Print

 

This application note explains how to install FreeRTOS to the STM32H7 System-On-Module using the UART interface as the download channel.

Refer to Understanding STM32H7 SOM Boot Architecture as a pre-requisite to understanding the installation procedure.

Hardware Set-Up

The following hardware set-up is required for installation of the software to the STM32H7 SOM:

  • STM32H7-SOM-1A soldered onto the STM32H7-BSB-1A baseboard;
  • The microUSB cable connected to the P1 connector on the baseboard (to provide the STM32H7 serial console to the development host);
  • The ST-LINK/V2 debugger/programmer connected to the 20-pin P3 ARM JTAG connector on the baseboard.

The following picture illustrates the above hardware set-up:

STM32H7 Starter Kit

Installable Images

The images to be installed onto the STM32H7 SOM can be obtained using one of the two approaches, as follows:

  • Build the images from the sources, as documented in Building FreeRTOS.
  • Use the prebuilt images provided by Emcraft. The prebuilt images can be found in the location documented in Release Notes.

Installing U-Boot SPL to Internal Flash

Step through the following procedure to install the U-Boot SPL to the internal Flash of the STM32H750:

  1. Run the following command on the Linux development host:
  2. [[email protected] stm32h7-som]# st-flash write u-boot-upstream/spl/u-boot-spl.bin 0x08000000 st-flash 1.7.0-246-gc721751
    2023-03-14T01:13:03 INFO common.c: STM32H74x_H75x: 128 KiB SRAM, 128 KiB flash in at least 128 KiB pages.
    file u-boot-upstream/spl/u-boot-spl.bin md5 checksum: 2de7cee5a61c7b980cf8993ebb6c3ea, stlink checksum: 0x00518859
    2023-03-14T01:13:03 INFO common_flash.c: Attempting to write 61729 (0xf121) bytes to stm32 address: 134217728 (0x8000000)
    2023-03-14T01:13:03 WARN common_flash.c: unaligned len 0xf121 -- padding with zero
    -> Flash page at 0x8000000 erased (size: 0x20000)

    2023-03-14T01:13:04 INFO flashloader.c: Starting Flash write for H7
    61730/61730 bytes written
    2023-03-14T01:13:05 INFO common_flash.c: Starting verification of write complete
    2023-03-14T01:13:06 INFO common_flash.c: Flash written and verified! jolly good!
    [[email protected] stm32h7-som]#

  3. Verify that the U-Boot SPL has been successfully installed. Reset the SOM by pressing the S3 button on the carrier board and confirm that the following output appears on the serial UART console:
  4. U-Boot SPL 2019.04-gb41e2dbf49-dirty (Mar 14 2023 - 01:00:44 +0300) Hit 's' key to enter spl shell: Trying to boot from SPI

Installing U-Boot "Proper" and FreeRTOS to QSPI Flash

Step through the following procedure to install the U-Boot "Proper" and FreeRTOS to the QSPI Flash:

  1. On the development host, make sure that your serial terminal utility (such as picocom) is not connected to the board serial console (/dev/ttyUSB1 in this example).
  2. Run the following command on the Linux development host:
  3. [[email protected] stm32h7-som]$ ./u-boot-upstream/board/emcraft/ stm32h7-som/stm32h7-som-prog.kermit /dev/ttyUSB1 u-boot-upstream/u-boot.img STM32CubeH7/Release/freertos_stm32h750.img

  4. Reset the board to start programming u-boot-upstream/u-boot.img via /dev/ttyUSB1.
  5. Reset the SOM by pressing the S3 button on the carrier board.
  6. Wait for the C-Kermit utility to load the U-Boot and FreeRTOS images (observe the progress indicators).
  7. The script will exit successfully at the end of the installation procedure:
  8. ...
    Successfully programmed STM32CubeH7/Release/freertos_stm32h750.img to the rtos1 UBI volume
    setenv boot1_valid 1
    STM32H7-SOM U-Boot > setenv boot2_active 0
    STM32H7-SOM U-Boot > setenv upgrade_available 0
    STM32H7-SOM U-Boot > setenv bootcount 0
    STM32H7-SOM U-Boot > saveenv
    Saving Environment to UBI... ubi0: detaching mtd2
    ...
    Writing to UBI... done
    OK
    STM32H7-SOM U-Boot > [[email protected] stm32h7-som]$ 

  9. Verify that the U-Boot "proper" and FreeRTOS have been successfully installed. Reset the SOM by pressing the S3 button on the carrier board and confirm that the following output appears on the serial UART console:
  10. U-Boot SPL 2019.04-gb41e2dbf49-dirty (Mar 14 2023 - 01:00:44 +0300) Hit 's' key to enter spl shell: Trying to boot from SPI U-Boot 2019.04-gb41e2dbf49-dirty (Mar 14 2023 - 01:00:44 +0300) Model: STMicroelectronics STM32H7 SOM DRAM: 32 MiB SF: Detected n25q512ax3 with page size 256 Bytes, erase size 4 KiB, total 64 MiB Flash: 128 KiB MMC: STM32 SDMMC2: 0 Loading Environment from UBI... ubi0: default fastmap pool size: 190 ... In: serial Out: serial Err: serial No size specified -> Using max size (2099072) Read 2099072 bytes from volume splash to d0400000 Net: Net Initialization Skipped No ethernet found. Hit any key to stop autoboot: 0 Booting Image #1 No size specified -> Using max size (4198144) Read 4198144 bytes from volume rtos1 to d0400000 ## Loading kernel from FIT Image at d0400000 ... ... Starting kernel ... STM32H7 SOM FreeRTOS CLI, www.emcraft.com Type help to view a list of available commands. CLI>

Enabling LCD and Splash Screen on Starter Kit with LCD

If your starter kit includes the LCD, it can be enabled in software by installing the U-Boot splash screen image to the QSPI Flash. It is done simultaneously with installing U-Boot "Proper" and FreeRTOS, as described above. Use the following command on the Linux development host to install the stm32h7-splash-24bpp.bmp picture as the splash screen:

[[email protected] stm32h7-som]$ ./u-boot-upstream/board/emcraft/stm32h7-som/stm32h7-som-prog.kermit /dev/ttyUSB1 u-boot-upstream/u-boot.img STM32CubeH7/Release/freertos_stm32h750.img ./u-boot-upstream/board/emcraft/stm32h7-som/stm32h7-splash-24bpp.bmp