boot.scr

概述

u_boot启动后,在倒计时结束后按照默认参数启动内核,默认参数其实是通过boot.scr向u-boot传参数的

1、boot.scr内容如下

for boot_target in ${boot_targets};
do
	if test "${boot_target}" = "jtag" ; then
		booti 0x00200000 0x04000000 0x00100000
		exit;
	fi
	if test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1" ; then
		if test -e ${devtype} ${devnum}:${distro_bootpart} /image.ub; then
			fatload ${devtype} ${devnum}:${distro_bootpart} 0x10000000 image.ub;
			bootm 0x10000000;
			exit;
                fi
		if test -e ${devtype} ${devnum}:${distro_bootpart} /Image; then
			fatload ${devtype} ${devnum}:${distro_bootpart} 0x00200000 Image;;
		fi
		if test -e ${devtype} ${devnum}:${distro_bootpart} /system.dtb; then
			fatload ${devtype} ${devnum}:${distro_bootpart} 0x00100000 system.dtb;
		fi
		if test -e ${devtype} ${devnum}:${distro_bootpart} /rootfs.cpio.gz.u-boot; then
			fatload ${devtype} ${devnum}:${distro_bootpart} 0x04000000 rootfs.cpio.gz.u-boot;
			booti 0x00200000 0x04000000 0x00100000
			exit;
		fi
		booti 0x00200000 - 0x00100000
		exit;
	fi
	if test "${boot_target}" = "xspi0" || test "${boot_target}" = "qspi" || test "${boot_target}" = "qspi0"; then
		sf probe 0 0 0;
		if test "image.ub" = "image.ub"; then
			sf read 0x10000000 0xa10000 0x1500000;
			bootm 0x10000000;
			exit;
		fi
		if test "image.ub" = "Image"; then
			sf read 0x00200000 0x3F00000 0x1D00000;
			sf read 0x04000000 0x5D00000 0x1D00000
			booti 0x00200000 0x04000000 0x00100000
			exit;
		fi
		exit;
	fi
	if test "${boot_target}" = "nand" || test "${boot_target}" = "nand0"; then
		nand info
		if test "image.ub" = "image.ub"; then
			nand read 0x10000000 0x4100000 0x6400000;
			bootm 0x10000000;
			exit;
		fi
		if test "image.ub" = "Image"; then
			nand read 0x00200000 0x4100000 0x3200000;
			nand read 0x04000000 0x7800000  0x3200000;
			booti 0x00200000 0x04000000 0x00100000
			exit;
		fi
	fi
done
  • 1.1 首先查询boot_target(可以通过下述指令查看),例如我是从qsipflash启动的,且image.ub=image.ub
printenv

在这里插入图片描述

  • 1.2 初始化qspi_flashsf probe 0 0 0,然后判断image.ub类型
	if test "${boot_target}" = "xspi0" || test "${boot_target}" = "qspi" || test "${boot_target}" = "qspi0"; then
		sf probe 0 0 0;
		if test "image.ub" = "image.ub"; then
			sf read 0x10000000 0xa10000 0x1500000;
			bootm 0x10000000;
			exit;
		fi
		if test "image.ub" = "Image"; then
            XXXXXXXXXXXXXXXXXXXXXXXXXX
            XXXXXXXXXXXXXXXXXXXXXXXXXX
            XXXXXXXXXXXXXXXXXXXXXXXXX
		fi
		exit;
	fi
  • 1.3 从falsh读取kernel镜像,我的镜像位于flash地址0xa10000,长度为0x1500000,存于DDR 0x10000000
    在这里插入图片描述

  • 1.4 从DDR 0x10000000地址启动内核

2、boot.scr如何生成的?

2.1 mkimage可以用来生成boot.scr

  • mkimage在制作映象文件的时候,是在原来的可执行映象文件的前面加上一个0x40字节的头,记录参数所指定的信息,这样uboot才能识别这个映象是针对哪个CPU体系结构的,哪个OS的,哪种类型,加载内存中的哪个位置, 入口点在内存的那个位置以及映象名是什么
./mkimage -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
-A ==> set architecture to 'arch'
-O ==> set operating system to 'os'
-T ==> set image type to 'type'
-C ==> set compression type 'comp'
-a ==> set load address to 'addr' (hex)
-e ==> set entry point to 'ep' (hex)
-n ==> set image name to 'name'
-d ==> use image data from 'datafile'
-x ==> set XIP (execute in place)

2.2 mkimage位值(petalinux2021.2)

  • mkimage位于prj_petalinux/build/tmp/sysroots-components/x86_64/u-boot-tools-native/usr/bin目录下

2.3 执行

./mkimage -c none -A arm -T script -d xxx./xxx./boot.cmd boot.scr
  • 在2.2路径下执行上述指令即可生成boot.scr,其中xxx./xxx./boot.cmd代表boot.cmd的绝对路径,这里说通俗一点就是在boot.cmd前面加一个头,这样在u-boot读取该段内容时进行CRC校验,已确读取的内容正确。

3、image.ub

  • image.ub, is a FIT image(https://blog.csdn.net/ee230/article/details/53318027)
  • 在INITRAMFS模式下mpsoc中包含了rootfs.cpio文件系统和内核镜像
    在这里插入图片描述

4、bootm bootz booti

  • bootm和bootz的不同地方
  • bootm用于加载uImage和ramdisk(rootfs.cpio)
bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address};
  • bootz用于加载zImage和ext4文件系统
bootz ${kernel_load_address} - ${devicetree_load_address}
  • zImage 是Image的压缩文件
  • uImage U-boot专用的映像文件,它是在zImage之前加上一个长度为0x40
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值