Running U-Boot Print

 

As explained in Installing U-Boot to the STM32F7 Discovery board, you have to install U-Boot to the internal Flash of the STM32F7 Discovery board in order to run Linux (uClinux) on the STM32F7 Discovery board. U-Boot runs as the primary firmware from the internal Flash on each power-on / reset.

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.

On the STM32F7 microcontrollers, U-Boot runs directly from the internal Flash. Volatile data (stack, variables, dynamic pool) are maintained in the internal SRAM. External RAM is not used unless you explicitly call a U-Boot command with an argument pointing to a memory location in SDRAM.

As soon as the STM32F7 Discovery board is powered on or reset, the STM32F7 proceeds to boot the U-Boot firmware from the internal Flash printing the following output to the serial console:

U-Boot 2010.03-cortexm-1.14.2 (Sep 04 2015 - 20:10:20)

CPU : STM32F7 (Cortex-M7)
Freqs: SYSCLK=200MHz,HCLK=200MHz,PCLK1=50MHz,PCLK2=100MHz
Board: STM32F746 Discovery Rev 1.A, www.emcraft.com
DRAM: 8 MB
In: serial
Out: serial
Err: serial
Net: STM32_MAC
Hit any key to stop autoboot: 0
STM32F746-DISCO>

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 STM32F7 Discovery board, the U-Boot environment is stored in the on-chip 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:
  • STM32F746-DISCO> printenv
    bootdelay=3
    baudrate=115200
    hostname=stm32f7-disco
    loadaddr=0xC0007FC0
    addip=setenv bootargs ${bootargs}
    ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:eth0:off
    ...
    Environment size: 782/4092 bytes
    STM32F746-DISCO>

  • setenv <var><val> - set the variable <var> to the value <val>:
  • STM32F746-DISCO> setenv image antonp/networking.uImage
    STM32F746-DISCO>

    Running setenv <var> will unset (undefine) a specified U-Boot variable.

  • saveenv - save the up-to-date U-Boot environment, possibly updated using setenv commands, into internal Flash. Running saveenv makes sure that any updates you have made to the U-Boot environment are persistent across power cycles and resets.
  • STM32F746-DISCO> saveenv
    Saving Environment to envm...
    STM32F746-DISCO>

The autoboot sequence in U-Boot is controlled by the two environment variables called bootdelay and bootcmd.

The bootdelay variable defines a delay, in seconds, before running the autoboot command defined by bootcmd. During the bootdelay countdown, you can interrupt the autobooting by pressing any key. This will let you enter the U-Boot command line interface.

The bootcmd variable defines a command executed by U-Boot automatically after the bootdelay countdown is over. Typically, this would be run netboot to boot Linux from TFTP during development or run flashboot to boot Linux from the NOR Flash on deployed units.

In deployed configurations, where boot time to the service provided by your embedded device is critical, you will probably want to set bootdelay to 0:

STM32F746-DISCO> sete bootdelay 0
STM32F746-DISCO> savee
Saving Environment to envm...
STM32F746-DISCO>

This will make sure that on each power on / reset U-Boot immediately executes the command defined by bootcmd, typically booting Linux from the on-module Flash.

With bootdelay set to 0 the U-Boot countdown is disabled, so there is a question how you enter the U-Boot command monitor, should you need to enter it for some reason. To do so, push the Ctrl-C keys down and don't release them until you have hit the reset button on the board. This will interrupt the U-Boot bootcmd sequence and let you enter the U-Boot command monitor:

U-Boot 2010.03-cortexm-1.14.1 (Jun 26 2015 - 12:03:51)

CPU : STM32F7 (Cortex-M7)
Freqs: SYSCLK=200MHz,HCLK=200MHz,PCLK1=50MHz,PCLK2=100MHz
Board: STM32F746 Discovery Rev 1.A, www.emcraft.com
DRAM: 8 MB
In: serial
Out: serial
Err: serial
Net: STM32_MAC
Hit any key to stop autoboot: 0
STM32F746-DISCO>
STM32F746-DISCO> <INTERRUPT>

From the command monitor, you would be able to reset bootdelay to 3 or whatever value makes sense to you.