blob: 93de8669109d906cc8cd3eab202af7185c909da7 [file] [log] [blame]
Fabio Estevamf4630122023-04-26 13:05:01 -03001// SPDX-License-Identifier: GPL-2.0+
2#ifdef CONFIG_SYS_BOOT_LOCKED
3#define SETUP_BOOT_MENU setup_boot_menu=setenv bootmenu_0 eMMC=run bootcmd
4#else
5#define SETUP_BOOT_MENU setup_boot_menu= \
6 if test "${mmcdev}" = 1; then \
7 setenv emmc_priority 0; \
8 setenv sd_priority 1; \
9 else setenv emmc_priority 1; \
10 setenv sd_priority 0; \
11 fi; \
12 setenv bootmenu_${emmc_priority} eMMC=run boot_emmc; \
13 setenv bootmenu_${sd_priority} SD=run boot_sd;
14#endif
15
16altbootcmd=
17 echo Performing rollback...;
18 if test "${mmcpart_committed}" = 1; then
19 setenv mmcpart 2;
20 setenv mmcpart_committed 2;
21 else
22 setenv mmcpart 1;
23 setenv mmcpart_committed 1;
24 fi;
25 setenv bootcount 0;
26 setenv upgrade_available;
27 setenv ustate 3;
28 saveenv;
29 run bootcmd;
30boot_emmc=setenv mmcdev_wanted 1; run persist_mmcdev; run bootcmd;
31boot_sd=setenv mmcdev_wanted 0; run persist_mmcdev; run bootcmd;
Eduard Strehlauf37cddd2023-06-26 11:31:36 -030032bootcmd=
33 if test "${bootcount}" -gt "${bootlimit}"; then
34 run altbootcmd;
35 else
36 if test "${ustate}" = 1; then
37 setenv upgrade_available 1;
38 saveenv;
39 fi;
40 run mmcboot;
41 fi;
Fabio Estevamf4630122023-04-26 13:05:01 -030042bootdelay=2
43bootlimit=3
44bootm_size=0x10000000
45commit_mmc=
46 if test "${ustate}" = 1 -a "${mmcpart}" != "${mmcpart_committed}"; then
47 setenv mmcpart_committed ${mmcpart};
48 saveenv;
49 fi;
50console=ttymxc0
Fabio Estevamf4630122023-04-26 13:05:01 -030051loadbootpart=mmc partconf 1 boot_part
Eduard Strehlaua1bcf002023-09-20 07:49:08 -030052loadimage=load mmc ${mmcdev}:${gpt_partition_entry}
Fabio Estevamf4630122023-04-26 13:05:01 -030053loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed}
54mmcargs=
55 setenv bootargs console=${console},${baudrate} root=/dev/mmcblk${mmcdev}p${gpt_partition_entry} rootwait rw SM_ROOT_DEV=${mmcdev} SM_ROOT_PART=${gpt_partition_entry} SM_BOOT_PART=${boot_part}
56mmcboot=
57 echo Booting...;
58 echo mmcdev: ${mmcdev};
59 run commit_mmc;
60 echo mmcpart: ${mmcpart_committed};
61 run loadpart;
62 echo gptpart: ${gpt_partition_entry};
63 run loadbootpart;
64 if run loadimage; then
65 ;
66 else
67 run altbootcmd;
68 fi;
Eduard Strehlaua1bcf002023-09-20 07:49:08 -030069#ifdef CONFIG_SYS_BOOT_LOCKED
Eduard Strehlaua1bcf002023-09-20 07:49:08 -030070 hab_auth_img_or_fail ${fileaddr} ${filesize};
Eduard Strehlaud3b841e2023-09-25 13:32:59 -030071#else
72 hab_auth_img ${fileaddr} ${filesize};
Eduard Strehlaua1bcf002023-09-20 07:49:08 -030073#endif
Fabio Estevamf4630122023-04-26 13:05:01 -030074 run mmcargs;
Eduard Strehlaua1bcf002023-09-20 07:49:08 -030075 if bootm; then
Fabio Estevamf4630122023-04-26 13:05:01 -030076 ;
77 else
78 run altbootcmd;
79 fi;
80mmcdev=1
81mmcpart=1
82mmcpart_committed=1
83persist_mmcdev=
84 if test "${mmcdev}" != "${mmcdev_wanted}"; then
85 setenv mmcdev "${mmcdev_wanted}";
86 saveenv;
87 fi;
88setup_boot_menu=
89 if test "${mmcdev}" = 1; then
90 setenv emmc_priority 0;
91 setenv sd_priority 1;
92 else
93 setenv emmc_priority 1;
94 setenv sd_priority 0;
95 fi;
96 setenv bootmenu_${emmc_priority} eMMC=run boot_emmc;
97 setenv bootmenu_${sd_priority} SD=run boot_sd;
98SETUP_BOOT_MENU