blob: 5a0fc1dc5d15f9e1515e3027e69072500f495937 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Semen Protsenko334f5bb2017-06-14 21:34:23 +03002/*
3 * Boot related environment variable definitions on TI boards.
4 *
5 * (C) Copyright 2017 Linaro Ltd.
6 * Sam Protsenko <semen.protsenko@linaro.org>
Semen Protsenko334f5bb2017-06-14 21:34:23 +03007 */
8
9#ifndef __TI_BOOT_H
10#define __TI_BOOT_H
11
12#ifndef CONSOLEDEV
Sam Protsenko02c005f2019-07-12 20:38:12 +030013#define CONSOLEDEV "ttyS2"
Semen Protsenko334f5bb2017-06-14 21:34:23 +030014#endif
15
16#ifndef PARTS_DEFAULT
Sam Protsenko04cdcee2020-01-24 17:53:48 +020017/*
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 Protsenko93516052018-04-19 23:57:30 +030024#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 Protsenko78371f32018-11-15 22:26:17 +020033 "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
Sam Protsenko22b71302019-01-04 22:09:08 +020034 "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
Sam Protsenko93516052018-04-19 23:57:30 +030035 "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
Sam Protsenko04cdcee2020-01-24 17:53:48 +020036 "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 Protsenko93516052018-04-19 23:57:30 +030045 "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
46#endif /* PARTS_DEFAULT */
Semen Protsenko334f5bb2017-06-14 21:34:23 +030047
Igor Opaniukb81b3b62018-06-03 21:56:41 +030048#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 Protsenko0b47e442020-01-24 17:53:47 +020055#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0"
Igor Opaniukb81b3b62018-06-03 21:56:41 +030056#else
57#define AVB_VERIFY_CHECK ""
58#define AVB_VERIFY_CMD ""
59#endif
60
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030061#define CONTROL_PARTITION "misc"
62
63#if defined(CONFIG_CMD_AB_SELECT)
Sam Protsenko04cdcee2020-01-24 17:53:48 +020064#define AB_SELECT_SLOT \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030065 "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 Protsenko04cdcee2020-01-24 17:53:48 +020074 "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 Trofymenko0655b262019-07-05 15:37:36 +030079#else
Sam Protsenko04cdcee2020-01-24 17:53:48 +020080#define AB_SELECT_SLOT ""
81#define AB_SELECT_ARGS ""
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030082#endif
83
Sam Protsenkob35bcb02019-07-25 16:20:41 +030084#define FASTBOOT_CMD \
85 "echo Booting into fastboot ...; " \
86 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; "
87
Semen Protsenko334f5bb2017-06-14 21:34:23 +030088#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 Opaniukb81b3b62018-06-03 21:56:41 +030096 AVB_VERIFY_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +030097 "partitions=" PARTS_DEFAULT "\0" \
98 "optargs=\0" \
Semen Protsenko93003172017-08-16 15:55:48 +030099 "dofastboot=0\0" \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300100 "emmc_linux_boot=" \
Sam Protsenkobfd9f7c2017-09-21 22:37:59 +0300101 "echo Trying to boot Linux from eMMC ...; " \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300102 "setenv mmcdev 1; " \
103 "setenv bootpart 1:2; " \
104 "setenv mmcroot /dev/mmcblk0p2 rw; " \
105 "run mmcboot;\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300106 "emmc_android_boot=" \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200107 "setenv mmcdev 1; " \
108 "mmc dev $mmcdev; " \
109 "mmc rescan; " \
110 AB_SELECT_SLOT \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300111 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
112 CONTROL_PARTITION "; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200113 "setenv ardaddr -; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300114 "if bcb test command = bootonce-bootloader; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200115 "echo Android: Bootloader boot...; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300116 "bcb clear command; bcb store; " \
117 FASTBOOT_CMD \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200118 "exit; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300119 "elif bcb test command = boot-recovery; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200120 "echo Android: Recovery boot...; " \
121 "setenv ardaddr $loadaddr;" \
122 "setenv apart recovery; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300123 "else " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200124 "echo Android: Normal boot...; " \
125 "setenv ardaddr $loadaddr; " \
126 "setenv apart boot${slot_suffix}; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300127 "fi; " \
128 "else " \
129 "echo Warning: BCB is corrupted or does not exist; " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200130 "echo Android: Normal boot...; " \
131 "fi; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300132 "setenv eval_bootargs setenv bootargs $bootargs; " \
133 "run eval_bootargs; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300134 "setenv machid fe6; " \
Igor Opaniukb81b3b62018-06-03 21:56:41 +0300135 AVB_VERIFY_CHECK \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200136 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 Trofymenko0655b262019-07-05 15:37:36 +0300144 "else " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200145 "echo $apart partition not found; " \
146 "exit; " \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +0300147 "fi;\0"
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300148
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 Vutla7b8b6f72017-12-29 11:47:58 +0530163 "if test $board_name = dra76x_acd; then " \
Lokesh Vutla066f5782017-08-21 12:50:58 +0530164 "setenv fdtfile dra76-evm.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300165 "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 Vutla473d8162017-08-23 11:39:07 +0530169 "if test $board_name = beagle_x15_revc; then " \
170 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
Caleb Robey7566e042020-01-02 08:17:29 -0600171 "if test $board_name = am5729_beagleboneai; then " \
172 "setenv fdtfile am5729-beagleboneai.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300173 "if test $board_name = am572x_idk; then " \
174 "setenv fdtfile am572x-idk.dtb; fi;" \
Lokesh Vutla7b8b6f72017-12-29 11:47:58 +0530175 "if test $board_name = am574x_idk; then " \
176 "setenv fdtfile am574x-idk.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300177 "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 Protsenkob35bcb02019-07-25 16:20:41 +0300190 FASTBOOT_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300191 "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 Protsenko7e43edc2017-09-21 22:37:58 +0300198 "run emmc_linux_boot; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300199 "run emmc_android_boot; " \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300200 ""
201
202#endif /* CONFIG_OMAP54XX */
203
204#endif /* __TI_BOOT_H */