blob: 684a744f312137fc87b07b711c7ef48996724419 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Semen Protsenko4fd79ac2017-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 Protsenko4fd79ac2017-06-14 21:34:23 +03007 */
8
9#ifndef __TI_BOOT_H
10#define __TI_BOOT_H
11
12#ifndef CONSOLEDEV
Sam Protsenkoadc097e2019-07-12 20:38:12 +030013#define CONSOLEDEV "ttyS2"
Semen Protsenko4fd79ac2017-06-14 21:34:23 +030014#endif
15
Igor Opaniuke883ffe2018-06-03 21:56:41 +030016#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 Trofymenkoedd31082019-07-05 15:37:36 +030026#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 Protsenko4fd79ac2017-06-14 21:34:23 +030038#ifndef PARTS_DEFAULT
Sam Protsenkoc90a7602018-04-19 23:57:30 +030039/* 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 Protsenko1e4fb782018-11-15 22:26:17 +020049 "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
Sam Protsenko35e3d2e2019-01-04 22:09:08 +020050 "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
Sam Protsenkoc90a7602018-04-19 23:57:30 +030051 "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
Sam Protsenkoc90a7602018-04-19 23:57:30 +030052 "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
Ruslan Trofymenkoedd31082019-07-05 15:37:36 +030053 COMMON_PARTS \
Sam Protsenkoc90a7602018-04-19 23:57:30 +030054 "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
Igor Opaniuke883ffe2018-06-03 21:56:41 +030055 VBMETA_PART \
Sam Protsenkoc90a7602018-04-19 23:57:30 +030056 "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
57#endif /* PARTS_DEFAULT */
Semen Protsenko4fd79ac2017-06-14 21:34:23 +030058
Igor Opaniuke883ffe2018-06-03 21:56:41 +030059#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 Trofymenkoedd31082019-07-05 15:37:36 +030072#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 Protsenko3db09892019-07-25 16:20:41 +0300101#define FASTBOOT_CMD \
102 "echo Booting into fastboot ...; " \
103 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; "
104
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300105#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 Opaniuke883ffe2018-06-03 21:56:41 +0300113 AVB_VERIFY_CMD \
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300114 "partitions=" PARTS_DEFAULT "\0" \
115 "optargs=\0" \
Semen Protsenkoa17c8b12017-08-16 15:55:48 +0300116 "dofastboot=0\0" \
Sam Protsenko2717c082017-09-21 22:37:58 +0300117 "emmc_linux_boot=" \
Sam Protsenko6ca43a52017-09-21 22:37:59 +0300118 "echo Trying to boot Linux from eMMC ...; " \
Sam Protsenko2717c082017-09-21 22:37:58 +0300119 "setenv mmcdev 1; " \
120 "setenv bootpart 1:2; " \
121 "setenv mmcroot /dev/mmcblk0p2 rw; " \
122 "run mmcboot;\0" \
Semen Protsenkoa17c8b12017-08-16 15:55:48 +0300123 "emmc_android_boot=" \
Sam Protsenko3db09892019-07-25 16:20:41 +0300124 "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 Protsenko6ca43a52017-09-21 22:37:59 +0300146 "echo Trying to boot Android from eMMC ...; " \
Praneeth Bajjurib2031ff2018-04-25 16:03:24 -0500147 "run update_to_fit; " \
Semen Protsenkoa17c8b12017-08-16 15:55:48 +0300148 "setenv eval_bootargs setenv bootargs $bootargs; " \
149 "run eval_bootargs; " \
150 "setenv mmcdev 1; " \
Semen Protsenkoa17c8b12017-08-16 15:55:48 +0300151 "setenv machid fe6; " \
152 "mmc dev $mmcdev; " \
153 "mmc rescan; " \
Igor Opaniuke883ffe2018-06-03 21:56:41 +0300154 AVB_VERIFY_CHECK \
Ruslan Trofymenkoedd31082019-07-05 15:37:36 +0300155 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 Protsenko4fd79ac2017-06-14 21:34:23 +0300165
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 Vutla3741c042017-12-29 11:47:58 +0530180 "if test $board_name = dra76x_acd; then " \
Lokesh Vutla911d76c2017-08-21 12:50:58 +0530181 "setenv fdtfile dra76-evm.dtb; fi;" \
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300182 "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 Vutla08318312017-08-23 11:39:07 +0530186 "if test $board_name = beagle_x15_revc; then " \
187 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300188 "if test $board_name = am572x_idk; then " \
189 "setenv fdtfile am572x-idk.dtb; fi;" \
Lokesh Vutla3741c042017-12-29 11:47:58 +0530190 "if test $board_name = am574x_idk; then " \
191 "setenv fdtfile am574x-idk.dtb; fi;" \
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300192 "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 Protsenko3db09892019-07-25 16:20:41 +0300205 FASTBOOT_CMD \
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300206 "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 Protsenko2717c082017-09-21 22:37:58 +0300213 "run emmc_linux_boot; " \
Semen Protsenkoa17c8b12017-08-16 15:55:48 +0300214 "run emmc_android_boot; " \
Semen Protsenko4fd79ac2017-06-14 21:34:23 +0300215 ""
216
217#endif /* CONFIG_OMAP54XX */
218
219#endif /* __TI_BOOT_H */