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 | |
Simon Glass | fb64e36 | 2020-05-10 11:40:09 -0600 | [diff] [blame] | 12 | #include <linux/stringify.h> |
| 13 | |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 14 | #ifndef CONSOLEDEV |
Sam Protsenko | 02c005f | 2019-07-12 20:38:12 +0300 | [diff] [blame] | 15 | #define CONSOLEDEV "ttyS2" |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 16 | #endif |
| 17 | |
| 18 | #ifndef PARTS_DEFAULT |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 19 | /* |
| 20 | * Default GPT tables for eMMC (Linux and Android). Notes: |
| 21 | * 1. Keep partitions aligned to erase group size (512 KiB) when possible |
| 22 | * 2. Keep partitions in sync with DFU_ALT_INFO_EMMC (see dfu.h) |
| 23 | * 3. Keep 'bootloader' partition (U-Boot proper) start address in sync with |
| 24 | * CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR (see common/spl/Kconfig) |
| 25 | */ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 26 | #define PARTS_DEFAULT \ |
| 27 | /* Linux partitions */ \ |
| 28 | "uuid_disk=${uuid_gpt_disk};" \ |
| 29 | "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \ |
| 30 | "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \ |
| 31 | /* Android partitions */ \ |
| 32 | "partitions_android=" \ |
| 33 | "uuid_disk=${uuid_gpt_disk};" \ |
| 34 | "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \ |
Sam Protsenko | 78371f3 | 2018-11-15 22:26:17 +0200 | [diff] [blame] | 35 | "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ |
Sam Protsenko | 22b7130 | 2019-01-04 22:09:08 +0200 | [diff] [blame] | 36 | "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 37 | "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 38 | "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ |
| 39 | "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ |
| 40 | "name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};" \ |
| 41 | "name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};" \ |
| 42 | "name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};" \ |
| 43 | "name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};" \ |
| 44 | "name=recovery,size=64M,uuid=${uuid_gpt_recovery};" \ |
| 45 | "name=super,size=2560M,uuid=${uuid_gpt_super};" \ |
| 46 | "name=metadata,size=16M,uuid=${uuid_gpt_metadata};" \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 47 | "name=userdata,size=-,uuid=${uuid_gpt_userdata}" |
| 48 | #endif /* PARTS_DEFAULT */ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 49 | |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 50 | #if defined(CONFIG_CMD_AVB) |
| 51 | #define AVB_VERIFY_CHECK "if run avb_verify; then " \ |
| 52 | "echo AVB verification OK.;" \ |
| 53 | "set bootargs $bootargs $avb_bootargs;" \ |
| 54 | "else " \ |
| 55 | "echo AVB verification failed.;" \ |
| 56 | "exit; fi;" |
Sam Protsenko | 0b47e44 | 2020-01-24 17:53:47 +0200 | [diff] [blame] | 57 | #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] | 58 | #else |
| 59 | #define AVB_VERIFY_CHECK "" |
| 60 | #define AVB_VERIFY_CMD "" |
| 61 | #endif |
| 62 | |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 63 | #define CONTROL_PARTITION "misc" |
| 64 | |
| 65 | #if defined(CONFIG_CMD_AB_SELECT) |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 66 | #define AB_SELECT_SLOT \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 67 | "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ |
| 68 | "then " \ |
| 69 | "echo " CONTROL_PARTITION \ |
| 70 | " partition number:${control_part_number};" \ |
| 71 | "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ |
| 72 | "else " \ |
| 73 | "echo " CONTROL_PARTITION " partition not found;" \ |
| 74 | "exit;" \ |
| 75 | "fi;" \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 76 | "setenv slot_suffix _${slot_name};" |
| 77 | #define AB_SELECT_ARGS \ |
| 78 | "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \ |
| 79 | "echo A/B cmdline addition: ${bootargs_ab};" \ |
| 80 | "setenv bootargs ${bootargs} ${bootargs_ab};" |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 81 | #else |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 82 | #define AB_SELECT_SLOT "" |
| 83 | #define AB_SELECT_ARGS "" |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 84 | #endif |
| 85 | |
Sam Protsenko | 1651ee1 | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 86 | /* |
| 87 | * Prepares complete device tree blob for current board (for Android boot). |
| 88 | * |
| 89 | * Boot image or recovery image should be loaded into $loadaddr prior to running |
| 90 | * these commands. The logic of these commnads is next: |
| 91 | * |
| 92 | * 1. Read correct DTB for current SoC/board from boot image in $loadaddr |
| 93 | * to $fdtaddr |
| 94 | * 2. Merge all needed DTBO for current board from 'dtbo' partition into read |
| 95 | * DTB |
| 96 | * 3. User should provide $fdtaddr as 3rd argument to 'bootm' |
| 97 | */ |
| 98 | #define PREPARE_FDT \ |
| 99 | "echo Preparing FDT...; " \ |
| 100 | "if test $board_name = am57xx_evm_reva3; then " \ |
| 101 | "echo \" Reading DTBO partition...\"; " \ |
| 102 | "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \ |
| 103 | "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \ |
| 104 | "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \ |
| 105 | "echo \" Reading DTB for AM57x EVM RevA3...\"; " \ |
| 106 | "abootimg get dtb --index=0 dtb_start dtb_size; " \ |
| 107 | "cp.b $dtb_start $fdtaddr $dtb_size; " \ |
Sam Protsenko | fe129ac | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 108 | "fdt addr $fdtaddr 0x80000; " \ |
Sam Protsenko | 1651ee1 | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 109 | "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \ |
| 110 | "adtimg addr $dtboaddr; " \ |
Sam Protsenko | fe129ac | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 111 | "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \ |
Sam Protsenko | 1651ee1 | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 112 | "fdt apply $dtbo0_addr; " \ |
Sam Protsenko | fe129ac | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 113 | "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \ |
Sam Protsenko | 1651ee1 | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 114 | "fdt apply $dtbo1_addr; " \ |
| 115 | "elif test $board_name = beagle_x15_revc; then " \ |
| 116 | "echo \" Reading DTB for Beagle X15 RevC...\"; " \ |
| 117 | "abootimg get dtb --index=0 dtb_start dtb_size; " \ |
| 118 | "cp.b $dtb_start $fdtaddr $dtb_size; " \ |
Sam Protsenko | fe129ac | 2020-02-21 16:35:21 +0200 | [diff] [blame] | 119 | "fdt addr $fdtaddr 0x80000; " \ |
Sam Protsenko | 1651ee1 | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 120 | "else " \ |
| 121 | "echo Error: Android boot is not supported for $board_name; " \ |
| 122 | "exit; " \ |
| 123 | "fi; " \ |
| 124 | |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 125 | #define FASTBOOT_CMD \ |
| 126 | "echo Booting into fastboot ...; " \ |
| 127 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " |
| 128 | |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 129 | #define DEFAULT_COMMON_BOOT_TI_ARGS \ |
| 130 | "console=" CONSOLEDEV ",115200n8\0" \ |
| 131 | "fdtfile=undefined\0" \ |
| 132 | "bootpart=0:2\0" \ |
| 133 | "bootdir=/boot\0" \ |
| 134 | "bootfile=zImage\0" \ |
| 135 | "usbtty=cdc_acm\0" \ |
| 136 | "vram=16M\0" \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 137 | AVB_VERIFY_CMD \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 138 | "partitions=" PARTS_DEFAULT "\0" \ |
| 139 | "optargs=\0" \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 140 | "dofastboot=0\0" \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 141 | "emmc_linux_boot=" \ |
Sam Protsenko | bfd9f7c | 2017-09-21 22:37:59 +0300 | [diff] [blame] | 142 | "echo Trying to boot Linux from eMMC ...; " \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 143 | "setenv mmcdev 1; " \ |
| 144 | "setenv bootpart 1:2; " \ |
| 145 | "setenv mmcroot /dev/mmcblk0p2 rw; " \ |
| 146 | "run mmcboot;\0" \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 147 | "emmc_android_boot=" \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 148 | "setenv mmcdev 1; " \ |
| 149 | "mmc dev $mmcdev; " \ |
| 150 | "mmc rescan; " \ |
| 151 | AB_SELECT_SLOT \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 152 | "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ |
| 153 | CONTROL_PARTITION "; then " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 154 | "setenv ardaddr -; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 155 | "if bcb test command = bootonce-bootloader; then " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 156 | "echo Android: Bootloader boot...; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 157 | "bcb clear command; bcb store; " \ |
| 158 | FASTBOOT_CMD \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 159 | "exit; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 160 | "elif bcb test command = boot-recovery; then " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 161 | "echo Android: Recovery boot...; " \ |
| 162 | "setenv ardaddr $loadaddr;" \ |
| 163 | "setenv apart recovery; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 164 | "else " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 165 | "echo Android: Normal boot...; " \ |
| 166 | "setenv ardaddr $loadaddr; " \ |
| 167 | "setenv apart boot${slot_suffix}; " \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 168 | "fi; " \ |
| 169 | "else " \ |
| 170 | "echo Warning: BCB is corrupted or does not exist; " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 171 | "echo Android: Normal boot...; " \ |
| 172 | "fi; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 173 | "setenv eval_bootargs setenv bootargs $bootargs; " \ |
| 174 | "run eval_bootargs; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 175 | "setenv machid fe6; " \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 176 | AVB_VERIFY_CHECK \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 177 | AB_SELECT_ARGS \ |
| 178 | "if part start mmc $mmcdev $apart boot_start; then " \ |
| 179 | "part size mmc $mmcdev $apart boot_size; " \ |
| 180 | "mmc read $loadaddr $boot_start $boot_size; " \ |
Sam Protsenko | 1651ee1 | 2020-01-24 17:53:49 +0200 | [diff] [blame] | 181 | PREPARE_FDT \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 182 | "bootm $loadaddr $ardaddr $fdtaddr; " \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 183 | "else " \ |
Sam Protsenko | 04cdcee | 2020-01-24 17:53:48 +0200 | [diff] [blame] | 184 | "echo $apart partition not found; " \ |
| 185 | "exit; " \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 186 | "fi;\0" |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 187 | |
| 188 | #ifdef CONFIG_OMAP54XX |
| 189 | |
| 190 | #define DEFAULT_FDT_TI_ARGS \ |
| 191 | "findfdt="\ |
| 192 | "if test $board_name = omap5_uevm; then " \ |
| 193 | "setenv fdtfile omap5-uevm.dtb; fi; " \ |
| 194 | "if test $board_name = dra7xx; then " \ |
| 195 | "setenv fdtfile dra7-evm.dtb; fi;" \ |
| 196 | "if test $board_name = dra72x-revc; then " \ |
| 197 | "setenv fdtfile dra72-evm-revc.dtb; fi;" \ |
| 198 | "if test $board_name = dra72x; then " \ |
| 199 | "setenv fdtfile dra72-evm.dtb; fi;" \ |
| 200 | "if test $board_name = dra71x; then " \ |
| 201 | "setenv fdtfile dra71-evm.dtb; fi;" \ |
Lokesh Vutla | 7b8b6f7 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 202 | "if test $board_name = dra76x_acd; then " \ |
Lokesh Vutla | 066f578 | 2017-08-21 12:50:58 +0530 | [diff] [blame] | 203 | "setenv fdtfile dra76-evm.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 204 | "if test $board_name = beagle_x15; then " \ |
| 205 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 206 | "if test $board_name = beagle_x15_revb1; then " \ |
| 207 | "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ |
Lokesh Vutla | 473d816 | 2017-08-23 11:39:07 +0530 | [diff] [blame] | 208 | "if test $board_name = beagle_x15_revc; then " \ |
| 209 | "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ |
Caleb Robey | 7566e04 | 2020-01-02 08:17:29 -0600 | [diff] [blame] | 210 | "if test $board_name = am5729_beagleboneai; then " \ |
| 211 | "setenv fdtfile am5729-beagleboneai.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 212 | "if test $board_name = am572x_idk; then " \ |
| 213 | "setenv fdtfile am572x-idk.dtb; fi;" \ |
Lokesh Vutla | 7b8b6f7 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 214 | "if test $board_name = am574x_idk; then " \ |
| 215 | "setenv fdtfile am574x-idk.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 216 | "if test $board_name = am57xx_evm; then " \ |
| 217 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 218 | "if test $board_name = am57xx_evm_reva3; then " \ |
| 219 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 220 | "if test $board_name = am571x_idk; then " \ |
| 221 | "setenv fdtfile am571x-idk.dtb; fi;" \ |
| 222 | "if test $fdtfile = undefined; then " \ |
| 223 | "echo WARNING: Could not determine device tree to use; fi; \0" |
| 224 | |
| 225 | #define CONFIG_BOOTCOMMAND \ |
| 226 | "if test ${dofastboot} -eq 1; then " \ |
| 227 | "echo Boot fastboot requested, resetting dofastboot ...;" \ |
| 228 | "setenv dofastboot 0; saveenv;" \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 229 | FASTBOOT_CMD \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 230 | "fi;" \ |
| 231 | "if test ${boot_fit} -eq 1; then " \ |
| 232 | "run update_to_fit;" \ |
| 233 | "fi;" \ |
| 234 | "run findfdt; " \ |
| 235 | "run envboot; " \ |
| 236 | "run mmcboot;" \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 237 | "run emmc_linux_boot; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 238 | "run emmc_android_boot; " \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 239 | "" |
| 240 | |
| 241 | #endif /* CONFIG_OMAP54XX */ |
| 242 | |
| 243 | #endif /* __TI_BOOT_H */ |