Running U-Boot (uClinux)

As explained in , you have to install U-Boot to the STM32H7 SOM in order to run Linux (uClinux) on the Emcraft STM32H7 SOM board. U-Boot runs as the primary firmware on each power-on / reset. Please refer to for details of the boot architecture.

U-Boot is probably the most popular firmware monitor for Linux. It is developed and maintained by DENX Software Engineering ( If you need detailed information on any aspects of U‑Boot operation, DENX publishes extensive U‑Boot user documentation at their web site.

As soon as the Emcraft STM32H7 SOM board is powered on or reset, the STM32H7 proceeds to boot the U‑Boot firmware from the internal and external Flash printing the following output to the serial console:

U-Boot SPL 2019.04- (May 03 2024 - 06:09:05 +0000) Hit 's' key to enter spl shell: Trying to boot from SPI U-Boot 2019.04-(May 03 2024 - 06:09:05 +0000) 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: 256 ubi0: default fastmap WL pool size: 128 ubi0: attaching mtd2 ubi0: scanning is finished ubi0: attached mtd2 (name "system", size 31 MiB) ubi0: PEB size: 4096 bytes (4 KiB), LEB size: 3968 bytes ubi0: min./max. I/O unit sizes: 1/256, sub-page size 1 ubi0: VID header offset: 64 (aligned 64), data offset: 128 ubi0: good PEBs: 7936, bad PEBs: 0, corrupted PEBs: 0 ubi0: user volume: 4, internal volumes: 1, max. volumes count: 23 ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 0 ubi0: available PEBs: 1518, total reserved PEBs: 6418, PEBs reserved for bad PEB handling: 0 Read 16384 bytes from volume env1 to d196f520 Read 16384 bytes from volume env2 to d1973540 *** Warning - bad CRC, using default environment In: serial Out: serial Err: serial Volume splash not found! splash_screen_display: ubi_volume_read error=19 Net: Error: ethernet@40028000 address not set. eth-1: ethernet@40028000 Hit any key to stop autoboot: 0

If you hit any key on the serial console before the number of seconds defined by the U-Boot bootdelay variable has elapsed, you will enter the U-Boot interactive command monitor. From the command monitor you can run U‑Boot commands to examine memory, load an image from Ethernet, boot Linux from a loaded image or perform any other action supported by U-Boot.

U-Boot makes use of the so-called environment variables to define various aspects of the target functionality. On the Emcraft STM32H7 SOM board, the U-Boot environment is stored in the QSPI Flash and is persistent across power or reset cycles. Parameters defined by the U-Boot environment variables include: target IP address, target MAC address, location in RAM where a Linux bootable image will be loaded, and many others.

To manipulate the U-Boot environment the following commands are used:

  • printenv <var> - print the value of the variable <var>. Without arguments, prints all environment variables:

    STM32H7-SOM U-Boot> printenv addclk=setenv bootargs ${bootargs} clk_ignore_unused addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}: ${netmask}:${hostname}:eth0:off altbootcmd=run reliable_altboot baudrate=115200 boot1_valid=1 boot2_active=0 ... upgrade_available=0 Environment size: 3961/16379 bytes STM32H7-SOM U-Boot>
  • setenv <var> <val> - set the variable <var> to the value <val>:

    STM32H7-SOM U-Boot> setenv image my.rootfs.uImage STM32H7-SOM U-Boot>
  • saveenv - save the up-to-date U-Boot environment, possibly updated using setenv commands, into the QSPI Flash. Running saveenv makes sure that any updates you have made to the U-Boot environment are persistent across power cycles and resets.