Loading Linux Images via Ethernet and TFTP |
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 STM32F4 SOM, loadaddr is set as follows, placing the download buffer into the on-module SDRAM: STM32F4X9-SOM> print loadaddr 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 NOR Flash: STM32F4X9-SOM> setenv ipaddr 172.17.6.136 Note that the ethaddr variable is preset by Emcraft to a unique MAC address at the factory. To avoid possible conflicts in a LAN, we do not recommend updating ethaddr although you have this option in case you require it for some reason: STM32F4X9-SOM> printenv ethaddr 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 bootable Linux file), copy it to some other place (for instance, NOR 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: STM32F4X9-SOM> print netboot 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 (the args and addip commands), and finally boot Linux from the just loaded image (the bootm command). 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 TFTP directory on the host and then from U-Boot on the target set the image environment variable to point to the Linux file: STM32F4X9-SOM> set image vlad/rootfs.uImage You must set up a TFTP server on the development host to allow downloading images to the target over Ethernet. The procedure is extensively documented in the Internet. Just google for "how to set up a tftp server" and follow the advice from some top articles. Here are some troubleshooting tips, in case tftpboot does not work for you from U-Boot:
|