Building and Self-Updating U-Boot on the STM32F4 System-On-Module Print


As explained in the other application notes available from the Emcraft web site, each STM32F4 System-On-Module is shipped by Emcraft with U-Boot installed to the on-chip Flash of the STM32F4. When you power-on the SOM, U-Boot is immediatelly available on the STM32F4 module 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 STM32F4 module.

The full U-Boot source for the STM32F4 SOM 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 STM32F4 SOM are as follows:

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

Run the folowing step-wise procedure in order to build U-Boot for the STM32F4 SOM:

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

  • Change to the U-Boot top directory:
  • -bash-3.2$ cd u-boot

  • Configure U-Boot for the STM32F4-SOM:
  • -bash-3.2$ make distclean
    -bash-3.2$ make stm-som_config

  • Build the U-Boot binary:
  • -bash-3.2$ make -s

The resultant image will be u-boot.bin in the U-Boot top directory (i.e. the same directory where you have run the make command from).

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. Typically, you download images from a TFTP host (refer to Loading Linux images via Ethernet and TFTP), however in absence of an Ethernet link in your specific target configuraiton, you can also load images over serial UART (refer to Loading Linux Images over UART).

The following session is an illustration of the U-Boot self-upgrade procedure:

  • From the U-Boot command line interface, download the upgrade U-Boot image to RAM:
  • STM32F4X9-SOM> tftp psl/stmf4/u-boot.bin
    Auto-negotiation...completed.
    STM32_MAC: link UP (100/Half)
    Using STM32_MAC device
    TFTP from server 172.17.0.1; our IP address is 172.17.4.206
    Filename 'psl/stmf4/u-boot.bin'.
    Load address: 0xc0007fc0
    Loading: #######
    done
    Bytes transferred = 99732 (18594 hex)

  • Run the U-Boot self-upgrade command to install the loaded upgrade image to the on-chip Flash. Note that the command updates the U-Boot image in the on-chip Flash and then immediatelly performs the reboot sequence to boot the newly installed U-Boot image:
  • STM32F4X9-SOM> cptf 0x08000000 ${loadaddr} ${filesize} 1
    cptf: Updating eNVM. Please wait ...

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

    CPU : STM32F4 (Cortex-M4)
    Freqs: SYSCLK=180MHz,HCLK=180MHz,PCLK1=45MHz,PCLK2=90MHz
    Board: STM-SOM Rev 2.A, www.emcraft.com
    DRAM: 32 MB
    Flash: 16 MB
    In: serial
    Out: serial
    Err: serial
    Net: STM32_MAC
    Hit any key to stop autoboot: 0
    STM32F4X9-SOM>

Note that the self-upgrade sequence is a dangerous operation. You must be sure that you load and install a functional U-Boot binary, which is always a tricky thing when you develop customisations to U-Boot. Make sure you have a JTAG programmer handy that you will be able to use in order to re-install the release U-Boot binary in case you have programmed a wrong U-Boot image to the on-chip Flash. The latest U-Boot binary is always available from STM32F4 System-On-Module Release Materials.