Building and self-updating U-Boot on the STM32H7 SOM Print


Installing U-Boot to the STM32H7 SOM explains how to install the U-Boot firmware to the board for the first time. Having installed U-Boot, U-Boot is immediately available on the STM32H7 SOM as a primary firmware monitor.

The default U-Boot configuration is a capable Linux bootloader so typically our customers do not require re-building and re-installing U-Boot. However, certain projects still do require customizations to the U-Boot firmware, which implies making changes to the U-Boot code, rebuilding the U-Boot binary and then updating it on the STM32H7 SOM.

Building U-Boot

The full U-Boot source for the Emcraft STM32H7 SOM board is included in the software distribution available from the Emcraft web site. Refer to the u-boot/ sub-directory in the software distribution tree.

The key board specific-configuration files for the Emcraft STM32H7 SOM board are as follows:

  • u-boot/configs/stm32h7_som_nor_defconfig - default U-Boot configuration;
  • u-boot/include/configs/stm32h7-som.h - configuration options;
  • u-boot/board/emcraft/stm32h7-som/stm32h7-som.c - board-specific initialization code.

Step through the following procedure to build U-Boot for the Emcraft STM32H7 SOM board:

  1. On the Linux development host, activate the cross-build environment as described in Installing and activating cross development environment:
  2. $ . ./ACTIVATE.sh

  3. Change to the U-Boot top directory:
  4. $ cd u-boot

  5. Configure U-Boot for the Emcraft STM32H7 SOM board:
  6. $ make distclean
    $ make stm32h7_som_nor_defconfig

  7. Run make to create the u-boot.img binary:
  8. $ make -s

Upgrading U-Boot "Proper" via Ethernet

The U-Boot command line interface provides a special command that can be used to self-upgrade the U-Boot image on the running target. Before you can run this command, you need to load an upgrade U-Boot binary to the target via Ethernet from a TFTP host, refer to Building and Installing Linux uImage on the STM32H7 SOM for details of the network configuration.

Step through the following procedure to upgrade the U-Boot "Proper" via Ethernet using the previously installed U-Boot:

  1. Copy the U-Boot image to the TFTP server, adjust the uboot_image environment variable, if needed:
  2. STM32H7-SOM U-Boot > printenv uboot_image uboot_image=stm32h7/u-boot.img STM32H7-SOM U-Boot >

  3. Download the U-Boot image from the TFTP server and install it to the QSPI Flash:
  4. STM32H7-SOM U-Boot > run uboot_upgrade Using ethernet@40028000 device TFTP from server 192.168.0.3; our IP address is 192.168.0.166 Filename 'stm32h7/u-boot.img'. Load address: 0xd0c00000 Loading: ################################### 118.2 KiB/s done Bytes transferred = 501469 (7a6dd hex) Erasing 0x00000000 ... 0x000fffff (8 eraseblock(s)) Size not on a page boundary (0x800), rounding to 0x7a800 Writing 501760 byte(s) (245 page(s)) at offset 0x00000000 STM32H7-SOM U-Boot >

  5. Verify that the new U-Boot has been successfully installed. Reset the SOM by pressing the S3 button on the carrier board and confirm that the U-Boot has been upgraded:
  6. U-Boot SPL 2019.04-gec287f63c5 (Jun 16 2023 - 14:31:30 +0000) Hit 's' key to enter spl shell: Trying to boot from SPI U-Boot 2019.04-gd8814bf0d6 (Jun 16 2023 - 21:37:24 +0000) ...

Note that the self-upgrade sequence is a dangerous operation. You must be sure that you load and install a functional U-Boot image, which is always a tricky thing when you develop customizations to U-Boot. If something goes wrong, you can re-install the release U-Boot image as documented in Installing U-Boot to the STM32H7 SOM.