公司让我给自己用来开发NVR的板子做一个文件系统,只给我了一个板子和一个hi3531 SDK 开发包,,这可苦了我,我对硬件了解甚少,于是一顿恶补.由于一直在看Linux的书,所以对SDK的学习还算快速,不几天文件系统做出来个样子,虽然是根据各处来的文档拼凑的,也感觉差不了多少了,现在想往板子上刷一刷了.然后学tftp用来刷板子,可是刷了几下板子就挂了,开始还能用tftp恢复回来,后来直接恢复不了了,听主管说要用fastboot,立马打起精神搞一搞.可是搞了好久还是不行.后来遇到高人指点,终于对fastboot算是了解透彻了,一定要根据我的理解狠狠总结一下(文档上讲的很清楚的就不细讲了).
工具;我用的是 Hi3531 SDK 自带的 FastBoot 3.1(BVT)
fastboot有3种模式:burn by partition, burn by adress, burn fastboot,下面分别介绍
burn by partition,根据下方的提示框中的内容可以发现它的实现原理其实也是tftp,只不过变成了一个tftp的工具,还可以保存xml的配置文件,用起来应该算方便了许多呢.
burn by adress,根据16进制(HEX)地址刷,这个没怎么用.
burn fastboot, 这个应该是板子里本来没有uboot的时候用的,也应该算是fastboot核心的用法了.我一开始就是用的这个,但是不知道写的文件应该是uboot,所以一直没反应,好纠结啊.
在刷板子之前要先备份一下板子上flash的内容,
1、配置tftp服务器
# 可以使用任意的tftp服务器,将package/image_uclibc(或image_glibc)下的相关文件拷贝到tftp服务器目录下。
测试tftp服务69端口是否开启, 使用命令
netstat -nlp|grep 69
2、参数配置
# 单板上电后,敲任意键进入u-boot。设置serverip(即tftp服务器的ip)、ipaddr(单板ip)和ethaddr(单板的MAC地址)。
setenv serverip xx.xx.xx.xx
setenv ipaddr xx.xx.xx.xx
setenv ethaddr xx:xx:xx:xx:xx:xx
setenv netmask xx.xx.xx.xx
setenv gatewayip xx.xx.xx.xx
ping serverip,确保网络畅通。
setenv ipaddr 192.168.0.133;setenv serverip 192.168.0.233;setenv ethaddr 00:16:17:30:C9:17;
setenv netmask 255.255.255.0;setenv gatewayip 192.168.0.1
备份16M spi flash
mw.b 0x81000000 0xff 0x1000000; sf probe 0; sf read 0x81000000 0 0x1000000;tftp 0x81000000 hi3531_spiflash_image_16M_bak14.3.4 0x1000000
进入uboot模式,查看uboot参数
hisilicon # printenv
baudrate=115200
bootfile="uImage"
jpeg_addr=0x80000000
jpeg_size=0x20000
vobuf=0x8f000000
bootdelay=3
gatwayip=192.168.0.1
filesize=3C818C
fileaddr=82000000
bootargs=mem=128M console=ttyAMA0,115200 root=1f04 rootfstype=jffs2 mtdparts=hi_sfc:384K(uboot),128K(uboot_logo),256K(config),4736K(kernel),9856K(rootfs),1024K(custom)
bootcmd=showlogo;sf probe 0; sf read 0x82000000 0xc0000 0x4a0000; bootm 0x82000000
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Oct 31 2012 - 10:23:03)
ethaddr=00:16:17:30:C9:17
gatewayip=192.168.0.1
netmask=255.255.255.0
ipaddr=192.168.0.133
serverip=192.168.0.233
修改uboot参数的方法
setenv bootargs 'mem=128M console=ttyAMA0,115200 root=1f04 rootfstype=jffs2 mtdparts=hi_sfc:384K(uboot),128K(uboot_logo),256K(config),4736K(kernel),9856K(rootfs),1024K(custom)'
saveenv
setenv bootargs 'mem=64M console=ttyAMA0,115200 root=1f04 rootfstype=jffs2 mtdparts=hi_sfc:384K(uboot),128K(uboot_logo),256K(config),4736K(kernel),9856K(rootfs),1024K(custom)'
saveenv
其中mtdparts=hi_sfc:384K(uboot),128K(uboot_logo),256K(config),4736K(kernel),9856K(rootfs),1024K(custom) 表示了uboot对flash的划分
起始 | 0 | 384k | 512k |768k |5504k| 15460k=15M
大小 | 384k | 128k | 256k |4736k |9856k |1024k |
|---------------|-------------------------|-----------------|-----------------|-----------------|-----------------|
分区 | uboot | uboot_logo |config |kernel | rootfs |custom|
从备份出的flash中提取出来这些划分
uboot: dd if=hi3531_spiflash_image_16M_bak14.3.4 of=hi3531_uboot_384k bs=1024 count=384
uboot_logo: dd if=hi3531_spiflash_image_16M_bak14.3.4 of=hi3531_uboot_logo_128k bs=1024 count=128 skip=384
config: dd if=hi3531_spiflash_image_16M_bak14.3.4 of=hi3531_config_256k bs=1024 count=256 skip=384
kernel: dd if=hi3531_spiflash_image_16M_bak14.3.4 of=hi3531_kernel_4736k bs=1024 count=4736 skip=768
rootfs: dd if=hi3531_spiflash_image_16M_bak14.3.4 of=hi3531_rootfs_9856k bs=1024 count=9856 skip=5504
在burn fastboot模式下fastboot刷uboot成功的提示(参数 flash type: spi , file: F:\ARM\u-boot-hi3531-slq-test-frombak1M.bin ):
Boot downloading started.
Boot 100 % Downloaded.
Boot Downloading completed!
U-Boot 2010.06 (Oct 31 2012 - 10:23:03)
DRAM: 256 MiB
Check spi flash controller v300. found
Spi(cs1) ID: 0x01 0x20 0x18 0x03 0x01 0x00
Spi(cs1): Block:64KB Chip:16MB Name:"S25FL128P-1"
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
start download process.
Boot Started successfully!
v
ersion: 3.0.3
(OK)
"getinfo version" command sent successfully!
spi
(OK)
"getinfo bootmode" command sent successfully!
16384 KiB hi_sfc at 0:0 is now current device
(OK)
"sf probe 0" command sent successfully!
Erasing at 0x10000 -- 6% complete.
Erasing at 0x20000 -- 12% complete.
Erasing at 0x30000 -- 18% complete.
Erasing at 0x40000 -- 25% complete.
#
Erasing at 0x50000 -- 31% complete.
Erasing at 0x60000 -- 37% complete.
Erasing at 0x70000 -- 43% complete.
#
Erasing at 0x80000 -- 50% complete.
Erasing at 0x90000 -- 56% complete.
Erasing at 0xa0000 -- 62% complete.
#
Erasing at 0xb0000 -- 68% complete.
Erasing at 0xc0000 -- 75% complete.
#
Erasing at 0xd0000 -- 81% complete.
Erasing at 0xe0000 -- 87% complete.
Erasing at 0xf0000 -- 93% complete.
#
Erasing at 0x100000 -- 100% complete.
(OK)
"sf erase 0 0x00100000" command sent successfully!
#
Writing at 0x10000 -- 6% complete.
#
Writing at 0x20000 -- 12% complete.
#
Writing at 0x30000 -- 18% complete.
Writing at 0x40000 -- 25% complete.
#
Writing at 0x50000 -- 31% complete.
Writing at 0x60000 -- 37% complete.
#
Writing at 0x70000 -- 43% complete.
Writing at 0x
80000 -- 50% complete.
#
Writing at 0x90000 -- 56% complete.
Writing at 0xa0000 -- 62% complete.
Writing at 0xb0000 -- 68% complete.
Writing at 0xc0000 -- 75% complete.
#
Writing at 0xd0000 -- 81% complete.
#
Writing at 0xe0000 -- 87% complete.
#
Writing at 0xf0000 -- 93% complete.
#
Writing
at 0x100000 -- 100% complete.
(OK)
"sf write 0x81000000 0 0x00100000" command sent successfully!
修改 uboot参数
hisilicon # printenv
baudrate=115200
bootfile="uImage"
jpeg_addr=0x80000000
jpeg_size=0x20000
vobuf=0x8f000000
bootdelay=3
gatwayip=192.168.0.1
filesize=3C818C
fileaddr=82000000
bootargs=mem=128M console=ttyAMA0,115200 root=1f04 rootfstype=jffs2 mtdparts=hi_sfc:384K(uboot),128K(uboot_logo),256K(config),4736K(kernel),9856K(rootfs),1024K(custom)
bootcmd=showlogo;sf probe 0; sf read 0x82000000 0xc0000 0x4a0000; bootm 0x82000000
stdin=serial
stdout=serial
stderr=serial
verify=n
ver=U-Boot 2010.06 (Oct 31 2012 - 10:23:03)
ethaddr=00:16:17:30:C9:17
gatewayip=192.168.0.1
netmask=255.255.255.0
ipaddr=192.168.0.133
serverip=192.168.0.233
setenv jpeg_addr 0x80000000
setenv jpeg_size 0x20000
setenv vobuf 0x8f000000
setenv bootdelay 3
setenv gatwayip 192.168.0.1
setenv filesize 3C818C
setenv fileaddr 82000000
setenv bootargs 'mem=128M console=ttyAMA0,115200 root=1f04 rootfstype=jffs2 mtdparts=hi_sfc:384K(uboot),128K(uboot_logo),256K(config),4736K(kernel),9856K(rootfs),1024K(custom)'
setenv bootcmd 'showlogo;sf probe 0; sf read 0x82000000 0xc0000 0x4a0000; bootm 0x82000000'
setenv ipaddr 192.168.0.133;setenv serverip 192.168.0.233;setenv ethaddr 00:16:17:30:C9:17;
setenv netmask 255.255.255.0;setenv gatewayip 192.168.0.1