Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Semen Protsenko | 4fd79ac | 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 | 4fd79ac | 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 | adc097e | 2019-07-12 20:38:12 +0300 | [diff] [blame] | 13 | #define CONSOLEDEV "ttyS2" |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 14 | #endif |
| 15 | |
| 16 | #ifndef PARTS_DEFAULT |
Sam Protsenko | d94e6db | 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 | c90a760 | 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 | 1e4fb78 | 2018-11-15 22:26:17 +0200 | [diff] [blame] | 33 | "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ |
Sam Protsenko | 35e3d2e | 2019-01-04 22:09:08 +0200 | [diff] [blame] | 34 | "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ |
Sam Protsenko | c90a760 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 35 | "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ |
Sam Protsenko | d94e6db | 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 | c90a760 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 45 | "name=userdata,size=-,uuid=${uuid_gpt_userdata}" |
| 46 | #endif /* PARTS_DEFAULT */ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 47 | |
Igor Opaniuk | e883ffe | 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 | 0f5103d | 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 | e883ffe | 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 | edd3108 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 61 | #define CONTROL_PARTITION "misc" |
| 62 | |
| 63 | #if defined(CONFIG_CMD_AB_SELECT) |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 64 | #define AB_SELECT_SLOT \ |
Ruslan Trofymenko | edd3108 | 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 | d94e6db | 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 | edd3108 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 79 | #else |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 80 | #define AB_SELECT_SLOT "" |
| 81 | #define AB_SELECT_ARGS "" |
Ruslan Trofymenko | edd3108 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 82 | #endif |
| 83 | |
Sam Protsenko | add1a6b | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 84 | /* |
| 85 | * Prepares complete device tree blob for current board (for Android boot). |
| 86 | * |
| 87 | * Boot image or recovery image should be loaded into $loadaddr prior to running |
| 88 | * these commands. The logic of these commnads is next: |
| 89 | * |
| 90 | * 1. Read correct DTB for current SoC/board from boot image in $loadaddr |
| 91 | * to $fdtaddr |
| 92 | * 2. Merge all needed DTBO for current board from 'dtbo' partition into read |
| 93 | * DTB |
| 94 | * 3. User should provide $fdtaddr as 3rd argument to 'bootm' |
| 95 | */ |
| 96 | #define PREPARE_FDT \ |
| 97 | "echo Preparing FDT...; " \ |
| 98 | "if test $board_name = am57xx_evm_reva3; then " \ |
| 99 | "echo \" Reading DTBO partition...\"; " \ |
| 100 | "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \ |
| 101 | "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \ |
| 102 | "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \ |
| 103 | "echo \" Reading DTB for AM57x EVM RevA3...\"; " \ |
| 104 | "abootimg get dtb --index=0 dtb_start dtb_size; " \ |
| 105 | "cp.b $dtb_start $fdtaddr $dtb_size; " \ |
Sam Protsenko | 41ee72f | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 106 | "fdt addr $fdtaddr 0x80000; " \ |
Sam Protsenko | add1a6b | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 107 | "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \ |
| 108 | "adtimg addr $dtboaddr; " \ |
Sam Protsenko | 41ee72f | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 109 | "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \ |
Sam Protsenko | add1a6b | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 110 | "fdt apply $dtbo0_addr; " \ |
Sam Protsenko | 41ee72f | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 111 | "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \ |
Sam Protsenko | add1a6b | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 112 | "fdt apply $dtbo1_addr; " \ |
| 113 | "elif test $board_name = beagle_x15_revc; then " \ |
| 114 | "echo \" Reading DTB for Beagle X15 RevC...\"; " \ |
| 115 | "abootimg get dtb --index=0 dtb_start dtb_size; " \ |
| 116 | "cp.b $dtb_start $fdtaddr $dtb_size; " \ |
Sam Protsenko | 41ee72f | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 117 | "fdt addr $fdtaddr 0x80000; " \ |
Sam Protsenko | add1a6b | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 118 | "else " \ |
| 119 | "echo Error: Android boot is not supported for $board_name; " \ |
| 120 | "exit; " \ |
| 121 | "fi; " \ |
| 122 | |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 123 | #define FASTBOOT_CMD \ |
| 124 | "echo Booting into fastboot ...; " \ |
| 125 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " |
| 126 | |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 127 | #define DEFAULT_COMMON_BOOT_TI_ARGS \ |
| 128 | "console=" CONSOLEDEV ",115200n8\0" \ |
| 129 | "fdtfile=undefined\0" \ |
| 130 | "bootpart=0:2\0" \ |
| 131 | "bootdir=/boot\0" \ |
| 132 | "bootfile=zImage\0" \ |
| 133 | "usbtty=cdc_acm\0" \ |
| 134 | "vram=16M\0" \ |
Igor Opaniuk | e883ffe | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 135 | AVB_VERIFY_CMD \ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 136 | "partitions=" PARTS_DEFAULT "\0" \ |
| 137 | "optargs=\0" \ |
Semen Protsenko | a17c8b1 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 138 | "dofastboot=0\0" \ |
Sam Protsenko | 2717c08 | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 139 | "emmc_linux_boot=" \ |
Sam Protsenko | 6ca43a5 | 2017-09-21 22:37:59 +0300 | [diff] [blame] | 140 | "echo Trying to boot Linux from eMMC ...; " \ |
Sam Protsenko | 2717c08 | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 141 | "setenv mmcdev 1; " \ |
| 142 | "setenv bootpart 1:2; " \ |
| 143 | "setenv mmcroot /dev/mmcblk0p2 rw; " \ |
| 144 | "run mmcboot;\0" \ |
Semen Protsenko | a17c8b1 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 145 | "emmc_android_boot=" \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 146 | "setenv mmcdev 1; " \ |
| 147 | "mmc dev $mmcdev; " \ |
| 148 | "mmc rescan; " \ |
| 149 | AB_SELECT_SLOT \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 150 | "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ |
| 151 | CONTROL_PARTITION "; then " \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 152 | "setenv ardaddr -; " \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 153 | "if bcb test command = bootonce-bootloader; then " \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 154 | "echo Android: Bootloader boot...; " \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 155 | "bcb clear command; bcb store; " \ |
| 156 | FASTBOOT_CMD \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 157 | "exit; " \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 158 | "elif bcb test command = boot-recovery; then " \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 159 | "echo Android: Recovery boot...; " \ |
| 160 | "setenv ardaddr $loadaddr;" \ |
| 161 | "setenv apart recovery; " \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 162 | "else " \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 163 | "echo Android: Normal boot...; " \ |
| 164 | "setenv ardaddr $loadaddr; " \ |
| 165 | "setenv apart boot${slot_suffix}; " \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 166 | "fi; " \ |
| 167 | "else " \ |
| 168 | "echo Warning: BCB is corrupted or does not exist; " \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 169 | "echo Android: Normal boot...; " \ |
| 170 | "fi; " \ |
Semen Protsenko | a17c8b1 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 171 | "setenv eval_bootargs setenv bootargs $bootargs; " \ |
| 172 | "run eval_bootargs; " \ |
Semen Protsenko | a17c8b1 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 173 | "setenv machid fe6; " \ |
Igor Opaniuk | e883ffe | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 174 | AVB_VERIFY_CHECK \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 175 | AB_SELECT_ARGS \ |
| 176 | "if part start mmc $mmcdev $apart boot_start; then " \ |
| 177 | "part size mmc $mmcdev $apart boot_size; " \ |
| 178 | "mmc read $loadaddr $boot_start $boot_size; " \ |
Sam Protsenko | add1a6b | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 179 | PREPARE_FDT \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 180 | "bootm $loadaddr $ardaddr $fdtaddr; " \ |
Ruslan Trofymenko | edd3108 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 181 | "else " \ |
Sam Protsenko | d94e6db | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 182 | "echo $apart partition not found; " \ |
| 183 | "exit; " \ |
Ruslan Trofymenko | edd3108 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 184 | "fi;\0" |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 185 | |
| 186 | #ifdef CONFIG_OMAP54XX |
| 187 | |
| 188 | #define DEFAULT_FDT_TI_ARGS \ |
| 189 | "findfdt="\ |
| 190 | "if test $board_name = omap5_uevm; then " \ |
| 191 | "setenv fdtfile omap5-uevm.dtb; fi; " \ |
| 192 | "if test $board_name = dra7xx; then " \ |
| 193 | "setenv fdtfile dra7-evm.dtb; fi;" \ |
| 194 | "if test $board_name = dra72x-revc; then " \ |
| 195 | "setenv fdtfile dra72-evm-revc.dtb; fi;" \ |
| 196 | "if test $board_name = dra72x; then " \ |
| 197 | "setenv fdtfile dra72-evm.dtb; fi;" \ |
| 198 | "if test $board_name = dra71x; then " \ |
| 199 | "setenv fdtfile dra71-evm.dtb; fi;" \ |
Lokesh Vutla | 3741c04 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 200 | "if test $board_name = dra76x_acd; then " \ |
Lokesh Vutla | 911d76c | 2017-08-21 12:50:58 +0530 | [diff] [blame] | 201 | "setenv fdtfile dra76-evm.dtb; fi;" \ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 202 | "if test $board_name = beagle_x15; then " \ |
| 203 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 204 | "if test $board_name = beagle_x15_revb1; then " \ |
| 205 | "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ |
Lokesh Vutla | 0831831 | 2017-08-23 11:39:07 +0530 | [diff] [blame] | 206 | "if test $board_name = beagle_x15_revc; then " \ |
| 207 | "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ |
Caleb Robey | 019d123 | 2020-01-02 08:17:29 -0600 | [diff] [blame] | 208 | "if test $board_name = am5729_beagleboneai; then " \ |
| 209 | "setenv fdtfile am5729-beagleboneai.dtb; fi;" \ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 210 | "if test $board_name = am572x_idk; then " \ |
| 211 | "setenv fdtfile am572x-idk.dtb; fi;" \ |
Lokesh Vutla | 3741c04 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 212 | "if test $board_name = am574x_idk; then " \ |
| 213 | "setenv fdtfile am574x-idk.dtb; fi;" \ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 214 | "if test $board_name = am57xx_evm; then " \ |
| 215 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 216 | "if test $board_name = am57xx_evm_reva3; then " \ |
| 217 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 218 | "if test $board_name = am571x_idk; then " \ |
| 219 | "setenv fdtfile am571x-idk.dtb; fi;" \ |
| 220 | "if test $fdtfile = undefined; then " \ |
| 221 | "echo WARNING: Could not determine device tree to use; fi; \0" |
| 222 | |
| 223 | #define CONFIG_BOOTCOMMAND \ |
| 224 | "if test ${dofastboot} -eq 1; then " \ |
| 225 | "echo Boot fastboot requested, resetting dofastboot ...;" \ |
| 226 | "setenv dofastboot 0; saveenv;" \ |
Sam Protsenko | 3db0989 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 227 | FASTBOOT_CMD \ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 228 | "fi;" \ |
| 229 | "if test ${boot_fit} -eq 1; then " \ |
| 230 | "run update_to_fit;" \ |
| 231 | "fi;" \ |
| 232 | "run findfdt; " \ |
| 233 | "run envboot; " \ |
| 234 | "run mmcboot;" \ |
Sam Protsenko | 2717c08 | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 235 | "run emmc_linux_boot; " \ |
Semen Protsenko | a17c8b1 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 236 | "run emmc_android_boot; " \ |
Semen Protsenko | 4fd79ac | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 237 | "" |
| 238 | |
| 239 | #endif /* CONFIG_OMAP54XX */ |
| 240 | |
| 241 | #endif /* __TI_BOOT_H */ |