本文使用軟體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
可在 include/configs/zynq-common.h 檔案中修改環境變量,也可以在uboot下添加修改環境變量:
1、添加 serverip 與 ipaddr 環境變量,将闆子與電腦連接配接到區域網路,就可ping同網絡了
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軟體,設定要燒寫檔案所在的目錄(如下圖):
在uboot下輸入指令即可更新所需檔案,例如輸入 run update_fpga_bit 更新PL部分的bit檔案:
都下載下傳完後重新開機或者輸入boot即可啟動系統
若要修改 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