IMX6ULL porting - uboot network command tftp

1. Introduction to tftp command

The function of the tftp command is the same as that of the nfs command, which is used to download files to the DRAM of the development board through the network.
This article learns the use of the tftp command. Download the file to the DRAM of the development board through the tftp service.

Two. tftp command

1. tftp command

The tftp command format in uboot is as follows:

tftpboot [loadAddress] [[hostIPaddr:]bootfilename] 

loadAddress is the storage address of the file in the DRAM of the development board ,
[[hostIPaddr:]bootfilename] is the file to be downloaded from Ubuntu .
However, the difference from the nfs command is that   the tftp command does not need to enter the full path of the file in Ubuntu , only the file name. 

2. Build tftp environment

(1)  To build a TFTP server on Ubuntu , you need to install tftp-hpa and tftpd-hpa . The installation command is as follows:

wangtian@wangtian-virtual-machine:/etc/apt$ sudo apt-get install tftp-hpa tftpd-hpa

(2)  Like NFS , tftp also needs a folder to store files, and create a directory under the ubuntu system.

The operation is as follows:

wangtian@wangtian-virtual-machine:~/linux$ mkdir tftp_file
wangtian@wangtian-virtual-machine:~/linux$ cd tftp_file/
wangtian@wangtian-virtual-machine:~/linux/tftp_file$ pwd
/home/wangtian/linux/tftp_file

(3)  To change the access rights of the created file, enter the following command:

wangtian@wangtian-virtual-machine:~/linux$ chmod 777 tftp_file

(4)   Configure tftp: Create a new file /etc/xinetd.d/tftp after the installation is complete. If there is no /etc/xinetd.d directory, it needs to be created.

Create the /etc/inetd.d directory:

wangtian@wangtian-virtual-machine:/$ sudo mkdir /etc/xinetd.d
[sudo] wangtian 的密码: 
wangtian@wangtian-virtual-machine:/$ cd /etc/xinetd.d/
wangtian@wangtian-virtual-machine:/etc/xinetd.d$ 

Create a tftp file as follows:

wangtian@wangtian-virtual-machine:/etc/xinetd.d$ sudo gedit tftp

The content of the tftp file is as follows:

server tftp
{
	socket_type = dgram
	protocol = udp
	wait = yes
	user = root
	server = /usr/sbin/in.tftpd
	server_args = -s /home/wangtian/linux/tftp_file
	disable = no
	per_source = 11
	cps = 100 2
	flags = IPv4
}

Change the /etc/default/tftpd-hpa file as follows:
Open the tftpd-hpa file and enter the following command:
wangtian@wangtian-virtual-machine:~$ sudo gedit /etc/default/tftpd-hpa

The tftpd-hpa file is changed as follows:

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/home/wangtian/linux/tftp_file"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -c -s"

(5)  Restart the tftp server and enter the following command:

wangtian@wangtian-virtual-machine:~$ sudo service tftpd-hpa restart
wangtian@wangtian-virtual-machine:~$ 

3. Download zImage

Copy the zImage image file to the tftpboot folder, and give zImage the corresponding permissions, the command is as follows:
 
wangtian@wangtian-virtual-machine:~/linux/tftp_file$ cp ../nfs_File/zImage ./
wangtian@wangtian-virtual-machine:~/linux/tftp_file$ ls -l
总用量 960
-rw-rw-r-- 1 wangtian wangtian 983040 7月   6 00:59 zImage

Download the zImage file to the development board

Prerequisites: The development board can ping the ubuntu system. as follows:

=> ping 192.168.1.66
Using FEC1 device
host 192.168.1.66 is alive
=> 

Power on the development board, enter the uboot command mode (that is, when uboot has just started, you can enter the uboot command), download the zImage file, and enter the command as follows:

=> tftp 80800000 zImage
Using FEC1 device
TFTP from server 192.168.1.66; our IP address is 192.168.1.50
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
	 ##
	 2.4 MiB/s
done
Bytes transferred = 983040 (f0000 hex)
=> 

It can be seen that the file is successfully downloaded to the development board through the tftp service.

Note: If the download fails, the following information is displayed, which can be resolved by changing the zImage file permissions in the /linux/ directory.

=> tftp 80800000 zImage
Using  FEC1 device
TFTP from server 192.168.1.66; our IP address is 192.168.1.50
Filename 'zImage'
Loading address: 0x80800000
Loading: *
TFTP error: 'Permission denied' (0)
Starting again

That is, give zImage the maximum permission to solve it:

wangtian@wangtian-virtual-machine:~/linux/tftp_file$ sudo chmod 777 zImage 

Guess you like

Origin blog.csdn.net/wojiaxiaohuang2014/article/details/131565692