Fabio Estevam | f463012 | 2023-04-26 13:05:01 -0300 | [diff] [blame] | 1 | // 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 | |
| 16 | altbootcmd= |
| 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; |
| 30 | boot_emmc=setenv mmcdev_wanted 1; run persist_mmcdev; run bootcmd; |
| 31 | boot_sd=setenv mmcdev_wanted 0; run persist_mmcdev; run bootcmd; |
Eduard Strehlau | f37cddd | 2023-06-26 11:31:36 -0300 | [diff] [blame] | 32 | bootcmd= |
| 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 Estevam | f463012 | 2023-04-26 13:05:01 -0300 | [diff] [blame] | 42 | bootdelay=2 |
| 43 | bootlimit=3 |
| 44 | bootm_size=0x10000000 |
| 45 | commit_mmc= |
| 46 | if test "${ustate}" = 1 -a "${mmcpart}" != "${mmcpart_committed}"; then |
| 47 | setenv mmcpart_committed ${mmcpart}; |
| 48 | saveenv; |
| 49 | fi; |
| 50 | console=ttymxc0 |
Fabio Estevam | f463012 | 2023-04-26 13:05:01 -0300 | [diff] [blame] | 51 | loadbootpart=mmc partconf 1 boot_part |
Eduard Strehlau | a1bcf00 | 2023-09-20 07:49:08 -0300 | [diff] [blame] | 52 | loadimage=load mmc ${mmcdev}:${gpt_partition_entry} |
Fabio Estevam | f463012 | 2023-04-26 13:05:01 -0300 | [diff] [blame] | 53 | loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed} |
| 54 | mmcargs= |
| 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} |
| 56 | mmcboot= |
| 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 Strehlau | a1bcf00 | 2023-09-20 07:49:08 -0300 | [diff] [blame] | 69 | #ifdef CONFIG_SYS_BOOT_LOCKED |
Eduard Strehlau | a1bcf00 | 2023-09-20 07:49:08 -0300 | [diff] [blame] | 70 | hab_auth_img_or_fail ${fileaddr} ${filesize}; |
Eduard Strehlau | d3b841e | 2023-09-25 13:32:59 -0300 | [diff] [blame] | 71 | #else |
| 72 | hab_auth_img ${fileaddr} ${filesize}; |
Eduard Strehlau | a1bcf00 | 2023-09-20 07:49:08 -0300 | [diff] [blame] | 73 | #endif |
Fabio Estevam | f463012 | 2023-04-26 13:05:01 -0300 | [diff] [blame] | 74 | run mmcargs; |
Eduard Strehlau | a1bcf00 | 2023-09-20 07:49:08 -0300 | [diff] [blame] | 75 | if bootm; then |
Fabio Estevam | f463012 | 2023-04-26 13:05:01 -0300 | [diff] [blame] | 76 | ; |
| 77 | else |
| 78 | run altbootcmd; |
| 79 | fi; |
| 80 | mmcdev=1 |
| 81 | mmcpart=1 |
| 82 | mmcpart_committed=1 |
| 83 | persist_mmcdev= |
| 84 | if test "${mmcdev}" != "${mmcdev_wanted}"; then |
| 85 | setenv mmcdev "${mmcdev_wanted}"; |
| 86 | saveenv; |
| 87 | fi; |
| 88 | setup_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; |
| 98 | SETUP_BOOT_MENU |