7.6. Flashing Package Type Conversion Tool and TFTP Flashing Method
Description: The flashing package type conversion tool is used to convert between SD card flashing packages and TFTP flashing packages. The TFTP flashing method is described at the end of this page.
Applicable Objects: This tool is suitable for official flashing packages, as well as those created by the socbak tool or the BSP tool.
Execution Environment: The tool needs to be executed in a Linux x86 system. This article uses Ubuntu 20.04 x86 as an example.
7.6.1. Acquisition of the Flashing Package Type Conversion Tool
Download the tool using a browser from: https://sophon-file.sophon.cn/sophon-prod-s3/drive/23/11/16/15/sd2tftp.tar
After the file is downloaded, user will get a compressed package. Extract the compressed package to obtain the sd2tftp.sh script file.
Note
The first time user use it, user need to install the mkimage tool. user can install it using the following command:
sudo apt install u-boot-tools
7.6.2. Usage Guide for the Flashing Package Type Conversion Tool
Place the sd2tftp.sh file in the same path as the SD card flashing package file or the TFTP flashing package file.
Execute the command:
./sd2tftp.sh [Mode Choose]
The converted flashing package will be generated in the output folder.
7.6.3. TFTP Flashing Method
The u-boot of SE5 also facilitates flashing via Ethernet and the TFTP protocol. The steps for flashing are as follows:
Attention
The flashing package used for TFTP is different from the one used for SD card flashing.
The TFTP flashing method only supports upgrading from SDKv22.09.02 and above.
Obtain the TFTP flashing package: It can be created using the method described above, or downloaded from https://developer.sophgo.com/site/index/material/all/all.html. The sophon-img_<date>_<hash> folder in SOPHONSDK version v22.09.02 and later includes a tftp.tgz file.
Install the TFTP server on the PC and specify the path of the TFTP flashing package:
Ubuntu system: Run: apt-get install tftpd-hpa tftp-hpa to download the TFTP tool; then check the TFTP DIRECTORY path in the /etc/default/tftpd-hpa file and copy the flashing package into it (user can also modify this path configuration, and it will take effect after sudo service tftpd-hpa restart);
Windows system: Click the link to download https://pjo2.github.io/tftpd64/, then open the downloaded tftpd64.exe graphical interface and set the Current Directory to point to the folder where the TFTP flashing package is extracted.
Attention
It is recommended to use an Ubuntu system for the PC as much as possible. The Windows version of tftpd64 is finicky about the environment and sometimes unstable when transferring large files, which can cause the upgrade to fail.
After setting up the TFTP server, user can test it with another PC to avoid network and firewall configuration issues.
Establish the basic network environment: Position the device intended for upgrade and the computer on the same router or connect the LAN port of the device directly to the computer.
Perform the flashing steps:
Connect the device to be upgraded to the serial terminal, start the box, and quickly press Enter to enter the u-boot command mode.
Enter the following commands:
setenv serverip 192.168.150.2 setenv ipaddr 192.168.150.1 setenv gatewayip 192.168.150.2 setenv update_all 0 setenv reset_after 1 tftp 0x310000000 boot.scr source 0x310000000 set netretry yes
Attention
Note: The serverip in the command is the address of the TFTP server, ipaddr is the IP address of the box, and gatewayip is the gateway address. These need to be adjusted according to the actual situation. In a scenario involving Windows, the LAN port of the box is typically connected to the PC, resulting in identical values for serverip and gatewayip. Before executing the TFTP command, the user can ping the serverip to confirm the connection status.
The flashing process will then begin, and user will see the progress indicated by the # symbol.
Since the environment variable reset_after 1 is configured via the command, the system will restart after the flashing is complete. Additionally, the command set netretry yes will retry the transfer upon timeout rather than restarting the device immediately. Note that if the flashing fails, the system will also automatically restart. Please refer to the prompt after the execution to determine whether the flashing has been successfully completed.