Understanding STM32H7 SOM Boot Architecture |
This application note explains the memory and boot architecture of the STM32H7 System-On-Module SOM. STM32H7 SOM Hardware Block Diagram The STM32H7 SOM boot architecture is defined by the hardware architecture of the SOM: U-Boot as Initial Firmware and RTOS Bootloader U-Boot Overview The STM32H7 SOM makes use of the U-Boot firmware as the RTOS OS bootloader. U-Boot is a sophisticated open-source, GPL-licensed firmware monitor that supports, off-the-shelf, various I/O interfaces and functionalities that are important for purposes of this project. Specifically, the following capabilities of U-Boot will be used:
STM32H7 SOM U-Boot Configuration This project makes use of U-Boot version 2019.04-rc3. It is built, configured, ported and otherwise enhanced specifically for the STM32H750 System-on-Module and development carrier board, running RTOS. Key U-Boot files specific to the STM32H750 System-on-Module are as follows, in the U-Boot source tree:
U-Boot SPL and U-Boot "Proper" It is important to note that the STM32H750 device has only 128KB of internal (on-chip) Flash. This implies that the initial firmware binary must be small enough to fit into this amount of Flash. U-Boot supports this, by implementing the concept of the "U-Boot SPL". When the U-Boot SPL build-time option (CONFIG_SPL_BUILD) is enabled in the U-Boot configuration file (include/configs/stm32h7-som.h), the U-Boot build procedure will build two separately loadable firmware images:
U-Boot Command Monitor Both the U-Boot SPL and main U-Boot support an interactive command interface (also referred to as the "command monitor") via the UART-based serial console. The U-Boot SPL provides a very minimal set of user commands, sufficient for basic examination of the system as well as load and installation of bootable images. The main U-Boot provides a sophisticated command monitor with various commands and scripting capabilities. The UART based serial console is a standard feature of U-Boot. On the STM32H750 System-on-Module, USART1 is configured as the U-Boot serial console (refer to include/configs/stm32h7-som.h). The serial console is available both in the U-Boot SPL and main U-Boot. It is important to note that in order to make sure that the USART1 related definitions are not truncated from the U-Boot SPL run-time configuration file (arch/arm/dts/stm32h7-som.dts), special constructs must be included in the .dts file, for the USART1 node and associated STM32 pins, as follows:
SDRAM Initialization The U-Boot initializes the SDRAM controller and sets it up for optimal performance of the specific SDRAM device used in the STM32H750 SOM design. There are two assembly-build-time configurations of the hardware SOM that will be supported by U-Boot, defined by the value of the PE2 GPIO input at boot time:
The U-Boot reads the value of the PE2 GPIO input and configures the SDRAM interface appropriately, setting it up for one of the two SDRAM assembly options above. Namely, the sdram init function from board/emcraft/stm32h7-som/stm32h7-som.c calls the detect_sdram_size function from this module to get the value of the PE2 GPIO input. In case of PE2 GPIO input active, the dts_fixup function residing in this module is also called. This function patches the u-boot device tree to provide the correct values for the U-Boot memory controller driver. Having initialized SDRAM, the U-Boot relocates to appropriate addresses in RAM memory map and then calls the main U-Boot entry point. From that point on, the main U-Boot controls the system. Amount of available SDRAM is stored in the U-Boot mem environment variable. Understanding Software Installation Procedure Understanding Software Installation Procedure Overview Procedure to install U-Boot to the STM32H750 consists of two parts:
Using ST-LINK to Install U-Boot SPL to Internal Flash The SWD or JTAG interface along with the STM32 ST-LINK utility must be used to install the U-Boot SPL (spl/u-boot-spl.bin) to the internal Flash of the STM32H750. Installing U-Boot "Proper" and RTOS to External Flash via UART The dedicated kermit script is provided to install the main U-Boot "proper" and RTOS images to the QSPI Flash. The script is available as board/emcraft/stm32h7-som/stm32h7-som-prog.kermit from the U-Boot source tree. This script must be used for the initial system installation, including installation of the U-Boot image, creating the UBI volumes, installation of the RTOS image and installation of the splash screen image. Usage is as follows: ./stm32h7-som-prog.kermit <tty> <uboot_img> [<rtos_img>] [<splash_img>]
The stm32h7-som-prog.kermit can be used to update only the U-Boot image without affecting the previously installed RTOS and the splash screen images on the QSPI Flash. For this the kermit script must be called without the rtos_img and splash_img arguments: ./stm32h7-som-prog.kermit <tty> <uboot_img> |