<Linux development> linux development tools-of-TFTP

<Linux development> linux development tools-of-TFTP

The function of the tftp command is the same as that of the nfs command. It is used to download things to DRAM through the network. It is just the TFTP protocol used by the tftp command, and the Ubuntu host is used as the TFTP server. Therefore, you need to build a TFTP server on Ubuntu. You need to install tftp-hpa and tftpd-hpa. The commands are as follows:

sudo apt-get install tftp-hpa tftpd-hpa 
sudo apt-get install xinetd

Like NFS, TFTP also needs a folder to store files. Create a new directory under the user directory. The command is as follows:

mkdir /home/water/linux/tftpboot
chmod 777 /home/water/linux/tftpboot

This way I created a directory (folder) called tftpboot on my computer with the path "/home/water/linux/tftpboot". Notice! We have to give the tftpboot folder permission, otherwise uboot cannot download files from the tftpboot folder. Finally, configure tftp. After the installation is complete, create a new file /etc/xinetd.d/tftp. If there is no /etc/xinetd.d directory, create it by yourself, and then enter the following content in it:

vi /etc/xinetd.d/tftp
  1 server tftp
  2 {
    
    
  3     socket_type =   dgram
  4     protocol    =   udp
  5     wait        =   yes
  6     user        =   root
  7     server      =   /usr/sbin/in.tftpd
  8     server_args =   -s /home/water/linux/tftpboot
  9     disable     =   on
 10     per_source  =   11
 11     cps         =   100.2
 12     flags       =   IPv4
 13 }
 14 

After finishing, start the tftp service, the command is as follows:

sudo service tftpd-hpa start

Open the /etc/default/tftpd-hpa file and modify it to look like this:

 vi /etc/default/tftpd-hpa 
  1 # /etc/default/tftpd-hpa
  2 
  3 TFTP_USERNAME="tftp"
  4 TFTP_DIRECTORY="/home/water/linux/tftpboot"
  5 TFTP_ADDRESS=":69"
  6 TFTP_OPTIONS="-1 -c -s"

TFTP_DIRECTORY is the tftp folder directory we created above. In the future, we will put all the files that need to be transferred through TFTP into this folder, and give these files the corresponding permissions.
Finally, enter the following command to restart the tftp server:

sudo service tftpd-hpa restart

The tftp server has been set up, and the next step is to use it. Copy the zImage image file to the tftpboot folder, and give zImage the corresponding permissions, the command is as follows:

cp zImage /home/water/linux/tftpboot/ 
cd /home/water/linux/tftpboot/ 
chmod 777 zImage

Verify that the tftp command format in uboot is as follows:

tftpboot [loadAddress] [[hostIPaddr:]bootfilename] 

It looks the same as the nfs command format, loadAddress is the storage address of the file in DRAM, [[hostIPaddr:]bootfilename] is the file to be downloaded from Ubuntu. But 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. For example, we now download the zImage file in the tftpboot folder to the 0X80800000 address of the development board DRAM, and the command is as follows:

tftp 80800000 zImage

The download process is shown in the figure below:
insert image description here
At this point, the TFTP tool has been built, and subsequent linux system migration will involve use.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324496115&siteId=291194637