Booting 使用tftp模式加载 linux镜像
前置准备:
已经安装vivado 启动SDK工具,打开了Ethernet控制
已经有petalinux生成的Boot.bin,zynq_fsbl.elf,image.ub
使用SDK烧写Boot.bin,zynq_fsbl.el
在电脑端配置tftp32的server绑定IP到192.168.1.104
启动板子进入ZynpMP提示符,
输入以下命令:
setenv serverip 192.168.1.104 setenv ipaddr 192.168.1.101 tftpboot 0x30000000 image.ub bootm 0x30000000
Booting 使用tftp模式加载 linux镜像并且固化到flash中
仍然使用tftp加载image.ub到内存,然后使用sf操作flash,将内存中的image.ub固化到flash指定位置:
setenv serverip 192.168.1.105 setenv ipaddr 192.168.1.101 tftpboot 0x30000000 image.ub #copy image.ub到内存0x30000000 setenv kernelsize 0x2000000 sf probe 0 0 0 sf erase ${kernelstart} ${kernelsize} #把flash中的${kernelstart}~${kernelsize}大小的内容擦除 sf write 0x30000000 ${kernelstart} ${kernelsize} #把DDR内存中0x30000000开始的${kernelsize}的内容写到flash ${kernelstart}开始的后面的空间去。
从flash运行image.ub
run cp_kernel2ram && bootm ${netstart}
# cp_kernel2ram 可以print 打印cp_kernel2ram内容,copy ${kernelstart}到DDR内存地址0x10000000
添加python支持
petalinux-config -c rootfs
#->Filesystem Packages->misc->python->python3
Booting 使用JTAG 模式加载 linux镜像
前置准备:
已经安装vivado 启动SDK工具
已经有petalinux生成的u-boot.elf,zynq_fsbl.elf,image.ub
下载bitstream
1.如果有FPGA程序,使用 SDK自带的Xilinx Tools → Program FPGA 点击program;没有则直接跳过该步骤。
2.打开Xilinx System Debugger (XSCT)SDK自带的调试工具Xilinx Tools → XSCT Console.
3.在XSCT命令提示下,做如下操作
xsct% xsct% connect tcfchan#1 xsct% targets 1 PS TAP 2 PMU 3 PL 4 PSU 5 RPU 6 Cortex-R5 #0 (Halted) 7 Cortex-R5 #1 (Lock Step Mode) 8 APU 9 Cortex-A53 #0 (Running) 10 Cortex-A53 #1 (Power On Reset) xsct% ta 9 xsct% dow "C:/Users/changry/Desktop/zynqmp_fsbl.elf" Downloading Program -- C:/Users/changry/Desktop/zynqmp_fsbl.elf section, .text: 0xfffc0000 - 0xfffcd91f section, .init: 0xfffcd940 - 0xfffcd973 section, .fini: 0xfffcd980 - 0xfffcd9b3 section, .note.gnu.build-id: 0xfffcd9b4 - 0xfffcd9d7 section, .rodata: 0xfffcda00 - 0xfffce417 section, .sys_cfg_data: 0xfffce440 - 0xfffcec77 section, .mmu_tbl0: 0xfffcf000 - 0xfffcf00f section, .mmu_tbl1: 0xfffd0000 - 0xfffd1fff section, .mmu_tbl2: 0xfffd2000 - 0xfffd5fff section, .data: 0xfffd6000 - 0xfffd7377 section, .sbss: 0xfffd7378 - 0xfffd737f section, .bss: 0xfffd7380 - 0xfffddb7f section, .heap: 0xfffddb80 - 0xfffddf7f section, .stack: 0xfffddf80 - 0xfffdff7f section, .dup_data: 0xfffdff80 - 0xfffe12f7 section, .handoff_params: 0xfffe9e00 - 0xfffe9e87 section, .bitstream_buffer: 0xffff0040 - 0xfffffc3f 0% 0MB 0.0MB/s ??:?? ETA 100% 0MB 0.4MB/s 00:00 Setting PC to Program Start Address 0xfffc0000 Successfully downloaded C:/Users/changry/Desktop/zynqmp_fsbl.elf
xsct% con
xsct% dow "C:/Users/changry/Desktop/u-boot.elf"
xsct% dow -data "C:/Users/changry/Desktop/image.ub" 0x30000000
之后在串口界面执行
ZynqMP> bootm 0x30000000
可以看到进入了linux的提示命令行
U-Boot 命令
在U-Boot提示符下可以访问U-Boot命令列表。键入“帮助”或“?”有关可用命令的完整列表。下面给出一个例子:
? - alias for 'help' base - print or set address offset bdinfo - print Board Info structure boot - boot default, i.e., run 'bootcmd' bootd - boot default, i.e., run 'bootcmd' bootm - boot application image from memory bootp - boot image via network using BOOTP/TFTP protocol cmp - memory compare coninfo - print console devices and information cp - memory copy crc32 - checksum calculation date - get/set/reset date && time echo - echo args to console editenv - edit environment variable erase - erase FLASH memory ext2load- load binary file from a Ext2 filesystem ext2ls - list files in a directory (default /) fatinfo - print information about filesystem fatload - load binary file from a dos filesystem fatls - list files in a directory (default /) fdt - flattened device tree utility commands flinfo - print FLASH memory information go - start application at address 'addr' help - print command description/usage iminfo - print header information for application image imls - list all images found in flash imxtract- extract a part of a multi-image itest - return true/false on integer compare loadb - load binary file over serial line (kermit mode) loads - load S-Record file over serial line loady - load binary file over serial line (ymodem mode) loop - infinite loop on address range md - memory display mm - memory modify (auto-incrementing address) mmc - MMC sub system mmcinfo - display MMC info mtest - simple RAM read/write test mw - memory write (fill) nfs - boot image via network using NFS protocol nm - memory modify (constant address) ping - send ICMP ECHO_REQUEST to network host printenv- print environment variables protect - enable or disable FLASH write protection rarpboot- boot image via network using RARP/TFTP protocol reset - Perform RESET of the CPU run - run commands in an environment variable setenv - set environment variables sf - SPI flash sub-system sleep - delay execution for some time source - run script from memory sspi - SPI utility commands tftpboot- boot image via network using TFTP protocol version - print monitor version
烧写QSPI Flash
U-Boot提供SF命令来对串行闪存设备进行编程。在所有通过u-boot进行的Xilinx平台上,您都可以使用SF命令对QSPI设备进行编程。这是将图像文件加载到QSPI设备的示例。
uboot> sf Usage: sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus and chip select sf read addr offset len - read 'len' bytes starting at 'offset' to memory at 'addr' sf write addr offset len - write 'len' bytes from memory at 'addr' to flash at 'offset' sf erase offset [+]len - erase 'len' bytes from 'offset'; '+len' round up 'len' to block size sf update addr offset len - erase and write 'len'bytes from memory at 'addr' to flash at 'offset uboot> sf probe 0 0 0 SF: Detected N25Q128 with page size 256, total 16 MiB 16384 KiB N25Q128 at 0:0 is now current device
引导应用程序映像
U-Boot提供了bootm命令来引导应用程序映像(即Linux),该映像希望这些映像可以使用mkimage用U-Boot特定的标头包装。该命令可用于引导旧的U-Boot映像或新的多组件映像(FIT),如U-Boot中所述。
标准的Linux构建过程将构建包装器uImage,而Petalinux项目默认也会生成多组件FIT图像。
以下U-Boot命令说明了使用bootm命令使用单个映像和FIT映像从SD卡加载Linux映像。
u-boot> fatload mmc 0 0x3000000 uImage u-boot> fatload mmc 0 0x2A00000 devicetree.dtb u-boot> fatload mmc 0 0x2000000 uramdisk.image.gz u-boot> bootm 0x3000000 0x2000000 0x2A00000 u-boot> fatload mmc 0 0x1000000 image.ub u-boot> bootm 0x1000000
使用bootm命令,U-Boot会在引导Linux之前重新定位映像,以使上面的地址可能不是内核看到的地址。
U-Boot还会更改设备树,以告知内核ramdisk映像在内存中的位置(initrd-start和initrd-end)。bootm命令将r2寄存器设置为内存中设备树的地址,而go命令无法完成该操作。
使用booti命令和bootm命令的差异和用例也不断发展。
从U-Boot 2020.01开始,主要区别在于处理U-Boot帮助中所述的未压缩Linux映像文件(在64位Arm平台上常见)与压缩Linux zImage文件(在32位Arm平台上常见)。通常,仅根据Linux映像类型来区分用法,
不是仅基于体系结构来区分。booti-从内存中启动Linux内核“映像”格式。bootm-从内存启动应用程序映像
booti和bootm的完整帮助分别详细说明了用法上的差异。