ROOTFS_A ROOTFS_B slot BOOT_A_LEFT 10 BOOT_B_LEFT 10 ROOTFS_A_VALID YES ROOTFS_B_VALID NO checkbootcount=if test -e ${ACTIVE_SLOT}; then echo ${ACTIVE_SLOT} exist; else setenv ACTIVE_SLOT ROOTFS_A; test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 5;test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 5; fi; if test ${ACTIVE_SLOT} = ROOTFS_A; then if itest ${BOOT_A_LEFT} -gt 0; then setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1; setenv bootpart ${mmcdev}:2; setenv slot actual_slot=ROOTFS_A; elif itest ${BOOT_B_LEFT} -gt 0; then setenv bootpart ${mmcdev}:3; setenv slot actual_slot=ROOTFS_B; setenv ACTIVE_SLOT ROOTFS_B; fi; fi; if test ${ACTIVE_SLOT} = ROOTFS_B; then if itest ${BOOT_B_LEFT} -gt 0; then setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1; setenv bootpart ${mmcdev}:3; setenv slot actual_slot=ROOTFS_B; elif itest ${BOOT_A_LEFT} -gt 0; then setenv bootpart ${mmcdev}:2; setenv slot actual_slot=ROOTFS_A; setenv ACTIVE_SLOT ROOTFS_A; fi; fi; part uuid mmc ${bootpart} uuid; saveenv args_mmc=if run checkbootcount;then printenv slot;fi;setenv bootargs console=${console} ${optargs} fips=1 root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype} ${slot} mmcboot=mmc dev ${mmcdev};setenv devnum {mmcdev}; setenv devtype mmc;echo DEBUG devtype:${devtype} devnum:{devnum}; if mmc rescan; then echo DEBUG SD/MMC found on device ${mmcdev}; if run checkbootcount;else echo DEBUG mmcboot checkrunboot successfully from mmcboot cmd;printenv slot;fi; if run loadimage; then run args_mmc; echo "loadimage success"; printenv ${loadimage}; if test ${boot_fit} -eq 1; then run run_fit; else run mmcloados; fi; else "loadimage failed" fi; fi;