天天看点

zynq的uboot模式下TFTP更新bit、内核等文件

本文使用软件uboot版本为u-boot-xlnx-xilinx-v2018.3,可在https://github.com/Xilinx/u-boot-xlnx/tree/xilinx-v2018.3下载官方版本

硬件为米联客MZ7XB,zynq7020,使用QSPI启动方式

关于zynq的uboot下的TFTP更新,需要先让uboot支持tftp模式,使能 tftpboot 命令,如下位置(如图)

Command Line interface ---> 
    Network commands  --->
        [*] bootp, tftpboot 
           
zynq的uboot模式下TFTP更新bit、内核等文件

可在 include/configs/zynq-common.h 文件中修改环境变量,也可以在uboot下添加修改环境变量:

 1、添加  serverip 与 ipaddr 环境变量,将板子与电脑连接到局域网,就可ping同网络了

zynq的uboot模式下TFTP更新bit、内核等文件

   2、板子使用的是n25q128,只有16M,故需要细细分配下地址,把文件系统放在spi flash芯片上,16M确实小了,凑合着用:

BOOT.bin            0x0       0x100000
    system.bit          0x100000  0x400000
    zImage              0x500000  0x480000
    devicetree.dtb      0x980000  0x10000
    uramdisk.image.gz   0x990000  0x670000

           

   3、设置环境变量: 

setenv update_boot "echo update bootload ... && tftpboot 0x800000 ${boot_image} && sf probe 0 0 0 && sf erase 0x0 0x100000 && sf write 0x800000 0x0 0x100000" 
setenv update_fpga_bit "echo update FPGA bitstream... && tftpboot 0x800000 ${bitstream_image} && sf probe 0 0 0 && sf erase 0x100000 0x400000 && sf write 0x800000 0x100000 0x400000" 
setenv update_kernel "echo update linux kernel... && tftpboot 0x800000 ${kernel_image} && sf probe 0 0 0 && sf erase 0x500000 0x480000 && sf write 0x800000 0x500000 0x480000" 
setenv update_dtb "echo update devicetree.dtb... && tftpboot 0x800000 ${devicetree_image} && sf probe 0 0 0 && sf erase 0x980000 0x10000 && sf write 0x800000 0x980000 0x10000"
setenv update_system "echo update file system... && tftpboot 0x800000 ${ramdisk_image} && sf probe 0 0 0 && sf erase 0x990000 0x670000 && sf write 0x800000 0x990000 0x670000"


使用zImage,独立fpga的bit文件,修改qspiboot如下:
setenv qspiboot "echo Copying Linux from QSPI flash to RAM... && sf probe 0 0 0 && echo  FPGA bitstream is loading ... ... && sf read 0x800000 0x100000 0x400000 && fpga loadb 0 0x800000 0x400000 && sf read ${kernel_load_address} 0x500000 0x480000 && sf read ${devicetree_load_address} 0x980000 0x10000 && echo Copying ramdisk... && sf read ${ramdisk_load_address} 0x990000 0x670000 && bootz ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}"

           

保存环境变量后,打开tftp软件,设置要烧写文件所在的目录(如下图):

zynq的uboot模式下TFTP更新bit、内核等文件

 在uboot下输入命令即可更新所需文件,例如输入 run update_fpga_bit 更新PL部分的bit文件:

zynq的uboot模式下TFTP更新bit、内核等文件

 都下载完后重启或者输入boot即可启动系统

zynq的uboot模式下TFTP更新bit、内核等文件

若要修改 include/configs/zynq-common.h 文件,需要添加ip,修改添加环境变量,部分修改添加如下所示:

#define CONFIG_IPADDR	192.168.XX.XX     //板子ip,ip自定义
#define CONFIG_SERVERIP	192.168.XX.XX     //服务器ip



在  CONFIG_EXTRA_ENV_SETTINGS 添加
	"update_boot=echo update bootload ... && "  \
		"tftpboot 0x800000 ${boot_image} && "  \
		"sf probe 0 0 0 && "  \
		"sf erase ${boot_addr} ${boot_size} && "  \
		"sf write 0x800000 ${boot_addr} ${filesize} \0"  \
	"update_fpga_bit=echo update FPGA bitstream... && "  \
		"tftpboot 0x800000 ${bitstream_image} && "  \
		"sf probe 0 0 0 && "  \
		"sf erase ${loadbit_addr} ${loadbit_size} && "  \
		"sf write 0x800000 ${loadbit_addr} ${filesize} \0"  \
	"update_kernel=echo update linux kernel... && "  \
		"tftpboot 0x800000 ${kernel_image} && "  \
		"sf probe 0 0 0 && "  \
		"sf erase ${kernel_addr} ${kernel_size} && "  \
		"sf write 0x800000 ${kernel_addr} ${filesize}\0"  \
	"update_dtb=echo update devicetree.dtb... && "  \
		"tftpboot 0x800000 ${devicetree_image} && "  \
		"sf probe 0 0 0 && "  \
		"sf erase ${devicetree_addr} ${devicetree_size} && "  \
		"sf write 0x800000 ${devicetree_addr} ${filesize}\0"  \
	"update_system=echo update file system... && "  \
		"tftpboot 0x800000 ${ramdisk_image} && "  \
		"sf probe 0 0 0 && "  \
		"sf erase ${ramdisk_addr} ${ramdisk_size} && "  \
		"sf write 0x800000 ${ramdisk_addr} ${filesize}\0"  \
	"update_all=echo update fpga_bit ... linux kernel ... devicetree ... file system && "  \


修改其中的
"qspiboot=echo Copying Linux from QSPI flash to RAM... && "  \
		"sf probe 0 0 0 && "  \
		"echo  FPGA bitstream is loading ... ... && "  \
		"sf read ${bitstream_load_address} ${loadbit_addr} ${loadbit_size} && "  \
		"fpga loadb 0 ${bitstream_load_address} ${loadbit_size} && "  \
		"sf read ${kernel_load_address} ${kernel_addr} ${kernel_size} && "  \
		"sf read ${devicetree_load_address} ${devicetree_addr} ${devicetree_size} && "  \
		"echo Copying ramdisk... && "  \
		"sf read ${ramdisk_load_address} ${ramdisk_addr} ${ramdisk_size} && "  \
		"bootz ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0"  \
           

生成BOOT.bin 烧写后即可使用。

打包好的BOOT.bin文件地址 https://download.csdn.net/download/feitingfj/11832377

修改后的uboot源码地址  https://github.com/feitingfj/u-boot-xlnx-xilinx-v2018.3

继续阅读