plutosdr通过uboot单独加载bit文件

导出bit文件,修改uEnv.txt文件,修改bitstream_image为自己的bit文件,如system_top.bit,并增加两行:

bitstream_image=system_top.bit

mmc_loadbit_fat=echo Loading bitstream ${bitstream_image} from SD to RAM... && mmcinfo && fatload mmc 0 ${loadbit_addr} ${bitstream_image} && fpga loadb 0 ${loadbit_addr} ${filesize}
uenvcmd=run mmc_loadbit_fat

其中uenvcmd会自动运行,从而加载bit文件。

然后将system_top.bit放到sd卡根目录下,重启。
可以看到如下输出:

Running uenvcmd ...
Loading bitstream system_top.bit from SD to RAM...
Device: sdhci@e0100000
Manufacturer ID: 89
OEM: 303
Name: NCard
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 29.1 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
reading system_top.bit
4045666 bytes read in 369 ms (10.5 MiB/s)
  design filename = "system_top;UserID=0XFFFFFFFF;Version=2021.1"
  part number = "7z020clg400"
  date = "2023/08/21"
  time = "23:59:02"
  bytes in bitstream = 4045564
zynq_align_dma_buffer: Align buffer at 100066 to 100000(swap 1)

注意,这里是uboot重新加载了一次bit文件,fsbl先前已经加载了bit文件,只是这里被覆盖了。如果不想fsbl加载bit文件,需要修改boot.bin的生成。

如果需要将上述内容自动加到编译时生成的uEnv.txt文件中,则需要修改文件u-boot-xlnx/include/configs/zynq-common.h,
修改后如下:

#define CONFIG_EXTRA_ENV_SETTINGS	\
	"ethaddr=00:0a:35:00:01:22\0"	\
	"ipaddr=192.168.2.1\0"	\
	"ipaddr_host=192.168.2.10\0"	\
	"netmask=255.255.255.0\0"	\
	"kernel_image=uImage\0"	\
	"fit_load_address=0x2080000\0" \
	"fit_config=config@0\0" \
	"extraenv_load_address=0x207E000\0" \
	"ramdisk_image=uramdisk.image.gz\0"	\
	"ramdisk_load_address=0x4000000\0"	\
	"devicetree_image=devicetree.dtb\0"	\
	"devicetree_load_address=0x2000000\0"	\
	"bitstream_image=system_top.bit\0"	\
...
	"usbboot=if usb start; then " \
			"run uenvboot; " \
			"echo Copying Linux from USB to RAM... && " \
			"load usb 0 ${fit_load_address} ${kernel_image} && " \
			"load usb 0 ${devicetree_load_address} ${devicetree_image} && " \
			"load usb 0 ${ramdisk_load_address} ${ramdisk_image} && " \
			"bootm ${fit_load_address} ${ramdisk_load_address} ${devicetree_load_address}; " \
		"fi\0" \
	"mmc_loadbit_fat=echo Loading bitstream ${bitstream_image} from SD to RAM... && " \
			"mmcinfo && fatload mmc 0 ${loadbit_addr} ${bitstream_image} && " \
			"fpga loadb 0 ${loadbit_addr} ${filesize}\0" \
	"uenvcmd=run mmc_loadbit_fat\0" \
	DFU_ALT_INFO \
	DFU_ALT_INFO_SF1

保存后重新编译,生成uEnv.txt文件中即自动包含了修改的内容。

vivado2019.1+;
uboot16+;

参考:https://blog.csdn.net/weixin_42418557/article/details/89018965

posted @ 2023-08-23 17:00  清哥他弟  阅读(174)  评论(0编辑  收藏  举报