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 | |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 16 | #define VBMETA_PART_SIZE (64 * 1024) |
| 17 | |
| 18 | #if defined(CONFIG_LIBAVB) |
| 19 | #define VBMETA_PART \ |
| 20 | "name=vbmeta,size=" __stringify(VBMETA_PART_SIZE) \ |
| 21 | ",uuid=${uuid_gpt_vbmeta};" |
| 22 | #else |
| 23 | #define VBMETA_PART "" |
| 24 | #endif |
| 25 | |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 26 | #if defined(CONFIG_CMD_AB_SELECT) |
| 27 | #define COMMON_PARTS \ |
| 28 | "name=boot_a,size=20M,uuid=${uuid_gpt_boot_a};" \ |
| 29 | "name=boot_b,size=20M,uuid=${uuid_gpt_boot_b};" \ |
| 30 | "name=system_a,size=1024M,uuid=${uuid_gpt_system_a};" \ |
| 31 | "name=system_b,size=1024M,uuid=${uuid_gpt_system_b};" |
| 32 | #else |
| 33 | #define COMMON_PARTS \ |
| 34 | "name=boot,size=20M,uuid=${uuid_gpt_boot};" \ |
| 35 | "name=system,size=1024M,uuid=${uuid_gpt_system};" |
| 36 | #endif |
| 37 | |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 38 | #ifndef PARTS_DEFAULT |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 39 | /* Define the default GPT table for eMMC */ |
| 40 | #define PARTS_DEFAULT \ |
| 41 | /* Linux partitions */ \ |
| 42 | "uuid_disk=${uuid_gpt_disk};" \ |
| 43 | "name=bootloader,start=384K,size=1792K,uuid=${uuid_gpt_bootloader};" \ |
| 44 | "name=rootfs,start=2688K,size=-,uuid=${uuid_gpt_rootfs}\0" \ |
| 45 | /* Android partitions */ \ |
| 46 | "partitions_android=" \ |
| 47 | "uuid_disk=${uuid_gpt_disk};" \ |
| 48 | "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \ |
Sam Protsenko | 78371f3 | 2018-11-15 22:26:17 +0200 | [diff] [blame] | 49 | "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \ |
Sam Protsenko | 22b7130 | 2019-01-04 22:09:08 +0200 | [diff] [blame] | 50 | "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 51 | "name=misc,size=128K,uuid=${uuid_gpt_misc};" \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 52 | "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 53 | COMMON_PARTS \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 54 | "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 55 | VBMETA_PART \ |
Sam Protsenko | 9351605 | 2018-04-19 23:57:30 +0300 | [diff] [blame] | 56 | "name=userdata,size=-,uuid=${uuid_gpt_userdata}" |
| 57 | #endif /* PARTS_DEFAULT */ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 58 | |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 59 | #if defined(CONFIG_CMD_AVB) |
| 60 | #define AVB_VERIFY_CHECK "if run avb_verify; then " \ |
| 61 | "echo AVB verification OK.;" \ |
| 62 | "set bootargs $bootargs $avb_bootargs;" \ |
| 63 | "else " \ |
| 64 | "echo AVB verification failed.;" \ |
| 65 | "exit; fi;" |
| 66 | #define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify;\0" |
| 67 | #else |
| 68 | #define AVB_VERIFY_CHECK "" |
| 69 | #define AVB_VERIFY_CMD "" |
| 70 | #endif |
| 71 | |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 72 | #define CONTROL_PARTITION "misc" |
| 73 | |
| 74 | #if defined(CONFIG_CMD_AB_SELECT) |
| 75 | #define AB_SELECT \ |
| 76 | "if part number mmc 1 " CONTROL_PARTITION " control_part_number; " \ |
| 77 | "then " \ |
| 78 | "echo " CONTROL_PARTITION \ |
| 79 | " partition number:${control_part_number};" \ |
| 80 | "ab_select slot_name mmc ${mmcdev}:${control_part_number};" \ |
| 81 | "else " \ |
| 82 | "echo " CONTROL_PARTITION " partition not found;" \ |
| 83 | "exit;" \ |
| 84 | "fi;" \ |
| 85 | "setenv slot_suffix _${slot_name};" \ |
| 86 | "if part number mmc ${mmcdev} system${slot_suffix} " \ |
| 87 | "system_part_number; then " \ |
| 88 | "setenv bootargs_ab " \ |
| 89 | "ro root=/dev/mmcblk${mmcdev}p${system_part_number} " \ |
| 90 | "rootwait init=/init skip_initramfs " \ |
| 91 | "androidboot.slot_suffix=${slot_suffix};" \ |
| 92 | "echo A/B cmdline addition: ${bootargs_ab};" \ |
| 93 | "setenv bootargs ${bootargs} ${bootargs_ab};" \ |
| 94 | "else " \ |
| 95 | "echo system${slot_suffix} partition not found;" \ |
| 96 | "fi;" |
| 97 | #else |
| 98 | #define AB_SELECT "" |
| 99 | #endif |
| 100 | |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 101 | #define FASTBOOT_CMD \ |
| 102 | "echo Booting into fastboot ...; " \ |
| 103 | "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " |
| 104 | |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 105 | #define DEFAULT_COMMON_BOOT_TI_ARGS \ |
| 106 | "console=" CONSOLEDEV ",115200n8\0" \ |
| 107 | "fdtfile=undefined\0" \ |
| 108 | "bootpart=0:2\0" \ |
| 109 | "bootdir=/boot\0" \ |
| 110 | "bootfile=zImage\0" \ |
| 111 | "usbtty=cdc_acm\0" \ |
| 112 | "vram=16M\0" \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 113 | AVB_VERIFY_CMD \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 114 | "partitions=" PARTS_DEFAULT "\0" \ |
| 115 | "optargs=\0" \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 116 | "dofastboot=0\0" \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 117 | "emmc_linux_boot=" \ |
Sam Protsenko | bfd9f7c | 2017-09-21 22:37:59 +0300 | [diff] [blame] | 118 | "echo Trying to boot Linux from eMMC ...; " \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 119 | "setenv mmcdev 1; " \ |
| 120 | "setenv bootpart 1:2; " \ |
| 121 | "setenv mmcroot /dev/mmcblk0p2 rw; " \ |
| 122 | "run mmcboot;\0" \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 123 | "emmc_android_boot=" \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 124 | "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \ |
| 125 | CONTROL_PARTITION "; then " \ |
| 126 | "if bcb test command = bootonce-bootloader; then " \ |
| 127 | "echo BCB: Bootloader boot...; " \ |
| 128 | "bcb clear command; bcb store; " \ |
| 129 | FASTBOOT_CMD \ |
| 130 | "elif bcb test command = boot-recovery; then " \ |
| 131 | "echo BCB: Recovery boot...; " \ |
| 132 | "echo Warning: recovery is not implemented; " \ |
| 133 | "echo Performing normal boot for now...; " \ |
| 134 | "bcb clear command; bcb store; " \ |
| 135 | "run emmc_android_normal_boot; " \ |
| 136 | "else " \ |
| 137 | "echo BCB: Normal boot requested...; " \ |
| 138 | "run emmc_android_normal_boot; " \ |
| 139 | "fi; " \ |
| 140 | "else " \ |
| 141 | "echo Warning: BCB is corrupted or does not exist; " \ |
| 142 | "echo Performing normal boot...; " \ |
| 143 | "run emmc_android_normal_boot; " \ |
| 144 | "fi;\0" \ |
| 145 | "emmc_android_normal_boot=" \ |
Sam Protsenko | bfd9f7c | 2017-09-21 22:37:59 +0300 | [diff] [blame] | 146 | "echo Trying to boot Android from eMMC ...; " \ |
Praneeth Bajjuri | d89516b | 2018-04-25 16:03:24 -0500 | [diff] [blame] | 147 | "run update_to_fit; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 148 | "setenv eval_bootargs setenv bootargs $bootargs; " \ |
| 149 | "run eval_bootargs; " \ |
| 150 | "setenv mmcdev 1; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 151 | "setenv machid fe6; " \ |
| 152 | "mmc dev $mmcdev; " \ |
| 153 | "mmc rescan; " \ |
Igor Opaniuk | b81b3b6 | 2018-06-03 21:56:41 +0300 | [diff] [blame] | 154 | AVB_VERIFY_CHECK \ |
Ruslan Trofymenko | 0655b26 | 2019-07-05 15:37:36 +0300 | [diff] [blame] | 155 | AB_SELECT \ |
| 156 | "if part start mmc ${mmcdev} boot${slot_suffix} boot_start; " \ |
| 157 | "then " \ |
| 158 | "part size mmc ${mmcdev} boot${slot_suffix} " \ |
| 159 | "boot_size; " \ |
| 160 | "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \ |
| 161 | "bootm ${loadaddr}#${fdtfile}; " \ |
| 162 | "else " \ |
| 163 | "echo boot${slot_suffix} partition not found; " \ |
| 164 | "fi;\0" |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 165 | |
| 166 | #ifdef CONFIG_OMAP54XX |
| 167 | |
| 168 | #define DEFAULT_FDT_TI_ARGS \ |
| 169 | "findfdt="\ |
| 170 | "if test $board_name = omap5_uevm; then " \ |
| 171 | "setenv fdtfile omap5-uevm.dtb; fi; " \ |
| 172 | "if test $board_name = dra7xx; then " \ |
| 173 | "setenv fdtfile dra7-evm.dtb; fi;" \ |
| 174 | "if test $board_name = dra72x-revc; then " \ |
| 175 | "setenv fdtfile dra72-evm-revc.dtb; fi;" \ |
| 176 | "if test $board_name = dra72x; then " \ |
| 177 | "setenv fdtfile dra72-evm.dtb; fi;" \ |
| 178 | "if test $board_name = dra71x; then " \ |
| 179 | "setenv fdtfile dra71-evm.dtb; fi;" \ |
Lokesh Vutla | 7b8b6f7 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 180 | "if test $board_name = dra76x_acd; then " \ |
Lokesh Vutla | 066f578 | 2017-08-21 12:50:58 +0530 | [diff] [blame] | 181 | "setenv fdtfile dra76-evm.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 182 | "if test $board_name = beagle_x15; then " \ |
| 183 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 184 | "if test $board_name = beagle_x15_revb1; then " \ |
| 185 | "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \ |
Lokesh Vutla | 473d816 | 2017-08-23 11:39:07 +0530 | [diff] [blame] | 186 | "if test $board_name = beagle_x15_revc; then " \ |
| 187 | "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 188 | "if test $board_name = am572x_idk; then " \ |
| 189 | "setenv fdtfile am572x-idk.dtb; fi;" \ |
Lokesh Vutla | 7b8b6f7 | 2017-12-29 11:47:58 +0530 | [diff] [blame] | 190 | "if test $board_name = am574x_idk; then " \ |
| 191 | "setenv fdtfile am574x-idk.dtb; fi;" \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 192 | "if test $board_name = am57xx_evm; then " \ |
| 193 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 194 | "if test $board_name = am57xx_evm_reva3; then " \ |
| 195 | "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \ |
| 196 | "if test $board_name = am571x_idk; then " \ |
| 197 | "setenv fdtfile am571x-idk.dtb; fi;" \ |
| 198 | "if test $fdtfile = undefined; then " \ |
| 199 | "echo WARNING: Could not determine device tree to use; fi; \0" |
| 200 | |
| 201 | #define CONFIG_BOOTCOMMAND \ |
| 202 | "if test ${dofastboot} -eq 1; then " \ |
| 203 | "echo Boot fastboot requested, resetting dofastboot ...;" \ |
| 204 | "setenv dofastboot 0; saveenv;" \ |
Sam Protsenko | b35bcb0 | 2019-07-25 16:20:41 +0300 | [diff] [blame] | 205 | FASTBOOT_CMD \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 206 | "fi;" \ |
| 207 | "if test ${boot_fit} -eq 1; then " \ |
| 208 | "run update_to_fit;" \ |
| 209 | "fi;" \ |
| 210 | "run findfdt; " \ |
| 211 | "run envboot; " \ |
| 212 | "run mmcboot;" \ |
Sam Protsenko | 7e43edc | 2017-09-21 22:37:58 +0300 | [diff] [blame] | 213 | "run emmc_linux_boot; " \ |
Semen Protsenko | 9300317 | 2017-08-16 15:55:48 +0300 | [diff] [blame] | 214 | "run emmc_android_boot; " \ |
Semen Protsenko | 334f5bb | 2017-06-14 21:34:23 +0300 | [diff] [blame] | 215 | "" |
| 216 | |
| 217 | #endif /* CONFIG_OMAP54XX */ |
| 218 | |
| 219 | #endif /* __TI_BOOT_H */ |