Running U-Boot Print

 

As explained in Installing U-Boot to the STM32H7 SOM], 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 Understanding STM32H7 SOM Boot Architecture 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 (www.denx.de). 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-gec287f63c5 (Jun 16 2023 - 14:31:30 +0000) Hit 's' key to enter spl shell: Trying to boot from SPI U-Boot 2019.04-gec287f63c5 (Jun 16 2023 - 14:31:30 +0000) Model: STMicroelectronics STM32H7 SOM DRAM: 28 MiB Flash: 128 KiB MMC: STM32 SDMMC2: 0 Loading Environment from UBI... ubi0: default fastmap pool size: 8 ubi0: default fastmap WL pool size: 4 ubi0: attaching mtd2 ubi0: scanning is finished ubi0: attached mtd2 (name "system", size 23 MiB) ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048 ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096 ubi0: good PEBs: 184, bad PEBs: 0, corrupted PEBs: 0 ubi0: user volume: 2, internal volumes: 1, max. volumes count: 128 ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 0 ubi0: available PEBs: 156, total reserved PEBs: 28, PEBs reserved for bad PEB handling: 20 Read 16384 bytes from volume env1 to d1e6d6e0 Read 16384 bytes from volume env2 to d1e71700 *** 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: 4056/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.
  • STM32H7-SOM U-Boot > saveenv Saving Environment to UBI... ubi0: detaching mtd2 ... Writing to UBI... done OK STM32H7-SOM U-Boot >