Loading Linux Images via Ethernet and TFTP Print

 

This note explains how to load images to the target via Ethernet. With an Ethernet connection available, U-Boot can load images from a TFTP host quickly and easily.

Please refer to Connecting to Ethernet on the STM32F429 Discovery for information on how to connect the STM32F429 Discovery to Ethernet.

The download procedure is based on the tftpboot command provided by the U-Boot command interface. tftboot implements a download capability over Ethernet using the TFTP protocol and has the following synopsis:

tftpboot <file> [<load_addr>]

If you do not specify a load address, then the value will be taken from the loadaddr environment variable. On the STM32F429 Discovery loadaddr is set as follows, placing the download buffer into SDRAM:

STM32F429-DISCO> print loadaddr
loadaddr=0xD0007FC0

The MAC address of the Ethernet interface is defined by the ethaddr environment variable.The IP address of the board is defined by the ipaddr U-Boot environment variable. The TFTP server IP address is defined by the serverip U-Boot environment variable. Make sure you define these environment variables to values that make sense for your LAN and save them in the internal Flash of the STM32F429:

STM32F429-DISCO> setenv ethaddr C0:B1:3D:88:88:89
STM32F429-DISCO> setenv ipaddr 172.17.6.136
STM32F429-DISCO> setenv serverip 172.17.0.1
STM32F429-DISCO> savee
Saving Environment to envm...
STM32F429-DISCO>

Once the transmission using tftpboot finishes, the file will be in memory at the specified load address. The loadaddr environment variable will automatically be set to the address the tftpboot command used. The filesize environment variable will automatically be set to the number of bytes transferred during the load operation.

Then you are free to do whatever you like with the loaded image. You can boot Linux from the image (assuming it is a Linux uImage file), copy it to some other place (for instance, embedded Flash), display the memory, etc.

One typical command sequence involving tftpboot is defined in the netboot environment variable, which by default is set in U-Boot as follows:

STM32F429-DISCO> print netboot
netboot=tftp ${image};run args addip;bootm

What netboot does is load from a TFTP host a file defined by image (the tftp command), then add the TCP/IP related parameters to the kernel command string (addip), and finally boot Linux from the just loaded image (bootm).

Let's use netboot to boot Linux via TFTP from the sample Linux image (networking.uImage) included in the Emcraft software distribution. Copy networking.uImage to the TFTP directory on the host and then from U-Boot on the target set the image environment variable to point to the image:

STM32F429-DISCO> setenv image vlad/networking.uImage
STM32F429-DISCO> savee
Saving Environment to envm...

Then just run netboot to boot Linux via TFTP:

STM32F429-DISCO> run netboot
Auto-negotiation...completed.
STM32_MAC: link UP (100/Full)
Using STM32_MAC device
TFTP from server 172.17.0.1; our IP address is 172.17.6.136
Filename 'vlad/networking.uImage'.
Load address: 0xd0007fc0
Loading: #################################################################
############################################
done
Bytes transferred = 1592224 (184ba0 hex)
## Booting kernel from Legacy Image at d0007fc0 ...
Image Name: Linux-2.6.33-arm1
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1592160 Bytes = 1.5 MB
Load Address: d0008000
Entry Point: d0008001
Verifying Checksum ... OK
Loading Ker
nel Image ... OK
OK

Starting kernel ...

Linux version 2.6.33-arm1 ( This e-mail address is being protected from spambots. You need JavaScript enabled to view it ) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #345 Fri Jan 3 12:34:36 +0400 2014
CPU: ARMv7-M Processor [410fc241] revision 1 (ARMv7M)
...
init started: BusyBox v1.17.0 (2014-01-02 18:24:02 +0400)
~ # ps
PID USER VSZ STAT COMMAND
1 root 360 S init
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
4 root 0 SW [events/0]
5 root 0 SW [khelper]
6 root 0 SW [async/mgr]
7 root 0 SW [sync_supers]
8 root 0 SW [bdi-default]
9 root 0 SW [kblockd/0]
10 root 0 SW [rpciod/0]
11 root 0 SW [kswapd0]
12 root 0 SW [nfsiod]
18 root 367 S /bin/hush -i
19 root 348 R ps
~ #

Here are some troubleshooting tips, in case tftpboot does not work for you from U-Boot:

  1. Make sure that board is ready for Ethernet from the hardware point of view. This is explained in detail in Connecting to Ethernet on the STM32F429 Discovery. If just a single of the required re-works is implemented incorrectly, Ethernet won't work for you on the Discovery. Also, unless you are using the Ethernet RMII board other than the one recommended by Emcraft, it is likely that some modifications in U-Boot are needed to support a different Ethernet PHY. If you are not getting past the "Autonegotiation completed" phase when running a tftpboot command from U-Boot, it probably implies that something is wrong with your set-up from the hardware point of view:
  2. STM32F429-DISCO> run netboot
    Auto-negotiation...completed.

  3. Ok, suppose the autonegotiation completes, but you are not getting your file from the TFTP server. It is possible that the problem is on the host side - you must set up a TFTP server correctly. Just google for "how to set up a tftp server" and follow the advice from a few top articles.
  4. Make sure you have copied a file you are trying to download to the TFTP server directory on the host.
  5. Disable the firewall on the host since get enabled, it will block TFTP requests from the target.
  6. On the target, make sure that you have set ipaddr and serverip correctly. Check ethaddr and make sure that you don't have another embedded board (eg. another Discovery) configured for the same MAC address.