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 |
| 51 | fdt_addr=0x83000000 |
| 52 | fdtfile=imx7d-smegw01.dtb |
| 53 | fit_addr=0x88000000 |
| 54 | image=fitImage |
| 55 | loadaddr=0x80800000 |
| 56 | loadbootpart=mmc partconf 1 boot_part |
| 57 | loadimage=load mmc ${mmcdev}:${gpt_partition_entry} ${fit_addr} boot/${image} |
| 58 | loadpart=gpt setenv mmc ${mmcdev} rootfs-${mmcpart_committed} |
| 59 | mmcargs= |
| 60 | 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} |
| 61 | mmcboot= |
| 62 | echo Booting...; |
| 63 | echo mmcdev: ${mmcdev}; |
| 64 | run commit_mmc; |
| 65 | echo mmcpart: ${mmcpart_committed}; |
| 66 | run loadpart; |
| 67 | echo gptpart: ${gpt_partition_entry}; |
| 68 | run loadbootpart; |
| 69 | if run loadimage; then |
| 70 | ; |
| 71 | else |
| 72 | run altbootcmd; |
| 73 | fi; |
| 74 | run mmcargs; |
| 75 | if bootm ${fit_addr}; then |
| 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 |