I. OverviewTFTP in U-boot is used to send smaller files. The lower layer uses the UDP protocol, which sends a UDP 69 port with a maximum packet of Bytes per send. The sending parties adopt a time-out retransmission mechanism. The data transfer mode is octet mode (binary mode). Using the TFTP feature in U-boot, you can use the following command: TFTP memoryaddress FileName where memoryaddress is the first address of the memory to put in the file, filename is the file name of the file to be transferred (the file must be placed in the TF TP default directory).ii. use of TFTPTo transfer files using TFTP: 1 The following variables have been initialized: Netourip (native IP address, defined in net.c file) Netserverip (the IP address of the TFTP server, defined in the net.c file) bootfile (file name required to transfer files , set at TFTP.C) Netourgatewayip (gateway address for this machine) netoursubnetmask (native subnet mask) 2 calls the Tftpstart function to start the file transfer.Third, TFTP implementation(1) Client state TFTP uses a variable tftpstate to describe the possible 5 states of the TFTP client: status
Description
State_rrq
Issue a read request pending approval
State_data
Receiving data
State_too_large
File is too large
State_bad_magic
Bad magic number
State_oack
Receive Oack Frames
Package TypeThere are 6 types of packets delivered using TFTP: type
Description
Tftp_rrq
Request Read File
Tftp_wrq
Request Write File
Tftp_data
Data package
Tftp_ack
Confirm Package
Tftp_error
Package with error message
Tftp_oack
Option acknowledge actively emits a oack frame when the server times out without receiving an ACK frame from the client
main functions and RolesU-boot in the TFTP protocol with the TFTP.C and Tftp.h files, the main functions include: Static __inline__ voidstore_block (unsigned block, Uchar * src, unsigned len */* According to the pre-set address LOAD_ADDR decision to the first address src, length len block blocks of data write to flash or write memory */static voidtftpsend (void);/* Different TFTP packets are sent according to the different values of the Tftpstate variable (sent using the UDP protocol) */static Voidtftphandler (Uchar * pkt, unsigned dest, unsigned src, unsigned len /* * Handle the Received TFTP packet */static voidtftptimeout (void);/* Timeout handler function */Voidtftpstart (void);/* Initialize each required data and start sending TFTP read requests * * This article from CSD n Blog, reproduced please indicate the source: http://blog.csdn.net/funy_liu/archive/2010/08/03/5784218.aspx
TFTP explained in U-boot