Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Boot related environment variable definitions on TI boards. |
| 4 | * |
| 5 | * (C) Copyright 2017 Linaro Ltd. |
| 6 | * Sam Protsenko <semen.protsenko@linaro.org> |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __TI_BOOT_H |
| 10 | #define __TI_BOOT_H |
| 11 | |
| 12 | #ifndef CONSOLEDEV |
Sam Protsenko | 02c005f | 2019-07-12 20:38:12 +0300 | [diff] [blame] | 13 | #define CONSOLEDEV "ttyS2" |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 14 | #endif |
| 15 | |
| 16 | #ifndef PARTS_DEFAULT |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 17 | /* |
| 18 | * Default GPT tables for eMMC (Linux and Android). Notes: |
| 19 | * 1. Keep partitions aligned to erase group size (512 KiB) when possible |
| 20 | * 2. Keep partitions in sync with DFU_ALT_INFO_EMMC (see dfu.h) |
| 21 | * 3. Keep 'bootloader' partition (U-Boot proper) start address in sync with |
| 22 | * CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (see common/spl/Kconfig) |
| 23 | */ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 24 | #define PARTS_DEFAULT \ |
| 25 | /* Linux partitions */ \ |
| 26 | "uuid_disk=${uuid_gpt_disk};" \ |
| 27 | "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \ |
| 28 | "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \ |
| 29 | /* Android partitions */ \ |
| 30 | "partitions_android=" \ |
| 31 | "uuid_disk=${uuid_gpt_disk};" \ |
| 32 | "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \ |
Sam Protsenko | 78371f3 | 2018-11-15 22:26:17 +0200 | [diff] [blame] | 33 | "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ |
Sam Protsenko | 22b7130 | 2019-01-04 22:09:08 +0200 | [diff] [blame] | 34 | "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 35 | "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 36 | "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ |
| 37 | "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ |
| 38 | "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \ |
| 39 | "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \ |
| 40 | "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \ |
| 41 | "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \ |
| 42 | "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \ |
| 43 | "name=super,size=2560M,uuid=${uuid_gpt_super};" \ |
| 44 | "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 45 | "name=userdata,size=-,uuid=${uuid_gpt_userdata}" |
| 46 | #endif /* PARTS_DEFAULT */ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 47 | |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 48 | #if defined(CONFIG_CMD_AVB) |
| 49 | #define AVB_VERIFY_CHECK "if run avb_verify; then " \ |
| 50 | "echo AVB verification OK.;" \ |
| 51 | "set bootargs $bootargs $avb_bootargs;" \ |
| 52 | "else " \ |
| 53 | "echo AVB verification failed.;" \ |
| 54 | "exit; fi;" |
Sam Protsenko | 0b47e44 | 2020-01-24 17:53:47 +0200 | [diff] [blame] | 55 | #define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0" |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 56 | #else |
| 57 | #define AVB_VERIFY_CHECK "" |
| 58 | #define AVB_VERIFY_CMD "" |
| 59 | #endif |
| 60 | |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 61 | #define CONTROL_PARTITION "misc" |
| 62 | |
| 63 | #if defined(CONFIG_CMD_AB_SELECT) |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 64 | #define AB_SELECT_SLOT \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 65 | "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ |
| 66 | "then " \ |
| 67 | "echo " CONTROL_PARTITION \ |
| 68 | " partition number:${control_part_number};" \ |
| 69 | "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ |
| 70 | "else " \ |
| 71 | "echo " CONTROL_PARTITION " partition not found;" \ |
| 72 | "exit;" \ |
| 73 | "fi;" \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 74 | "setenv slot_suffix _${slot_name};" |
| 75 | #define AB_SELECT_ARGS \ |
| 76 | "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \ |
| 77 | "echo A/B cmdline addition: ${bootargs_ab};" \ |
| 78 | "setenv bootargs ${bootargs} ${bootargs_ab};" |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 79 | #else |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 80 | #define AB_SELECT_SLOT "" |
| 81 | #define AB_SELECT_ARGS "" |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 82 | #endif |
| 83 | |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 84 | #define FASTBOOT_CMD \ |
| 85 | "echo Booting into fastboot ...; " \ |
| 86 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " |
| 87 | |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 88 | #define DEFAULT_COMMON_BOOT_TI_ARGS \ |
| 89 | "console=" CONSOLEDEV ",115200n8\0" \ |
| 90 | "fdtfile=undefined\0" \ |
| 91 | "bootpart=0:2\0" \ |
| 92 | "bootdir=/boot\0" \ |
| 93 | "bootfile=zImage\0" \ |
| 94 | "usbtty=cdc_acm\0" \ |
| 95 | "vram=16M\0" \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 96 | AVB_VERIFY_CMD \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 97 | "partitions=" PARTS_DEFAULT "\0" \ |
| 98 | "optargs=\0" \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 99 | "dofastboot=0\0" \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 100 | "emmc_linux_boot=" \ |
Sam Protsenko | bfd9f7c | 2017-09-21 22:37:59 +0300 | [diff] [blame] | 101 | "echo Trying to boot Linux from eMMC ...; " \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 102 | "setenv mmcdev 1; " \ |
| 103 | "setenv bootpart 1:2; " \ |
| 104 | "setenv mmcroot /dev/mmcblk0p2 rw; " \ |
| 105 | "run mmcboot;\0" \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 106 | "emmc_android_boot=" \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 107 | "setenv mmcdev 1; " \ |
| 108 | "mmc dev $mmcdev; " \ |
| 109 | "mmc rescan; " \ |
| 110 | AB_SELECT_SLOT \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 111 | "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ |
| 112 | CONTROL_PARTITION "; then " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 113 | "setenv ardaddr -; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 114 | "if bcb test command = bootonce-bootloader; then " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 115 | "echo Android: Bootloader boot...; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 116 | "bcb clear command; bcb store; " \ |
| 117 | FASTBOOT_CMD \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 118 | "exit; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 119 | "elif bcb test command = boot-recovery; then " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 120 | "echo Android: Recovery boot...; " \ |
| 121 | "setenv ardaddr $loadaddr;" \ |
| 122 | "setenv apart recovery; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 123 | "else " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 124 | "echo Android: Normal boot...; " \ |
| 125 | "setenv ardaddr $loadaddr; " \ |
| 126 | "setenv apart boot${slot_suffix}; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 127 | "fi; " \ |
| 128 | "else " \ |
| 129 | "echo Warning: BCB is corrupted or does not exist; " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 130 | "echo Android: Normal boot...; " \ |
| 131 | "fi; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 132 | "setenv eval_bootargs setenv bootargs $bootargs; " \ |
| 133 | "run eval_bootargs; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 134 | "setenv machid fe6; " \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 135 | AVB_VERIFY_CHECK \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 136 | AB_SELECT_ARGS \ |
| 137 | "if part start mmc $mmcdev $apart boot_start; then " \ |
| 138 | "part size mmc $mmcdev $apart boot_size; " \ |
| 139 | "mmc read $loadaddr $boot_start $boot_size; " \ |
| 140 | "abootimg get dtb --index=0 dtb_start dtb_size; " \ |
| 141 | "cp.b $dtb_start $fdtaddr $dtb_size; " \ |
| 142 | "fdt addr $fdtaddr; " \ |
| 143 | "bootm $loadaddr $ardaddr $fdtaddr; " \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 144 | "else " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame^] | 145 | "echo $apart partition not found; " \ |
| 146 | "exit; " \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 147 | "fi;\0" |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 148 | |
| 149 | #ifdef CONFIG_OMAP54XX |
| 150 | |
| 151 | #define DEFAULT_FDT_TI_ARGS \ |
| 152 | "findfdt="\ |
| 153 | "if test $board_name = omap5_uevm; then " \ |
| 154 | "setenv fdtfile omap5-uevm.dtb; fi; " \ |
| 155 | "if test $board_name = dra7xx; then " \ |
| 156 | "setenv fdtfile dra7-evm.dtb; fi;" \ |
| 157 | "if test $board_name = dra72x-revc; then " \ |
| 158 | "setenv fdtfile dra72-evm-revc.dtb; fi;" \ |
| 159 | "if test $board_name = dra72x; then " \ |
| 160 | "setenv fdtfile dra72-evm.dtb; fi;" \ |
| 161 | "if test $board_name = dra71x; then " \ |
| 162 | "setenv fdtfile dra71-evm.dtb; fi;" \ |
Lokesh Vutla | 7b8b6f7 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 163 | "if test $board_name = dra76x_acd; then " \ |
Lokesh Vutla | 066f578 | 2017-08-21 12:50:58 +0530 | [diff] [blame] | 164 | "setenv fdtfile dra76-evm.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 165 | "if test $board_name = beagle_x15; then " \ |
| 166 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 167 | "if test $board_name = beagle_x15_revb1; then " \ |
| 168 | "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ |
Lokesh Vutla | 473d816 | 2017-08-23 11:39:07 +0530 | [diff] [blame] | 169 | "if test $board_name = beagle_x15_revc; then " \ |
| 170 | "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ |
Caleb Robey | 7566e04 | 2020-01-02 08:17:29 -0600 | [diff] [blame] | 171 | "if test $board_name = am5729_beagleboneai; then " \ |
| 172 | "setenv fdtfile am5729-beagleboneai.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 173 | "if test $board_name = am572x_idk; then " \ |
| 174 | "setenv fdtfile am572x-idk.dtb; fi;" \ |
Lokesh Vutla | 7b8b6f7 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 175 | "if test $board_name = am574x_idk; then " \ |
| 176 | "setenv fdtfile am574x-idk.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 177 | "if test $board_name = am57xx_evm; then " \ |
| 178 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 179 | "if test $board_name = am57xx_evm_reva3; then " \ |
| 180 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 181 | "if test $board_name = am571x_idk; then " \ |
| 182 | "setenv fdtfile am571x-idk.dtb; fi;" \ |
| 183 | "if test $fdtfile = undefined; then " \ |
| 184 | "echo WARNING: Could not determine device tree to use; fi; \0" |
| 185 | |
| 186 | #define CONFIG_BOOTCOMMAND \ |
| 187 | "if test ${dofastboot} -eq 1; then " \ |
| 188 | "echo Boot fastboot requested, resetting dofastboot ...;" \ |
| 189 | "setenv dofastboot 0; saveenv;" \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 190 | FASTBOOT_CMD \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 191 | "fi;" \ |
| 192 | "if test ${boot_fit} -eq 1; then " \ |
| 193 | "run update_to_fit;" \ |
| 194 | "fi;" \ |
| 195 | "run findfdt; " \ |
| 196 | "run envboot; " \ |
| 197 | "run mmcboot;" \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 198 | "run emmc_linux_boot; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 199 | "run emmc_android_boot; " \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 200 | "" |
| 201 | |
| 202 | #endif /* CONFIG_OMAP54XX */ |
| 203 | |
| 204 | #endif /* __TI_BOOT_H */ |