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的完整帮助分别详细说明了用法上的差异。