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. This is the development and software manufacturing option that is preferable with U-Boot and Linux.

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 VF6 SOM, loadaddr is set as follows, placing the download buffer into the on-module SDRAM:

Vybrid U-Boot > print loadaddr
loadaddr=0x80007FC0
Vybrid U-Boot >

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 on-module NAND Flash:

Vybrid U-Boot >  setenv ethaddr C0:B1:3C:88:88:89
Vybrid U-Boot >  setenv ipaddr 172.17.44.46
Vybrid U-Boot >  setenv serverip 172.17.0.1
saveenv
...
Vybrid U-Boot >

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, NAND 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:

Vybrid U-Boot > print netboot
netboot=tftp ${image};run args addip;bootm
Vybrid U-Boot >

What netboot does is load from a TFTP host a file defined by image (the tftp command), then add the general parameters (args) as well as the TCP/IP related parameters (addip) to the kernel command string, 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:

Vybrid U-Boot > set image vlad/networking.uImage
Vybrid U-Boot > saveenv
...
Vybrid U-Boot > run netboot
Using FEC0 device
TFTP from server 172.17.0.1; our IP address is 172.17.44.46
Filename 'vlad/networking.uImage'.
Load address: 0x80007fc0
Loading: ###################################################################### ###############
done
Bytes transferred = 3057956 (2ea924 hex)
## Booting kernel from Legacy Image at 80007fc0 ...
Image Name: Linux-3.0.15-linux-vf6-1.14.0
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3057892 Bytes = 2.9 MiB
Load Address: 80008000
Entry Point: 80008000
XIP Kernel Image ... OK
OK
Starting kernel ...

Linux version 3.0.15-vf6-1.14.0 (vlad@ocean.emcraft.com)(gcc version 4.7.2 (GCC)) #10 Tue Apr 28 17:54:32 +0400 2015
...
CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c53c7d
...
Freeing init memory: 3408K
init started: BusyBox v1.17.0 (2014-06-03 16:33:34 +0400)
...
~ # ps
PID USER       VSZ STAT COMMAND
1 root       356 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]
13 root        0 SW   [mtdblockd]
19 root      371 S    /bin/hush -i
20 root      352 R    ps
~ #

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

  1. As trivial as it sounds make sure that the board is connected to the LAN with an Ethernet cable.
  2. Suppose you are still 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 some top articles.
  3. Make sure you have copied a file you are trying to download to the TFTP server directory on the host.
  4. Disable the firewall on the host since get enabled, it will block TFTP requests from the target.
  5. 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 VF6 SOM) configured for the same MAC address.