Updating image on the board
本章节主要讨论如何更新flash上的image,包括uboot和linux。当然,前提条件是不将flash取出,而是在线刷写flash。刷写的方式有多种,包括通过tftp协议将镜像从ftp server上download到板子上;使用fatload指令从fat格式的接口device中加载到内存上; 或者使用console 的kermit 协议传输文件到板子内存中。
4.1 Update u-bootusing console
u-boot提供命令接口loadb让用户使用console协议来传输image到板子内存中。需要用户连接的主机支持kermit传输协议,比如超级终端是默认支持的。更新过程步骤如下:
Step 1: Use kermit protocolto transmit file into the targetsystem.
uBoot> loadb
use Kermit protocol transmit file.
## Total Size = 0x0003b8a0 = 243872 Bytes
## Start Addr = 0x00100000
Step 2: Update bootcode by command run bootloader_flash_updateor bootloaderupdate
uBoot> run bootloader_flash_update
Un-Protected 5 sectors
..... done
Erased 5 sectors
copy to Flash...4....3....2....1....done.
当所有的步骤完成之后,显示update done,则可以使用reset指令来完成重启系统。
4.2 Update u-boot using TFTP
u-boot中另外还提供一种更新flash的途径:tftp协议。一般情况下还是推荐使用这种方式,应为这种方式是所有途径中传输速率最快。
在download image之前,必须保证TFTP server已经准备好,可以正常工作了。在linux下可以使用重定向到ftp来实现ftp服务器传输。Windows下推荐使用工具tftpd32.exe来完成ftp server的建立。最后两端的ip必须设置清晰,比如默认情况下,板端IP为192.168.1.1. 而server端IP为192.168.1.100 。在uboot每次启动之后,默认在uboot下工作的是ethact=octmgmt0,所以在使用其他LAN接口的时候,请用setenv调整工作lan。比如:
command meaning
setenv ipaddr <ip> Set device IP.
setenv serverip <ip> Set TFTP server IP.
setenv ethact <interface> Set network interface,octmgmt0 is manage
port,octeth0-3 is LAN fromSGMII0.
octeth4-7 from GMII1
saveenv Save settings to ENV area.
同样,更新flash的步骤也是两个:
Step 1: Using tftpboot command to download bootloader image to memory
uBoot> tftpboot $(loadaddr) u-boot.bin
Using octeth0 device
TFTP from server192.168.1.100; our IP address is 192.168.1.1
Filename ’u-boot.bin’. Load address: 0x20000000
Loading: ########## done
Bytes transferred = 388256 (5eca0 hex),12230 Kbytes/sec
Step 2: Update bootcode by command run bootloader_flash_updateor bootloaderupdate
uBoot> run bootloader_flash_update
Un-Protected 3 sectors
... done
Erased 3 sectors
copy to Flash...4....3....2....1....done
Un-Protected 1 sectors
. done
Erased 1 sectors
当所有的步骤完成之后,显示update done,则可以使用reset指令来完成重启系统。
4.3 Update BSP image using TFTP
针对Linux kernel的update,可以参考u-boot image更新的方式来实现。当然这种方式只使用与Linux系统存放在flash的情况下。有些时候flash有可能是放入CF卡或者u盘中的。
command meaning
setenv ipaddr <ip> Set device IP.
setenv serverip <ip> Set TFTP server IP.
setenv ethact <interface> Set network interface,octeth0-3 is LAN fromSGMII0.
octeth4-7 fromGMII1
saveenv Save settings to ENV area.
同样,更新flash的步骤也是两个:
Step 1: Using tftpboot command to download BSP image to memory
uBoot> tftpboot $(loadaddr) vmlinux.64
Using octeth0 device
TFTP from server192.168.1.100; our IP address is 192.168.1.1
Filename ’vmlinux.64’. Load address: 0x20000000
Loading: ########################
done
Bytes transferred = 388256 (5eca0 hex),12230 Kbytes/sec
Step 2: Update BSPimage by command run linux_update
uBoot> run linux_update
Un-Protected 192 sectors
................................................ Erased 192 sectors
copy to Flash...4....3....2....1....done
当所有的步骤完成之后,显示update done,则可以使用reset指令来完成重启系统.。
4.4 Update BSP image using USB
这里介绍另外的一种更新Linux image的方式,同样使用与更新u-boot image。Download 镜像的方式是一样的。都是通过fat格式的u盘来加载镜像到内存中。
通过help usb来获得usb指令的详细帮助:
图4.1 usb指令的使用帮助
针对usb的指令主要会用到如下三个:
Description / Parameters / Example |
|
usb reset/start |
Description: To reset or rescan USBcontroller.
Parameters: Example: uBoot> usb reset (Re)start USB... USB: (port 0) scanning bus for devices... 1 USB Devices found scanning bus for storage devices... Device 0: vendor: USB 2.0 Prod.: Flash disk Rev: 0.00 Type: Removable Hard disk Capacity: 496.0 MB = 0.4 GB (1015808 x 512) |
Fatls <interface><dev[:part]> [directory] |
List files in USB device. <interface>: Decide what interface you want to list. <dev[:part]>: Decide USB list port. uBoot> fatls usb 0 18121896 vmlinux.64 .. 1 file(s),0 dir(s) |
fatload <interface> <dev[:part]> <addr> <filename> [bytes]
|
Load file in USB device to address. <interface>: Decide what interface you want to list. <addr>: Load address. <filename>: Load file name. Example: uBoot> fatload usb 0:1 $(loadaddr) vmlinux.64 reading vmlinux.64 .................... 18121896 bytes read
|
Table 4.1: u-Boot USB commands.
同样,更新flash的步骤也是两个:
Step 1: Using fatload command to download BSP image to memory
uBoot> fatload usb 0 $(loadaddr)vmlinux.64
reading vmlinux.64
........................................
18121896 bytes read
Step 2: Update BSPimage by command run linux_update
uBoot> run linux_update
Un-Protected 192sectors
................................................ Erased 192 sectors
copy to Flash...4....3....2....1....done
当所有的步骤完成之后,显示update done,则可以使用reset指令来完成重启系统。