1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Configuration for Android Amlogic Meson 64bits SoCs
5 * Copyright (C) 2019 Baylibre, SAS
6 * Author: Jerome Brunet <jbrunet@baylibre.com>
9 #ifndef __MESON64_ANDROID_CONFIG_H
10 #define __MESON64_ANDROID_CONFIG_H
12 #include <linux/sizes.h>
14 #ifndef BOOT_PARTITION
15 #define BOOT_PARTITION "boot"
18 #ifndef LOGO_PARTITION
19 #define LOGO_PARTITION "logo"
22 #ifndef CONTROL_PARTITION
23 #define CONTROL_PARTITION "misc"
26 #if defined(CONFIG_CMD_AVB)
27 #define AVB_VERIFY_CHECK \
28 "if test \"${force_avb}\" -eq 1; then " \
29 "if run avb_verify; then " \
30 "echo AVB verification OK.;" \
31 "setenv bootargs \"$bootargs $avb_bootargs\";" \
33 "echo AVB verification failed.;" \
36 "setenv bootargs \"$bootargs androidboot.verifiedbootstate=orange\";" \
37 "echo Running without AVB...; "\
40 #define AVB_VERIFY_CMD "avb_verify=avb init ${mmcdev}; avb verify $slot_suffix;\0"
42 #define AVB_VERIFY_CHECK ""
43 #define AVB_VERIFY_CMD ""
46 #if defined(CONFIG_CMD_AB_SELECT)
47 #define ANDROIDBOOT_GET_CURRENT_SLOT_CMD "get_current_slot=" \
48 "if part number mmc ${mmcdev} " CONTROL_PARTITION " control_part_number; " \
50 "echo " CONTROL_PARTITION \
51 " partition number:${control_part_number};" \
52 "ab_select current_slot mmc ${mmcdev}:${control_part_number};" \
54 "echo " CONTROL_PARTITION " partition not found;" \
57 #define AB_SELECT_SLOT \
58 "run get_current_slot; " \
59 "if test -e \"${current_slot}\"; " \
61 "setenv slot_suffix _${current_slot}; " \
63 "echo current_slot not found;" \
67 #define AB_SELECT_ARGS \
68 "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \
69 "echo A/B cmdline addition: ${bootargs_ab};" \
70 "setenv bootargs ${bootargs} ${bootargs_ab};"
72 #define AB_BOOTARGS " androidboot.force_normal_boot=1"
73 #define RECOVERY_PARTITION "boot"
75 #define AB_SELECT_SLOT ""
76 #define AB_SELECT_ARGS " "
77 #define ANDROIDBOOT_GET_CURRENT_SLOT_CMD ""
78 #define AB_BOOTARGS " "
79 #define RECOVERY_PARTITION "recovery"
82 #if defined(CONFIG_CMD_ABOOTIMG)
84 * Prepares complete device tree blob for current board (for Android boot).
86 * Boot image or recovery image should be loaded into $loadaddr prior to running
87 * these commands. The logic of these commnads is next:
89 * 1. Read correct DTB for current SoC/board from boot image in $loadaddr
91 * 2. Merge all needed DTBO for current board from 'dtbo' partition into read
93 * 3. User should provide $fdtaddr as 3rd argument to 'bootm'
96 "echo Preparing FDT...; " \
97 "if test $board_name = sei510; then " \
98 "echo \" Reading DTB for sei510...\"; " \
99 "setenv dtb_index 0;" \
100 "elif test $board_name = sei610; then " \
101 "echo \" Reading DTB for sei610...\"; " \
102 "setenv dtb_index 1;" \
104 "echo Error: Android boot is not supported for $board_name; " \
107 "abootimg get dtb --index=$dtb_index dtb_start dtb_size; " \
108 "cp.b $dtb_start $fdt_addr_r $dtb_size; " \
109 "fdt addr $fdt_addr_r 0x80000; " \
110 "if test $board_name = sei510; then " \
111 "echo \" Reading DTBO for sei510...\"; " \
112 "setenv dtbo_index 0;" \
113 "elif test $board_name = sei610; then " \
114 "echo \" Reading DTBO for sei610...\"; " \
115 "setenv dtbo_index 1;" \
117 "echo Error: Android boot is not supported for $board_name; " \
120 "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \
121 "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \
122 "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
123 "echo \" Applying DTBOs...\"; " \
124 "adtimg addr $dtboaddr; " \
125 "adtimg get dt --index=$dtbo_index dtbo0_addr; " \
126 "fdt apply $dtbo0_addr;" \
127 "setenv bootargs \"$bootargs androidboot.dtbo_idx=$dtbo_index \";"\
129 #define BOOT_CMD "bootm ${loadaddr} ${loadaddr} ${fdt_addr_r};"
132 #define PREPARE_FDT " "
133 #define BOOT_CMD "bootm ${loadaddr};"
136 #define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
137 "bootcmd_fastboot=" \
138 "setenv run_fastboot 0;" \
139 "if test \"${boot_source}\" = \"usb\"; then " \
140 "echo Fastboot forced by usb rom boot;" \
141 "setenv run_fastboot 1;" \
143 "if test \"${run_fastboot}\" -eq 0; then " \
144 "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
146 "echo Broken MMC partition scheme;" \
147 "setenv run_fastboot 1;" \
150 "if test \"${run_fastboot}\" -eq 0; then " \
151 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
152 CONTROL_PARTITION "; then " \
153 "if bcb test command = bootonce-bootloader; then " \
154 "echo BCB: Bootloader boot...; " \
155 "bcb clear command; bcb store; " \
156 "setenv run_fastboot 1;" \
157 "elif bcb test command = boot-fastboot; then " \
158 "echo BCB: fastboot userspace boot...; " \
159 "setenv force_recovery 1;" \
162 "echo Warning: BCB is corrupted or does not exist; " \
165 "if test \"${run_fastboot}\" -eq 1; then " \
166 "echo Running Fastboot...;" \
167 "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
170 #define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
173 #define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
174 "bootcmd_recovery=" \
175 "pinmux dev pinctrl@14;" \
176 "pinmux dev pinctrl@40;" \
177 "setenv run_recovery 0;" \
178 "if run check_button; then " \
179 "echo Recovery button is pressed;" \
180 "setenv run_recovery 1;" \
182 "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
183 CONTROL_PARTITION "; then " \
184 "if bcb test command = boot-recovery; then " \
185 "echo BCB: Recovery boot...; " \
186 "setenv run_recovery 1;" \
189 "echo Warning: BCB is corrupted or does not exist; " \
191 "if test \"${skip_recovery}\" -eq 1; then " \
192 "echo Recovery skipped by environment;" \
193 "setenv run_recovery 0;" \
195 "if test \"${force_recovery}\" -eq 1; then " \
196 "echo Recovery forced by environment;" \
197 "setenv run_recovery 1;" \
199 "if test \"${run_recovery}\" -eq 1; then " \
200 "echo Running Recovery...;" \
201 "mmc dev ${mmcdev};" \
202 "setenv bootargs \"${bootargs} androidboot.serialno=${serial#}\";" \
206 "part start mmc ${mmcdev} " RECOVERY_PARTITION "${slot_suffix} boot_start;" \
207 "part size mmc ${mmcdev} " RECOVERY_PARTITION "${slot_suffix} boot_size;" \
208 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
210 "echo Running Android Recovery...;" \
213 "echo Failed to boot Android...;" \
217 #define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
220 #define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
222 "echo Loading Android " BOOT_PARTITION " partition...;" \
223 "mmc dev ${mmcdev};" \
224 "setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \
228 "part start mmc ${mmcdev} " BOOT_PARTITION "${slot_suffix} boot_start;" \
229 "part size mmc ${mmcdev} " BOOT_PARTITION "${slot_suffix} boot_size;" \
230 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
232 "setenv bootargs \"${bootargs} " AB_BOOTARGS "\" ; " \
233 "echo Running Android...;" \
236 "echo Failed to boot Android...;" \
239 #define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \
242 #define BOOT_TARGET_DEVICES(func) \
243 func(FASTBOOT, fastboot, na) \
244 func(RECOVERY, recovery, na) \
245 func(SYSTEM, system, na) \
247 #define PREBOOT_LOAD_LOGO \
248 "if test \"${boot_source}\" != \"usb\" && " \
249 "gpt verify mmc ${mmcdev} ${partitions}; then; " \
250 "mmc dev ${mmcdev};" \
251 "part start mmc ${mmcdev} " LOGO_PARTITION " boot_start;" \
252 "part size mmc ${mmcdev} " LOGO_PARTITION " boot_size;" \
253 "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
254 "bmp display ${loadaddr} m m;" \
258 #define CONFIG_EXTRA_ENV_SETTINGS \
259 "partitions=" PARTS_DEFAULT "\0" \
261 ANDROIDBOOT_GET_CURRENT_SLOT_CMD \
264 "gpio_recovery=88\0" \
265 "check_button=gpio input ${gpio_recovery};test $? -eq 0;\0" \
266 "load_logo=" PREBOOT_LOAD_LOGO "\0" \
267 "stdin=" STDIN_CFG "\0" \
268 "stdout=" STDOUT_CFG "\0" \
269 "stderr=" STDOUT_CFG "\0" \
270 "dtboaddr=0x08200000\0" \
271 "loadaddr=0x01080000\0" \
272 "fdt_addr_r=0x01000000\0" \
273 "scriptaddr=0x08000000\0" \
274 "kernel_addr_r=0x01080000\0" \
275 "pxefile_addr_r=0x01080000\0" \
276 "ramdisk_addr_r=0x13000000\0" \
277 "fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
280 #include <configs/meson64.h>
282 #endif /* __MESON64_ANDROID_CONFIG_H */