Login

Why register?

  • Download software and technical materials
  • Purchase products at our on-line shop
  • Receive design news to stay up-to-date with Emcraft's new solutions

 

 

Installing Linux Images to Flash Print


This note explains how to install a bootable Linux image to the NOR Flash on the STM32F7 Discovery board. Having installed a Linux image to the Flash, you would be able to boot Linux on the target automatically on any power up or reset cycle. This is the mode of operation that is typically used for deployed production units.

 

The example below refers to rootfs.uImage. This image is included as a prebuilt binary in the software distribution so you can always use it to revert to the factory default software, should you need to do that at some point. As mentioned above though, the process below will work for any bootable Linux image you build using the Emcraft software distribution.

Before you proceed to install a Linux image to the NOR Flash, it probably makes sense to verify that what you have is indeed a bootable Linux image. You can do that by loading the image to the target from the network using the run netboot command (refer to Loading Linux Images via Ethernet and TFTP). It is important to understand that the same uImage that you load via TFTP can be loaded from the Flash as well. It doesn't make sense to install a Linux image to the Flash unless you have validated the image by loading it via Ethernet and TFTP.

The U-Boot command sequence required to install a Linux image to the NOR Flash is defined for you by the U-Boot environment variable called update. Here is how update is defined in U-Boot by default:

STM32F769I-DISCO> print update
update=tftp ${image} && qspi erase 0 ${filesize} && qspi write ${loadaddr} 0 ${filesize} && echo 'Successfully updated'
STM32F769I-DISCO>

You will notice that the first command in update is a tftpboot command to download an image from the network via Ethernet and TFTP. Please refer to Loading Linux Images via Ethernet and TFTP for detailed information on how to set up your target and the development host for loading images from TFTP. Following tftpboot, there is a sequence of commands that erase those Flash sections where the Linux image will be installed to and then copy the image to the Flash.

Here is a snapshot showing how update is used to install rootfs.uImage to the Flash:

STM32F769I-DISCO> sete image stm32f7/rootfs.uImage
STM32F769I-DISCO> saveenv
Saving Environment to envm...
...
STM32F769I-DISCO> run update
Auto-negotiation...completed.
STM32_MAC: link UP (100/Half)
Using STM32_MAC device
TFTP from server 192.168.1.65; our IP address is 192.168.1.132
Filename 'stm32f7/rootfs.uImage'.
Load address: 0xc0007fb4
Loading:
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##
done
Bytes transferred = 5773923 (581a63 hex)
............................................. done
Un-Protected 45 sectors

............................................. done
Erased 45 sectors
Copy to Flash... done
Saving Environment to Flash...
...

Having installed an image to the Flash, just hit the Reset button on the baseboard to boot the newly installed image from Flash:

U-Boot 2010.03-cortexm-2.3.2 (Mar 12 2017 - 11:18:48)

CPU : STM32F7 (Cortex-M7)
Freqs: SYSCLK=216MHz,HCLK=216MHz,PCLK1=54MHz,PCLK2=108MHz
Board: STM32F769I-DISCO Revision B-01, www.emcraft.com
DRAM: 16 MB
...
## Booting kernel from Legacy Image at 90000000 ...
Image Name: Linux-4.2.0-cortexm-2.3.2
Image Type: ARM Linux Multi-File Image (uncompressed)
Data Size: 5773859 Bytes = 5.5 MB
Load Address: c0008000
Entry Point: c0008001
Contents:
Image 0: 5756576 Bytes = 5.5 MB
Image 1: 17271 Bytes = 16.9 kB
Verifying Checksum ... OK
## Flattened Device Tree from multi component Image at 60020000
Booting using the fdt at 0x6059d6ec
Loading Multi-File Image ... OK
OK
Loading Device Tree to c1ff8000, end c1fff376 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.2.0-cortexm-2.3.2 (psl@skywanderer.emcraft.com) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #2 Mon Mar 13 11:19:44 MSK 2017
...
init started: BusyBox v1.17.0 (2017-03-13 11:07:14 MSK)
/ #

On deployed units, you will probably want to optimize the boot time by setting the U-Boot bootdelay variable to 0. Please refer to Autobooting Linux from U-Boot for detailed information on how to do that.