'VÖësÒM›žð  Œ        2JŒ° Boot script                       „    # This is a boot script for U-Boot
# Generate boot.scr:
# mkimage -c none -A arm -T script -d boot.cmd.default boot.scr
#
################
fitimage_name=image.ub
kernel_name=Image
ramdisk_name=kria-image-initramfs-k24-smk.cpio.gz.u-boot
rootfs_name=rootfs.cpio.gz.u-boot


# Close pmufw node so that linux can't send small fragments to pmufw
zynqmp pmufw node close

# k24 Starter Kit default boot args
if test "${board_name}" = "${k24_starter}"; then
	setenv bootargs 'earlycon console=ttyPS1,115200 init_fatal_sh=1 cma=512M root=LABEL=root';
# k26 Starter Kit default boot args
else test "${board_name}" = "${k26_starter}";
	setenv bootargs 'earlycon console=ttyPS1,115200 init_fatal_sh=1 cma=900M root=LABEL=root';
fi

#Set boot parameters based on CC type
if test "${card1_name}" = "SCK-KV-G"; then
        setenv card_name sck-kv-g;
elif test "${card1_name}" = "SCK-KR-G"; then
	setenv card_name sck-kr-g && setenv bootargs xilinx_tsn_ep.st_pcp=4 $bootargs;
elif test "${card1_name}" = "SCK-KD-G"; then
        setenv card_name sck-kd-g && setenv bootargs xilinx_tsn_ep.st_pcp=4 $bootargs;
else #Assume Kria USB secondary boot device
        setenv card_name unknown;
fi

#Set DT selection
if test "${card1_name}" = "SCK-KV-G"; then
        if test "${card1_rev}" = "Z" || test "${card1_rev}" = "A"; then
                #revA dtb also supports revZ boards
                dtb_name=SMK-zynqmp-${card_name}-revA
        elif test "${card1_rev}" = "B" || test "${card1_rev}" = "1" || test "${card1_rev}" = "2"; then
                #revB dtb also supports rev1 and rev2 boards
                dtb_name=SMK-zynqmp-${card_name}-revB
        else #default dtb if card revision is not found
                dtb_name=SMK-zynqmp-${card_name}-revB
                echo "Card revision not found, using default dtb: ${dtb_name}.dtb"
        fi
elif test "${card1_name}" = "SCK-KR-G"; then
	if test "${card1_rev}" = "B" || test "${card1_rev}" = "1"; then
		#revB dtb also supports rev1 dtb
		dtb_name=SMK-zynqmp-${card_name}-revB
	elif test "${card1_rev}" = "A"; then
		dtb_name=SMK-zynqmp-${card_name}-revA
	else #default dtb if card revision is not found
		dtb_name=SMK-zynqmp-${card_name}-revB
		echo "Card revision not found, using default dtb: ${dtb_name}.dtb"
	fi
elif test "${card1_name}" = "SCK-KD-G"; then
        if test "${card1_rev}" = "A" || test "${card1_rev}" = "B" || test "${card1_rev}" = "1"; then
                dtb_name=SMK-zynqmp-${card_name}-revA
	else #default dtb if card revision not found
		dtb_name=SMK-zynqmp-${card_name}-revA
		echo "Card revision not found, using default dtb: ${dtb_name}.dtb"
	fi
else
        dtb_name=system
fi

for boot_target in ${boot_targets};
do
echo "Trying to load boot images from ${boot_target}"
if test "${boot_target}" = "mmc0" || test "${boot_target}" = "mmc1" || test "${boot_target}" = "usb0" || test "${boot_target}" = "usb1"; then
        if test -e ${devtype} ${devnum}:${distro_bootpart} /${fitimage_name}; then
                fatload ${devtype} ${devnum}:${distro_bootpart} 0x10000000 ${fitimage_name};
                bootm 0x10000000;
        fi
        if test -e ${devtype} ${devnum}:${distro_bootpart} /${kernel_name}; then
                fatload ${devtype} ${devnum}:${distro_bootpart} 0x00200000 ${kernel_name};
        fi
        if test -e ${devtype} ${devnum}:${distro_bootpart} /devicetree/${dtb_name}.dtb; then
                fatload ${devtype} ${devnum}:${distro_bootpart} 0x00100000 devicetree/${dtb_name}.dtb;
        else
		echo "Expected ${dtb_name} Not Found in FAT Partition, Booting with SOM only DTB"
	fi
	if test -e ${devtype} ${devnum}:${distro_bootpart} /devicetree/openamp.dtbo; then
		echo "Loading and merging openamp.dtbo into device tree";
		fatload ${devtype} ${devnum}:${distro_bootpart} 0x1000000 devicetree/openamp.dtbo;
		fdt addr 0x00100000
		fdt resize 8192
		fdt apply 0x1000000
	fi

        if test -e ${devtype} ${devnum}:${distro_bootpart} /${ramdisk_name} && test "${skip_tinyramdisk}" != "yes"; then
                fatload ${devtype} ${devnum}:${distro_bootpart} 0x04000000 ${ramdisk_name};
                booti 0x00200000 0x04000000 0x00100000
        fi
        if test -e ${devtype} ${devnum}:${distro_bootpart} /${rootfs_name} && test "${skip_ramdisk}" != "yes"; then
                fatload ${devtype} ${devnum}:${distro_bootpart} 0x04000000 ${rootfs_name};
                booti 0x00200000 0x04000000 0x00100000
        fi
        booti 0x00200000 - 0x00100000
fi
done
