blob: 523c8fc4fe9a80ce1fd87909e6697893ce2930d9 [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 Protsenko1651ee12020-01-24 17:53:49 +020084/*
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; " \
106 "fdt addr $fdtaddr; " \
107 "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \
108 "adtimg addr $dtboaddr; " \
109 "adtimg get dt --index=0 dtbo0_addr; " \
110 "fdt apply $dtbo0_addr; " \
111 "adtimg get dt --index=1 dtbo1_addr; " \
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; " \
117 "fdt addr $fdtaddr; " \
118 "else " \
119 "echo Error: Android boot is not supported for $board_name; " \
120 "exit; " \
121 "fi; " \
122
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300123#define FASTBOOT_CMD \
124 "echo Booting into fastboot ...; " \
125 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; "
126
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300127#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 Opaniukb81b3b62018-06-03 21:56:41 +0300135 AVB_VERIFY_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300136 "partitions=" PARTS_DEFAULT "\0" \
137 "optargs=\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300138 "dofastboot=0\0" \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300139 "emmc_linux_boot=" \
Sam Protsenkobfd9f7c2017-09-21 22:37:59 +0300140 "echo Trying to boot Linux from eMMC ...; " \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300141 "setenv mmcdev 1; " \
142 "setenv bootpart 1:2; " \
143 "setenv mmcroot /dev/mmcblk0p2 rw; " \
144 "run mmcboot;\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300145 "emmc_android_boot=" \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200146 "setenv mmcdev 1; " \
147 "mmc dev $mmcdev; " \
148 "mmc rescan; " \
149 AB_SELECT_SLOT \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300150 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
151 CONTROL_PARTITION "; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200152 "setenv ardaddr -; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300153 "if bcb test command = bootonce-bootloader; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200154 "echo Android: Bootloader boot...; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300155 "bcb clear command; bcb store; " \
156 FASTBOOT_CMD \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200157 "exit; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300158 "elif bcb test command = boot-recovery; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200159 "echo Android: Recovery boot...; " \
160 "setenv ardaddr $loadaddr;" \
161 "setenv apart recovery; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300162 "else " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200163 "echo Android: Normal boot...; " \
164 "setenv ardaddr $loadaddr; " \
165 "setenv apart boot${slot_suffix}; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300166 "fi; " \
167 "else " \
168 "echo Warning: BCB is corrupted or does not exist; " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200169 "echo Android: Normal boot...; " \
170 "fi; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300171 "setenv eval_bootargs setenv bootargs $bootargs; " \
172 "run eval_bootargs; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300173 "setenv machid fe6; " \
Igor Opaniukb81b3b62018-06-03 21:56:41 +0300174 AVB_VERIFY_CHECK \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200175 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 Protsenko1651ee12020-01-24 17:53:49 +0200179 PREPARE_FDT \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200180 "bootm $loadaddr $ardaddr $fdtaddr; " \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +0300181 "else " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200182 "echo $apart partition not found; " \
183 "exit; " \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +0300184 "fi;\0"
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300185
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 Vutla7b8b6f72017-12-29 11:47:58 +0530200 "if test $board_name = dra76x_acd; then " \
Lokesh Vutla066f5782017-08-21 12:50:58 +0530201 "setenv fdtfile dra76-evm.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300202 "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 Vutla473d8162017-08-23 11:39:07 +0530206 "if test $board_name = beagle_x15_revc; then " \
207 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
Caleb Robey7566e042020-01-02 08:17:29 -0600208 "if test $board_name = am5729_beagleboneai; then " \
209 "setenv fdtfile am5729-beagleboneai.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300210 "if test $board_name = am572x_idk; then " \
211 "setenv fdtfile am572x-idk.dtb; fi;" \
Lokesh Vutla7b8b6f72017-12-29 11:47:58 +0530212 "if test $board_name = am574x_idk; then " \
213 "setenv fdtfile am574x-idk.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300214 "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 Protsenkob35bcb02019-07-25 16:20:41 +0300227 FASTBOOT_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300228 "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 Protsenko7e43edc2017-09-21 22:37:58 +0300235 "run emmc_linux_boot; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300236 "run emmc_android_boot; " \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300237 ""
238
239#endif /* CONFIG_OMAP54XX */
240
241#endif /* __TI_BOOT_H */