Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

This application note explains the memory and boot architecture of the STM32H7 System-On-Module SOM.

1. STM32H7 SOM Hardware Block Diagram

The STM32H7 SOM boot architecture is defined by the hardware architecture of the SOM:

image-20240524-083659.png

2. U-Boot as Initial Firmware and Linux Bootloader

2.1. U-Boot Overview

The STM32H7 SOM makes use of the U-Boot firmware as the Linux 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:

  • Serial console command interface with various set-up, test and maintenance commands;

  • Environment variables allowing customisation of a unit;

  • Sophisticated OS auto-boot sequence;

  • Partitioning and UBI management of QSPI Flash;

  • Initial installation of OS images to QSPI Flash;

  • Reliable upgrade of redundant OS images in QSPI Flash.

2.2. 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 Linux. Key U-Boot files specific to the STM32H750 System-on-Module are as follows, in the U-Boot source tree:

  • include/configs/stm32h7-som.h - U-Boot configuration file specific to the STM32H750 System-on-Module and development carrier board;

  • board/emcraft/stm32h7-som/ - U-Boot code specific to support of the STM32H750 System-on-Module;

  • arch/arm/dts/stm32h7-som.dts - U-Boot run-time I/O configuration file.

2.3. 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 SPL - first-stage bootloader is the U-Boot SPL. The U-Boot SPL is called by the STM32H750 hardware from internal Flash on power-on / reset. This is a minimal stand-alone configuration of U-Boot that is small in size. The U-Boot SPL performs basic initialization of the system and then loads the main U-Boot from external storage device to RAM and invokes the main U-Boot in RAM. On the STM32H750 System-on-Module, the U-Boot SPL will load the U-Boot image from QSPI Flash to SRAM and then pass control to the main U-Boot which relocates to SDRAM.

  • Main U-Boot (or "U-Boot proper") - second-stage bootloader, which is the regular full-fledged U-Boot with all the features and capabilities. It is larger in size (typically, size is larger than 250KB). On the STM32H750 System-on-Module, the main U-Boot will be responsible, among other things, for fully initializing the system, selecting an appropriate bootable Linux image out of the two redundant images, relocating the OS image from Flash to RAM and finally calling Linux in RAM.

2.4. 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, USART3 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 USART3 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 USART3 node and associated STM32 pins, as follows:

&usart3 {       
        u-boot,dm-spl;
...

2.5. 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:

  • 0 (low) implies that the SOM is populated with 1 SDRAM chip (32MB 16-bit SDRAM);

  • 1 (active) implies that the SOM is populated with 2 SDRAM chips (64MB 32-bit SDRAM).

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 check_sdram_64m 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.

3. Understanding Software Installation Procedure

3.1. Understanding Software Installation Procedure Overview

Procedure to install U-Boot to the STM32H750 consists of two parts:

  • Installation the U-Boot SPL image to the internal Flash of the STM32H750;

  • Installation the main U-Boot image to the QSPI Flash.

3.2. 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.

3.3. Installing U-Boot "Proper" to External Flash via UART

The dedicated kermit script is provided to install the main U-Boot "proper" image to the QSPI Flash. The script is available as board/emcraft/stm32h7-som/stm32h7-som-uboot-install.kermit from the U-Boot source tree. This script must be used for the initial system installation, including installation of the U-Boot image and creating the UBI volumes. Usage is as follows:

./stm32h7-som-uboot-install.kermit <tty> <uboot_img>
  • tty - is a serial device name as seen on the Linux host, e.g. /dev/ttyUSB0, where the debug console of the STM32H750 is connected to (mandatory);

  • uboot_img - is the path to the main U-Boot image, i.e. u-boot.img (mandatory).

  • No labels