Rockchip U-Boot TFTP Upgrade Developer Guide
:::info 文档信息
文档标识:RK-SM-YF-389 · 发布版本:V1.0.1 · 发布日期:2021-12-01 · 页数:14 · 语言:英文
原始文档:Rockchip_Developer_Guide_U-Boot_TFTP_Upgrade_EN.pdf
:::
章节大纲
- Rockchip U-Boot TFTP Upgrade Developer Guide(P1)
- Overview(P4)
- U-Boot Configuration(P4)
- Ethernet Driver(P4)
- CMD Configuration(P4)
- DTS Configuration(P5)
- Network Information Configuration(P5)
- TFTP Firmware Upgrade(P6)
- Server Configuration(P6)
- Server TFTP Tool Configuration(P7)
- Use TFTP to Upgrade Firmware on the Device Side(P8)
- Command Line Test(P8)
- Step1: Enter the Command Line(P8)
- Step2: Check the Network Configuration(P8)
- Step3: Download Firmware via TFTP(P8)
- Step4: Restart the Device(P9)
- Checking Upgrade during Boot Automatically (discrete firmware)(P9)
- Step1: U-Boot Booting Command Modification(P9)
- Step2: Optimize the Time When Ping Connection Fails(P10)
- Step3: Test and Verification(P11)
- Step4: Upgrade Successfully(P12)
- Command Line Test(P8)
- Frequently Asked Question(P12)
- Unable to Connect Network of Server(P12)
- The Server TFTP Service is not Enable(P12)
- The File Path of Server is Configured Incorrectly or the File Does not Exist(P12)
- How to Change update.img to Separate Image Files(P13)
在线预览
若预览无法显示,请直接下载 PDF 后用本地阅读器打开。
1. Overview
Besides storage devices such as USB and SD cards, the fastest way to use U-Boot to download firmware or files is to transfer via network. In order do this, U-Boot implements the TFTP protocol. In the following chapters, we will introduce how to enable TFTP in U-Boot and realize the firmware upgrade function.
2. U-Boot Configuration
2.1 Ethernet Driver
For U-Boot defconfig configuration, please refer to RV1126 configuration: configs/rv1126_defconfig:
CONFIG_DM_ETH=y
CONFIG_DM_ETH_PHY=y
CONFIG_DWC_ETH_QOS=y
CONFIG_GMAC_ROCKCHIP=y
The nocache memory should be configured in dwc_eth_qos driver, please refer to RV1126 configuration:
diff --git a/include/configs/rv1126_common.h b/include/configs/rv1126_common.h
index 933917f3f0..9d70795fb8 100644
--- a/include/configs/rv1126_common.h
+++ b/include/configs/rv1126_common.h
@@ -50,6 +50,7 @@
#define CONFIG_SYS_SDRAM_BASE 0
#define SDRAM_MAX_SIZE 0xfd000000
+#define CONFIG_SYS_NONCACHED_MEMORY (1 << 20) /* 1 MiB */
#ifndef CONFIG_SPL_BUILD
2.2 CMD Configuration
Select the following configuration in menuconfig manually:
-> Command line interface
-> Network commands
[*] bootp, tftpboot
[*] tftp put
[*] tftp download and bootm
[*] tftp download and flash
For U-Boot defconfig configuration, please refer to RV1126 configuration: configs/rv1126_defconfig
CONFIG_CMD_TFTPPUT=y
CONFIG_CMD_TFTP_BOOTM=y
CONFIG_CMD_TFTP_FLASH=y
2.3 DTS Configuration
The DTS node is the same as it in the kernel, and the following board-level related attribute configurations should be paid attention to:
phy interface configuration (phy-mode) phy reset pin and reset time (snps, reset-gpio) (snps, reset-delays-us) The clock output direction for the controller (clock_in_out) Clock source selection and frequency setting (assigned-clock-parents) (assigned-clock-rates) RGMII Delayline, RGMII interface requirements (tx_delay) (rx_delay)
Pleas refer to RV1126 configuration: arch/arm/dts/rv1126-u-boot.dtsi:
&gmac {
phy-mode = "rgmii";
clock_in_out = "input";
snps,reset-gpio = <&gpio3 RK_PA0 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
/* Reset time is 20ms, 100ms for rtl8211f */
snps,reset-delays-us = <0 20000 100000>;
assigned-clocks = <&cru CLK_GMAC_SRC>, <&cru CLK_GMAC_TX_RX>, <&cru
CLK_GMAC_ETHERNET_OUT>;
assigned-clock-parents = <&cru CLK_GMAC_SRC_M1>, <&cru RGMII_MODE_CLK>;
assigned-clock-rates = <125000000>, <0>, <25000000>;
pinctrl-names = "default";
pinctrl-0 = <&rgmiim1_pins &clk_out_ethernetm1_pins>;
tx_delay = <0x2a>;
rx_delay = <0x1a>;
phy-handle = <&phy>;
status = "okay";
};
2.4 Network Information Configuration
In order to find the TFTP server conveniently, The device IP, server IP, and default gateway IP should be configured. You can add a declaration definition in the code. Please refer to RV1126 configuration: include/configs/rv1126_common.h. If you need to complete TFTP flashing automatically, please configure the network information in the code.
diff --git a/include/configs/rv1126_common.h b/include/configs/rv1126_common.h
index a6307ebcc7..f293c87286 100644
--- a/include/configs/rv1126_common.h
+++ b/include/configs/rv1126_common.h
@@ -25,6 +25,11 @@
#define CONFIG_SYS_LOAD_ADDR 0x00C00800
#define CONFIG_SYS_BOOTM_LEN (64 << 20)
+#define CONFIG_IPADDR 192.168.11.254 //Device IP
+#define CONFIG_SERVERIP 192.168.11.26 //Server IP
+#define CONFIG_GATEWAYIP 192.168.11.1 //Gateway IP
+#define CONFIG_NETMASK 255.255.255.0 //Subnet mask
You can also set the above information through the command line:
set ipaddr 192.168.11.254
set serverip 192.168.11.26
set gatewayip 192.168.11.1
set netmask 255.255.255.0
3. TFTP Firmware Upgrade
3.1 Server Configuration
The computer host should be configured with the corresponding network information to ensure that the device can communicate with the server (which should be consistent with the configuration in the code):
- Server IP: the IP address of the server 2. NetMask: subnet mask 3. GateWay IP: IP address of Gateway
3.2 Server TFTP Tool Configuration
Open the tool, select the Tftp Server tab, and confirm that the server's IP and the directory where the firmware is located are configured correctly.
3.3 Use TFTP to Upgrade Firmware on the Device Side
3.3.1 Command Line Test
3.3.1.1 Step1: Enter the Command Line
Power on, long press Ctrl+C to enter U-Boot command line mode:
=> <INTERRUPT>
=> <INTERRUPT>
=> <INTERRUPT>
=>
3.3.1.2 Step2: Check the Network Configuration
- Check whether the network information configuration of the device reach the expectations
=> printenv
...
gatewayip=192.168.11.1
ipaddr=192.168.11.254
netmask=255.255.255.0
serverip=192.168.11.26
...
- Check whether the communication with the server is normal
=> ping 192.168.11.26
host 192.168.11.26 is alive
The printing is alive indicates that the device and the server's network communication are normal.
3.3.1.3 Step3: Download Firmware via TFTP
=> tftpflash 0x20000000 uboot.img uboot
=> tftpflash 0x20000000 misc.img misc
=> tftpflash 0x20000000 rootfs.img rootfs
=> tftpflash 0x20000000 boot.img boot
=> tftpflash 0x20000000 recovery.img recovery
=> tftpflash 0x20000000 oem.img oem
=> tftpflash 0x20000000 userdata.img userdata
Command parameters:
Usage:
tftpflash [loadAddress] [[hostIPaddr:]bootfilename] [partition]
The following information will be printed if each partition is upgraded successfully:
=> tftpflash 0x20000000 uboot.img uboot
TFTP from server 192.168.11.26; our IP address is 192.168.11.254
Filename 'uboot.img'.
Load address: 0x20000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
##########################
479.5 KiB/s
done
Bytes transferred = 4194304 (400000 hex)
## TFTP flash uboot.img to partititon 'uboot' size 0x400000 ... OK
3.3.1.4 Step4: Restart the Device
=> reset
3.3.2 Checking Upgrade during Boot Automatically (discrete firmware)
3.3.2.1 Step1: U-Boot Booting Command Modification
U-Boot booting will call RKIMG_BOOTCOMMAND finally, TFTP_DOWNLOAD_COMMAND which is used to burn the firmware is added:
diff --git a/include/configs/rv1126_common.h b/include/configs/rv1126_common.h
index a6307ebcc7..f308095159 100644
--- a/include/configs/rv1126_common.h
+++ b/include/configs/rv1126_common.h
@@ -62,6 +69,15 @@
#define CONFIG_USB_FUNCTION_MASS_STORAGE
#define CONFIG_ROCKUSB_G_DNL_PID 0x110b
+#define TFTP_DOWNLOAD_COMMAND \
+ "tftpflash 0x20000000 uboot.img uboot;" \
+ "tftpflash 0x20000000 misc.img misc;" \
+ "tftpflash 0x20000000 rootfs.img rootfs;" \
+ "tftpflash 0x20000000 boot.img boot;" \
+ "tftpflash 0x20000000 recovery.img recovery;" \
+ "tftpflash 0x20000000 oem.img oem;" \
+ "tftpflash 0x20000000 userdata.img userdata;"
+
#define ENV_MEM_LAYOUT_SETTINGS \
"scriptaddr=0x00000000\0" \
"pxefile_addr_r=0x00100000\0" \
@@ -84,8 +100,12 @@
"boot_fit;"
#else
#define RKIMG_BOOTCOMMAND \
- "boot_fit;" \
- "boot_android ${devtype} ${devnum};"
+ "if ping ${serverip}; then ;" \
+ TFTP_DOWNLOAD_COMMAND \
+ "reset;" \
+ "else;" \
+ "boot_fit;" \
+ "boot_android ${devtype} ${devnum};" \
+ "fi;"
Note: adjust the partition image and partition name according to actual products.
The automatic detection upgrade process is as follows:
Start
Ping ServerIP
successful
TFTP firmware flshing
Failed
Reset
System boot firmware
3.3.2.2 Step2: Optimize the Time When Ping Connection Fails
Since the automatic upgrade process can only be completed when the server is connected and the upgrade package is ready, it is also necessary to determine whether the server is connected during regular booting, and the ping operation time should be optimized.
diff --git a/include/configs/rv1126_common.h b/include/configs/rv1126_common.h
index a6307ebcc7..f308095159 100644
--- a/include/configs/rv1126_common.h
+++ b/include/configs/rv1126_common.h
@@ -25,6 +25,13 @@
#define CONFIG_SYS_LOAD_ADDR 0x00C00800
#define CONFIG_SYS_BOOTM_LEN (64 << 20)
+#define CONFIG_ARP_TIMEOUT 200UL
3.3.2.3 Step3: Test and Verification
- The server connection failed, boot normally
ARP Retry count exceeded; starting again
ping failed; host 192.168.11.26 is not alive
## Booting FIT Image at 0x3b53a580 with size 0x005bc800
- The server connection is normal, after upgrading the firmware, boot normally
host 192.168.11.26 is alive
TFTP from server 192.168.11.26; our IP address is 192.168.11.254
Filename 'uboot.img'.
Load address: 0x20000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
##########################
1.1 MiB/s
done
Bytes transferred = 4194304 (400000 hex)
## TFTP flash uboot.img to partititon 'uboot' size 0x400000 ... OK
......
Partition image upgrade
......
TFTP from server 192.168.11.26; our IP address is 192.168.11.254
Filename 'userdata.img'.
Load address: 0x20000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################
1 MiB/s
done
Bytes transferred = 5242880 (500000 hex)
## TFTP flash userdata.img to partititon 'userdata' size 0x500000 ... OK
## Booting FIT Image at 0x3b53a580 with size 0x005bc800
3.3.2.4 Step4: Upgrade Successfully
After successful upgrade, the system will restart automatically. Please disconnect the TFTP server to prevent the device from being upgraded again.
4. Frequently Asked Question
4.1 Unable to Connect Network of Server
ARP Retry count exceeded; starting again
ping failed; host 192.168.11.26 is not alive
4.2 The Server TFTP Service is not Enable
host 192.168.11.26 is alive
TFTP from server 192.168.11.26; our IP address is 192.168.11.254
Filename 'uboot.img'.
Load address: 0x20000000
Loading: *
TFTP server died; starting again
4.3 The File Path of Server is Configured Incorrectly or the File Does
not Exist
host 192.168.11.26 is alive
TFTP from server 192.168.11.26; our IP address is 192.168.11.254
Filename 'uboot.img'.
Load address: 0x20000000
Loading: *
TFTP error: 'File not found' (1)
Not retrying...
4.4 How to Change update.img to Separate Image Files
- The update.img can be unpacked as a separate image file through a script tool under the Linux environment
Tools: tools/linux/Linux_Pack_Firmware/rockdev/unpack.sh How to use: place update.img in the same level directory of the unpack.sh script and execute the following command to unpack
./unpack.sh
- Rockchip Development Tools under Windows can be used to unpack update.img as a separate image file
Tools: tools/windows/RKDevTool/RKDevTool_Release/RKDevTool.exe How to use: select the advanced features tab, the firmware bar ... select the corresponding update.img, and click the unpack button to unpack the firmware