blob: e55a4aec57c5f3f96f7bf9b3f8cca2a95a6c1f91 [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
Igor Opaniukb81b3b62018-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 Trofymenko0655b262019-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 Protsenko334f5bb2017-06-14 21:34:23 +030038#ifndef PARTS_DEFAULT
Sam Protsenko93516052018-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 Protsenko78371f32018-11-15 22:26:17 +020049 "name=bootloader,size=2048K,uuid=${uuid_gpt_bootloader};" \
Sam Protsenko22b71302019-01-04 22:09:08 +020050 "name=uboot-env,start=2432K,size=256K,uuid=${uuid_gpt_reserved};" \
Sam Protsenko93516052018-04-19 23:57:30 +030051 "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
Sam Protsenko93516052018-04-19 23:57:30 +030052 "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +030053 COMMON_PARTS \
Sam Protsenko93516052018-04-19 23:57:30 +030054 "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
Igor Opaniukb81b3b62018-06-03 21:56:41 +030055 VBMETA_PART \
Sam Protsenko93516052018-04-19 23:57:30 +030056 "name=userdata,size=-,uuid=${uuid_gpt_userdata}"
57#endif /* PARTS_DEFAULT */
Semen Protsenko334f5bb2017-06-14 21:34:23 +030058
Igor Opaniukb81b3b62018-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 Trofymenko0655b262019-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
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300101#define DEFAULT_COMMON_BOOT_TI_ARGS \
102 "console=" CONSOLEDEV ",115200n8\0" \
103 "fdtfile=undefined\0" \
104 "bootpart=0:2\0" \
105 "bootdir=/boot\0" \
106 "bootfile=zImage\0" \
107 "usbtty=cdc_acm\0" \
108 "vram=16M\0" \
Igor Opaniukb81b3b62018-06-03 21:56:41 +0300109 AVB_VERIFY_CMD \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300110 "partitions=" PARTS_DEFAULT "\0" \
111 "optargs=\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300112 "dofastboot=0\0" \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300113 "emmc_linux_boot=" \
Sam Protsenkobfd9f7c2017-09-21 22:37:59 +0300114 "echo Trying to boot Linux from eMMC ...; " \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300115 "setenv mmcdev 1; " \
116 "setenv bootpart 1:2; " \
117 "setenv mmcroot /dev/mmcblk0p2 rw; " \
118 "run mmcboot;\0" \
Semen Protsenko93003172017-08-16 15:55:48 +0300119 "emmc_android_boot=" \
Sam Protsenkobfd9f7c2017-09-21 22:37:59 +0300120 "echo Trying to boot Android from eMMC ...; " \
Praneeth Bajjurid89516b2018-04-25 16:03:24 -0500121 "run update_to_fit; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300122 "setenv eval_bootargs setenv bootargs $bootargs; " \
123 "run eval_bootargs; " \
124 "setenv mmcdev 1; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300125 "setenv machid fe6; " \
126 "mmc dev $mmcdev; " \
127 "mmc rescan; " \
Igor Opaniukb81b3b62018-06-03 21:56:41 +0300128 AVB_VERIFY_CHECK \
Ruslan Trofymenko0655b262019-07-05 15:37:36 +0300129 AB_SELECT \
130 "if part start mmc ${mmcdev} boot${slot_suffix} boot_start; " \
131 "then " \
132 "part size mmc ${mmcdev} boot${slot_suffix} " \
133 "boot_size; " \
134 "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \
135 "bootm ${loadaddr}#${fdtfile}; " \
136 "else " \
137 "echo boot${slot_suffix} partition not found; " \
138 "fi;\0"
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300139
140#ifdef CONFIG_OMAP54XX
141
142#define DEFAULT_FDT_TI_ARGS \
143 "findfdt="\
144 "if test $board_name = omap5_uevm; then " \
145 "setenv fdtfile omap5-uevm.dtb; fi; " \
146 "if test $board_name = dra7xx; then " \
147 "setenv fdtfile dra7-evm.dtb; fi;" \
148 "if test $board_name = dra72x-revc; then " \
149 "setenv fdtfile dra72-evm-revc.dtb; fi;" \
150 "if test $board_name = dra72x; then " \
151 "setenv fdtfile dra72-evm.dtb; fi;" \
152 "if test $board_name = dra71x; then " \
153 "setenv fdtfile dra71-evm.dtb; fi;" \
Lokesh Vutla7b8b6f72017-12-29 11:47:58 +0530154 "if test $board_name = dra76x_acd; then " \
Lokesh Vutla066f5782017-08-21 12:50:58 +0530155 "setenv fdtfile dra76-evm.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300156 "if test $board_name = beagle_x15; then " \
157 "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
158 "if test $board_name = beagle_x15_revb1; then " \
159 "setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \
Lokesh Vutla473d8162017-08-23 11:39:07 +0530160 "if test $board_name = beagle_x15_revc; then " \
161 "setenv fdtfile am57xx-beagle-x15-revc.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300162 "if test $board_name = am572x_idk; then " \
163 "setenv fdtfile am572x-idk.dtb; fi;" \
Lokesh Vutla7b8b6f72017-12-29 11:47:58 +0530164 "if test $board_name = am574x_idk; then " \
165 "setenv fdtfile am574x-idk.dtb; fi;" \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300166 "if test $board_name = am57xx_evm; then " \
167 "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
168 "if test $board_name = am57xx_evm_reva3; then " \
169 "setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
170 "if test $board_name = am571x_idk; then " \
171 "setenv fdtfile am571x-idk.dtb; fi;" \
172 "if test $fdtfile = undefined; then " \
173 "echo WARNING: Could not determine device tree to use; fi; \0"
174
175#define CONFIG_BOOTCOMMAND \
176 "if test ${dofastboot} -eq 1; then " \
177 "echo Boot fastboot requested, resetting dofastboot ...;" \
178 "setenv dofastboot 0; saveenv;" \
179 "echo Booting into fastboot ...; " \
180 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
181 "fi;" \
182 "if test ${boot_fit} -eq 1; then " \
183 "run update_to_fit;" \
184 "fi;" \
185 "run findfdt; " \
186 "run envboot; " \
187 "run mmcboot;" \
Sam Protsenko7e43edc2017-09-21 22:37:58 +0300188 "run emmc_linux_boot; " \
Semen Protsenko93003172017-08-16 15:55:48 +0300189 "run emmc_android_boot; " \
Semen Protsenko334f5bb2017-06-14 21:34:23 +0300190 ""
191
192#endif /* CONFIG_OMAP54XX */
193
194#endif /* __TI_BOOT_H */