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 NXP i.MX RT1060 EVK board, loadaddr is set as follows, placing the download buffer into the on-module SDRAM:
=> print loadaddr
loadaddr=0x80007fc0
=>
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 SD Card:
=> setenv ethaddr C0:B1:3D:88:88:89
=> setenv ipaddr 192.168.1.151
=> setenv serverip 192.168.1.65
=> saveenv
Saving Environment to FAT...
writing uboot.env
done
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), 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:
=> print netboot
netboot=tftp ${tftpdir}${image} && run addip && bootm ${loadaddr}
=>
What netboot does is load from tftpdir in 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 (rootfs.uImage) included in the Emcraft software distribution. Copy rootfs.uImage to the appropriate (tftpdir) TFTP directory on the host and then from U-Boot on the target set the image environment variable to point to the image:
=> setenv tftpdir imxrt106x/
=> setenv image rootfs.uImage
=> saveenv
Saving Environment to FAT...
writing uboot.env
done
=> run netboot
ethernet@402D8000 Waiting for PHY auto negotiation to complete....... done
Using ethernet@402D8000 device
TFTP from server 192.168.1.65; our IP address is 192.168.1.151
Filename 'imxrt106x/rootfs.uImage'.
Load address: 0x80007fc0
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
########
1.7 MiB/s
done
Bytes transferred = 7749634 (764002 hex)
## Booting kernel from Legacy Image at 80007fc0 ...
Image Name: Linux-4.5.0-cortexm-2.5.0
Image Type: ARM Linux Multi-File Image (uncompressed)
Data Size: 7749570 Bytes = 7.4 MiB
Load Address: 80008000
Entry Point: 80008001
Contents:
Image 0: 7739904 Bytes = 7.4 MiB
Image 1: 9654 Bytes = 9.4 KiB
Verifying Checksum ... OK
## Flattened Device Tree from multi component Image at 80007FC0
Booting using the fdt at 0x80769a0c
Loading Multi-File Image ... OK
Loading Device Tree to 81e77000, end 81e7c5b5 ... OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 4.5.0-cortexm-2.5.0 (
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
) (gcc version 4.7.4 20130508
(prerelease) (20170818-165657- build on build.emcraft by build) )
#1 Tue Oct 17 01:50:48 +0400 2017
...
init started: BusyBox v1.24.2 (2017-10-17 01:49:35 +0400)
...
/ # ps
PID USER VSZ STAT COMMAND
1 root 396 S init
2 root 0 SW [kthreadd]
3 root 0 SW [ksoftirqd/0]
4 root 0 SW [kworker/0:0]
5 root 0 SW< [kworker/0:0H]
6 root 0 SW [kworker/u2:0]
7 root 0 SW [kdevtmpfs]
8 root 0 SW< [writeback]
9 root 0 SW< [crypto]
10 root 0 SW< [bioset]
11 root 0 SW< [kblockd]
12 root 0 SW< [rpciod]
13 root 0 SW [kworker/0:1]
14 root 0 SW [kswapd0]
15 root 0 SW< [nfsiod]
33 root 0 SW< [ci_otg]
34 root 0 SW< [ft5x0x_ts]
35 root 0 SW [irq/46-mmc0]
36 root 0 SW< [ipv6_addrconf]
37 root 0 SW [kworker/0:2]
38 root 0 SW< [deferwq]
39 root 0 SW [kworker/u2:1]
47 root 0 SW< [bioset]
50 root 0 SW [mmcqd/0]
56 root 0 SW< [kworker/0:1H]
67 root 3248 S {sbengine} /crankdemo/uclinux-stm32f7-armle-fbdev-ob
74 root 404 S dropbear
76 root 432 S -/bin/hush
78 root 3248 S {sbengine} /crankdemo/uclinux-stm32f7-armle-fbdev-ob
80 root random: nonblocking pool is initialized
3248 S {sbengine} /crankdemo/uclinux-stm32f7-armle-fbdev-ob
92 root 3248 S {sbengine} /crankdemo/uclinux-stm32f7-armle-fbdev-ob
93 root 3248 S {sbengine} /crankdemo/uclinux-stm32f7-armle-fbdev-ob
94 root 404 R ps
Here are some troubleshooting tips, in case tftpboot does not work for you from U-Boot:
- As trivial as it sounds make sure that the board is connected to the LAN with an Ethernet cable.
- 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.
- Make sure you have copied a file you are trying to download to the TFTP server directory on the host.
- Disable the firewall on the host since get enabled, it will block TFTP requests from the target.
- 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 NXP i.MX RT1060 EVK board) configured for the same MAC address.