运行
petalinux-devtool modify u-boot-xlnx
会把uboot源码放在
components/yocto/workspace/sources
目录下
老版本用命令
petalinux-build -c u-boot -x modify
https://www.cnblogs.com/hankfu/p/16058337.html
随着petalinux版本不一样,目录可能会有差异
源码位于工程目录的((petalinux-config -c u-boot)
比如有的版本是在
components/plnx_workspace/sources/u-boot-xlnx
官方下载链接
https://github.com/Xilinx/u-boot-xlnx
2.1.1 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
// Detect QSPI Flash parameters
// To make QSPI clock run faster, higher speed can be set to second parameter,
// e.g. setting QSPI clock to 20MHz
// sf probe 0 20000000 0
2.1.2 uboot> sf erase 0 0x200000
// Erase 2MB from QSPI offset 0x0
// Note: If erase size is less than QSPI Flash page size, u-boot reports erase error
2.1.3 uboot> sf read 0x08000000 0 100
// Read QSPI Flash from 0x0 to DDR 0x08000000 with 100 bytes
// you can use any location in DDR as destination. make sure it doesnt overwrite u-boot
// code/data area. u-boot is at 0x04000000.
2.1.4 uboot> md 08000000
08000000: ffffffff ffffffff ffffffff ffffffff ................
// Display content in memory 0x08000000.
// U-boot by default uses hex
2.1.5 uboot> loadb 0x08000000
// load the boot image to DDR
// load method can be KERMIT through UART, XMD dow -data through JTAG, TFTP through Ethernet
// or read from SD Card directly
// load the boot image through KERMIT protocol after this step
// it is assumed that you should have a boot image generated using the bootgen utility
## Ready for binary (kermit) download to 0x08000000 at 115200 bps...
## Total Size = 0x0003e444 = 255044 Bytes
## Start Addr = 0x08000000
uboot> md 08000000 100
2.1.6 uboot> sf write 0x08000000 0 0x3E444
// Write from DDR address 0x08000000 to QSPI offset 0 with 0x3E444 bytes of data
// U-Boot read command can be used to see what is programmed in to QSPI memory.
// Following is the syntax of the "sf read" command.
zynq-boot> sf read <destination address in RAM> <source address in QSPI> <length of data to read>
NOTE: The "destination address" should not be ZERO.
Example:
uboot> sf read 0x800 0x0 0x2000
2.2.1 nand info
2.2.2 nand erase <start addr> <size>
// Download the image to a location DDR(DDR addr) using tftp and then perform write to nand from that DDR address as shown below.
2.2.3 nand write <DDR addr> <start addr> <size>
// The nand programming was done wuith the above command but to ensure that it has written successfully just read the written data using the below read command.
// Provide DDR addr different from the above and differ from the above DDR addr at least by the <size> so that we can compare both using cmp command and ensure it was written successfully.
2.2.4 nand read <DDR addr> <start addr>
2.3.1 flinfo
2.3.2 erase all
2.3.3 cp.b <DDR addr> <nor addr> <size>.
- booti: 引导ARM64 kernel image—-Image;
- bootz: 引导ARM kernel image—-zImage;
- bootm: 引导u-boot自定义的kernel image—-uImage。
tftpboot [loadAddress] [[hostIPaddr:]bootfilename]
48M
u-boot> fatload mmc 0 0x3000000 uImage
42M
u-boot> fatload mmc 0 0x2A00000 devicetree.dtb
32M
u-boot> fatload mmc 0 0x2000000 uramdisk.image.gz
kernel rootfs dtb 不指定的时候用-代替
u-boot> bootm 0x3000000 0x2000000 0x2A00000
2.4.1 用法举例:image.ub -- 从tftp加载image.ub
setenv ipaddr 10.0.0.99;setenv serverip 10.0.0.102;
tftpboot 0x3000000 /tftpboot/image.ub
bootm
2.4.2 用法举例:image.ub -- 从sd卡上加载image.ub到内存0x10000000(256M)
fatload mmc 0 0x10000000 image.ub
bootm 0x10000000
2.4.3 用法举例:rootfs放在sd卡第2分区上,从tftp下载Image和dtb
制作根 文件的时候,如果分区根目录没有init,则
sudo ln -s sbin/init init
设置ip
setenv ipaddr 10.0.0.99;setenv serverip 10.0.0.102;
分Image和system.dtb两个文件加载
setenv bootargs earlycon clk_ignore_unused consoleblank=0 cma=1700M uio_pdrv_genirq.of_id=generic-uio root=/dev/mmcblk0p2
tftpboot 0x3000000 /tftpboot/Image;tftpboot 0x2A00000 /tftpboot/system.dtb;
booti 0x03000000 - 0x02A00000
直接加载不带rootfs的image.ub
setenv bootargs earlycon clk_ignore_unused consoleblank=0 cma=1700M uio_pdrv_genirq.of_id=generic-uio root=/dev/mmcblk0p2
tftpboot 0x3000000 /tftpboot/image.ub;bootm 0x03000000
2.4.4 用法举例:rootfs放在sd卡第2分区上,从sd卡加载Image和dtb
制作根 文件的时候,如果分区根目录没有init,则
sudo ln -s sbin/init init
分Image和system.dtb两个文件加载
setenv bootargs earlycon clk_ignore_unused consoleblank=0 cma=1700M uio_pdrv_genirq.of_id=generic-uio root=/dev/mmcblk0p2
fatload mmc 0 0x03000000 Image
fatload mmc 0 0x02A00000 system.dtb
booti 0x03000000 - 0x02A00000
直接加载不带rootfs的image.ub
setenv bootargs earlycon clk_ignore_unused consoleblank=0 cma=1700M uio_pdrv_genirq.of_id=generic-uio root=/dev/mmcblk0p2
fatload mmc 0 0x03000000 image.ub
bootm 0x03000000
2.4.5 用法举例:从tftp下载Image、dtb、rootfs??????rootfs不成功,提示格式不对
setenv ipaddr 10.0.0.99;setenv serverip 10.0.0.102;
tftpboot 0x3000000 /tftpboot/Image;tftpboot 0x2A00000 /tftpboot/system.dtb;
tftpboot 0x4000000 /tftpboot/rootfs.cpio.gz.u-boot
booti 0x03000000 0x4000000 0x02A00000
2.4.6 从sd卡启动image
fatload mmc 0 0x3000000 uImage
fatload mmc 0 0x2A00000 devicetree.dtb
bootm 0x3000000 - 0x2A00000
3. 环境变量保存
petalinux-config -c u-boot
Environment
取消Environment is not stored
选中Environment is in a FAT filesystem和Environment in an MMC device
编译报错
打开
components/yocto/workspace/sources/u-boot-xlnx/include/configs/xilinx_zynqmp.h
添加
#define CONFIG_SYS_MMC_ENV_DEV 0
编译通过
在开发板上测试
然后查看sd卡
说明保存成功
3.1.2 spi flash
偏移量1E00000 30M 大小0x8000 32k 扇区大小0x40000 256k
启动uboot,保存
从flash读到内存,然后显示,如图。说明保存成功
3.2 如果u-boot里没有saveenv命令(默认是已经选中)
petalinux-config -c u-boot
Command line interface --> Environment commands --> saveenv
1.sd卡加载boot.bin和image.ub可以脱机运行
缺点:需要反复插拔sd卡,需要打包image.ub
2.sd卡加载boot.bin,tftp加载image.ub
避免了反复插拔sd卡,还是需要打包image.ub
3.sd卡加载boot.bin,tftp加载image、system.dtb rootfs
避免了反复打包image.ub的时间,可以只编译内核或者只编译dtb
4.sd卡加载boot.bin,tftp加载image和system.dtb,sd卡存放 rootfs(推荐方式)
rootfs一般变化不大,调试阶段需要反复修改的是内核代码和设备树,节省了tftp下载rootfs的时间。缺点是需要硬件支持sd卡