Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

Code Block
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 RT10XX EVKB board, loadaddr is set as follows, placing the download buffer into the on-module SDRAM:

Code Block
=> 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:

Code Block
=> setenv ethaddr aa:bb:cc:dd:ee:d0
=> setenv ipaddr 192.168.1.86
=> setenv serverip 192.168.1.96
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK

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:

Code Block
=> print netboot
netboot=tftp ${tftpdir}${image} && run addip && bootm
=>

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:

Code Block
=> run netboot
Using ethernet@402d8000 device
TFTP from server 192.168.1.96; our IP address is 192.168.1.86
Filename 'imxrt1050/rootfs.uImage'.
Load address: 0x80007fc0
...

         #########################################################
         109.4 KiB/s
done
Bytes transferred = 8661287 (842927 hex)
## Booting kernel from Legacy Image at 80007fc0 ...
   Image Name:   Linux-6.6.36
   Image Type:   ARM Linux Multi-File Image (uncompressed)
   Data Size:    8661223 Bytes = 8.3 MiB
   Load Address: 80008000
   Entry Point:  80008001
   Contents:
      Image 0: 8649380 Bytes = 8.2 MiB
      Image 1: 11831 Bytes = 11.6 KiB
   Verifying Checksum ... OK
## Flattened Device Tree from multi component Image at 80007FC0
   Booting using the fdt at 0x80847ab0
Working FDT set to 80847ab0
   Loading Multi-File Image to 80008000
   Loading Device Tree to 81dfa000, end 81dffe36 ... OK
Working FDT set to 81dfa000

Starting kernel ...

Booting Linux on physical CPU 0x0
...
Run /init as init process
[51] Jan 01 04:19:58 Running in background
/ # Micrel KSZ8081 or KSZ8091 402d8000.ethernet-1:02: attached PHY driver (mii_bus:phy_addr=402d8000.ethernet-1:02, irq=POLL)
fec 402d8000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
random: crng init done
/ # ps
 PID USER       VSZ STAT COMMAND
    1 root       876 S    init
    2 root         0 SW   [kthreadd]
    3 root         0 SW   [pool_workqueue_]
    4 root         0 IW<  [kworker/R-rcu_g]
    5 root         0 IW<  [kworker/R-rcu_p]
    6 root         0 IW<  [kworker/R-slub_]
    7 root         0 IW<  [kworker/R-netns]
    8 root         0 IW   [kworker/0:0-eve]
    9 root         0 IW<  [kworker/0:0H-ev]
   10 root         0 IW   [kworker/0:1-dev]
   11 root         0 IW   [kworker/u2:0-ev]
   12 root         0 IW<  [kworker/R-mm_pe]
   13 root         0 SW   [ksoftirqd/0]
   14 root         0 IW   [rcu_preempt]
   15 root         0 SW   [kdevtmpfs]
   16 root         0 IW<  [kworker/R-inet_]
   17 root         0 IW   [kworker/u2:1-ev]
   18 root         0 IW<  [kworker/R-write]
   19 root         0 IW<  [kworker/R-kbloc]
   20 root         0 IW<  [kworker/0:1H-kb]
   21 root         0 IW<  [kworker/R-rpcio]
   22 root         0 IW<  [kworker/R-xprti]
   23 root         0 IW<  [kworker/R-cfg80]
   24 root         0 SW   [kswapd0]
   25 root         0 IW<  [kworker/R-nfsio]
   27 root         0 IW<  [kworker/R-uas]
   28 root         0 IW<  [kworker/u3:0]
   29 root         0 IW<  [kworker/R-sdhci]
   30 root         0 SW   [irq/190-mmc0]
   31 root         0 SW<  [krfcommd]
   32 root         0 IW<  [kworker/R-mmc_c]
   33 root         0 IW   [kworker/u2:2]
   34 root         0 IW<  [kworker/R-ft5x0]
   35 root         0 IW   [kworker/0:2-pm]
   36 root         0 IW<  [kworker/R-ci_ot]
   51 root       728 S    dropbear -R
   53 root       888 S    -/bin/hush
   74 root       884 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 NXP i.MX RT1050 EVK board) configured for the same MAC address.