blob: a9d8f28d4679a731c6e4f61bec1056c659264ee3 [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
Simon Glassfb64e362020-05-10 11:40:09 -060012#include <linux/stringify.h>
13
Semen Protsenko334f5bb2017-06-14 21:34:23 +030014#ifndef CONSOLEDEV
Sam Protsenko02c005f2019-07-12 20:38:12 +030015#define CONSOLEDEV "ttyS2"
Semen Protsenko334f5bb2017-06-14 21:34:23 +030016#endif
17
18#ifndef PARTS_DEFAULT
Sam Protsenko04cdcee2020-01-24 17:53:48 +020019/*
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 Protsenko93516052018-04-19 23:57:30 +030026#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 Protsenko78371f32018-11-15 22:26:17 +020035 "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
Sam Protsenko22b71302019-01-04 22:09:08 +020036 "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
Sam Protsenko93516052018-04-19 23:57:30 +030037 "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
Sam Protsenko04cdcee2020-01-24 17:53:48 +020038 "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 Protsenko93516052018-04-19 23:57:30 +030047 "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
48#endif /* PARTS_DEFAULT */
Semen Protsenko334f5bb2017-06-14 21:34:23 +030049
Igor Opaniukb81b3b62018-06-03 21:56:41 +030050#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 Protsenko0b47e442020-01-24 17:53:47 +020057#define AVB_VERIFY_CMD "avb_verify=avb init 1; avb verify $slot_suffix;\0"
Igor Opaniukb81b3b62018-06-03 21:56:41 +030058#else
59#define AVB_VERIFY_CHECK ""
60#define AVB_VERIFY_CMD ""
61#endif
62
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030063#define CONTROL_PARTITION "misc"
64
65#if defined(CONFIG_CMD_AB_SELECT)
Sam Protsenko04cdcee2020-01-24 17:53:48 +020066#define AB_SELECT_SLOT \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030067 "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 Protsenko04cdcee2020-01-24 17:53:48 +020076 "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 Trofymenko0655b262019-07-05 15:37:36 +030081#else
Sam Protsenko04cdcee2020-01-24 17:53:48 +020082#define AB_SELECT_SLOT ""
83#define AB_SELECT_ARGS ""
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030084#endif
85
Sam Protsenko1651ee12020-01-24 17:53:49 +020086/*
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 Protsenkofe129ac2020-02-21 16:35:21 +0200108 "fdt addr $fdtaddr 0x80000; " \
Sam Protsenko1651ee12020-01-24 17:53:49 +0200109 "echo \" Applying DTBOs for AM57x EVM RevA3...\"; " \
110 "adtimg addr $dtboaddr; " \
Sam Protsenkofe129ac2020-02-21 16:35:21 +0200111 "adtimg get dt --index=0 dtbo0_addr dtbo0_size; " \
Sam Protsenko1651ee12020-01-24 17:53:49 +0200112 "fdt apply $dtbo0_addr; " \
Sam Protsenkofe129ac2020-02-21 16:35:21 +0200113 "adtimg get dt --index=1 dtbo1_addr dtbo1_size; " \
Sam Protsenko1651ee12020-01-24 17:53:49 +0200114 "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 Protsenkofe129ac2020-02-21 16:35:21 +0200119 "fdt addr $fdtaddr 0x80000; " \
Sam Protsenko1651ee12020-01-24 17:53:49 +0200120 "else " \
121 "echo Error: Android boot is not supported for $board_name; " \
122 "exit; " \
123 "fi; " \
124
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300125#define FASTBOOT_CMD \
126 "echo Booting into fastboot ...; " \
127 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; "
128
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300129#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 Opaniukb81b3b62018-06-03 21:56:41 +0300137 AVB_VERIFY_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300138 "partitions=" PARTS_DEFAULT "\0" \
139 "optargs=\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300140 "dofastboot=0\0" \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300141 "emmc_linux_boot=" \
Sam Protsenkobfd9f7c2017-09-21 22:37:59 +0300142 "echo Trying to boot Linux from eMMC ...; " \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300143 "setenv mmcdev 1; " \
144 "setenv bootpart 1:2; " \
145 "setenv mmcroot /dev/mmcblk0p2 rw; " \
146 "run mmcboot;\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300147 "emmc_android_boot=" \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200148 "setenv mmcdev 1; " \
149 "mmc dev $mmcdev; " \
150 "mmc rescan; " \
151 AB_SELECT_SLOT \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300152 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
153 CONTROL_PARTITION "; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200154 "setenv ardaddr -; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300155 "if bcb test command = bootonce-bootloader; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200156 "echo Android: Bootloader boot...; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300157 "bcb clear command; bcb store; " \
158 FASTBOOT_CMD \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200159 "exit; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300160 "elif bcb test command = boot-recovery; then " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200161 "echo Android: Recovery boot...; " \
162 "setenv ardaddr $loadaddr;" \
163 "setenv apart recovery; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300164 "else " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200165 "echo Android: Normal boot...; " \
166 "setenv ardaddr $loadaddr; " \
167 "setenv apart boot${slot_suffix}; " \
Sam Protsenkob35bcb02019-07-25 16:20:41 +0300168 "fi; " \
169 "else " \
170 "echo Warning: BCB is corrupted or does not exist; " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200171 "echo Android: Normal boot...; " \
172 "fi; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300173 "setenv eval_bootargs setenv bootargs $bootargs; " \
174 "run eval_bootargs; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300175 "setenv machid fe6; " \
Igor Opaniukb81b3b62018-06-03 21:56:41 +0300176 AVB_VERIFY_CHECK \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200177 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 Protsenko1651ee12020-01-24 17:53:49 +0200181 PREPARE_FDT \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200182 "bootm $loadaddr $ardaddr $fdtaddr; " \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +0300183 "else " \
Sam Protsenko04cdcee2020-01-24 17:53:48 +0200184 "echo $apart partition not found; " \
185 "exit; " \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +0300186 "fi;\0"
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300187
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 Vutla7b8b6f72017-12-29 11:47:58 +0530202 "if test $board_name = dra76x_acd; then " \
Lokesh Vutla066f5782017-08-21 12:50:58 +0530203 "setenv fdtfile dra76-evm.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300204 "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 Vutla473d8162017-08-23 11:39:07 +0530208 "if test $board_name = beagle_x15_revc; then " \
209 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
Caleb Robey7566e042020-01-02 08:17:29 -0600210 "if test $board_name = am5729_beagleboneai; then " \
211 "setenv fdtfile am5729-beagleboneai.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300212 "if test $board_name = am572x_idk; then " \
213 "setenv fdtfile am572x-idk.dtb; fi;" \
Lokesh Vutla7b8b6f72017-12-29 11:47:58 +0530214 "if test $board_name = am574x_idk; then " \
215 "setenv fdtfile am574x-idk.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300216 "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 Protsenkob35bcb02019-07-25 16:20:41 +0300229 FASTBOOT_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300230 "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 Protsenko7e43edc2017-09-21 22:37:58 +0300237 "run emmc_linux_boot; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300238 "run emmc_android_boot; " \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300239 ""
240
241#endif /* CONFIG_OMAP54XX */
242
243#endif /* __TI_BOOT_H */