summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGuillaume La Roque <glaroque@baylibre.com>2023-07-17 15:27:32 +0200
committerPraneeth Bajjuri <praneeth@ti.com>2023-07-17 15:15:46 -0500
commit77718b7f42f98b3f012c3d244e61c800d77c6c56 (patch)
tree0b2f01d0743be9ef00e00caa838c745da20bcbe4 /include
parent4cbb1eb81c08fc8f73b308216a0d694721fa8699 (diff)
include: configs: am62x_evm: Add android bootflow
Add android boot flow support for AM62X board based on misc partition to detect reboot reason and boot.img version 2 from android build system. Also add device tree overlay support for Android to enable CSI camera, LVDS screen, HDMI Audio output. This assumes that the `dtbo_index` env variable is a space-separated list of indices. Example: => env set dtbo_index "0 2" => run distro_bootcmd Signed-off-by: Guillaume La Roque <glaroque@baylibre.com> [mkorpershoek: move parts to am62x.env file] Co-developed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Diffstat (limited to 'include')
-rw-r--r--include/configs/am62x_evm.h5
-rw-r--r--include/configs/am62x_evm_android.h222
-rw-r--r--include/environment/ti/mmc_android.env21
3 files changed, 248 insertions, 0 deletions
diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
index bdf0bec098..ff369e907d 100644
--- a/include/configs/am62x_evm.h
+++ b/include/configs/am62x_evm.h
@@ -17,6 +17,11 @@
/* Now for the remaining common defines */
#include <configs/ti_armv7_common.h>
+/* include Android related settings */
+#if CONFIG_CMD_ABOOTIMG
+#include <configs/am62x_evm_android.h>
+#endif
+
/* NAND Driver config */
#define CFG_SYS_NAND_BASE 0x51000000
diff --git a/include/configs/am62x_evm_android.h b/include/configs/am62x_evm_android.h
new file mode 100644
index 0000000000..afabdb4afe
--- /dev/null
+++ b/include/configs/am62x_evm_android.h
@@ -0,0 +1,222 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration header file for K3 AM625 SoC family: Android
+ *
+ * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#ifndef BOOT_PARTITION
+#define BOOT_PARTITION "boot"
+#endif
+
+#ifndef CONTROL_PARTITION
+#define CONTROL_PARTITION "misc"
+#endif
+
+#if defined(CONFIG_CMD_AVB)
+#define AVB_VERIFY_CMD "avb_verify_cmd=" \
+ "if test \"${force_avb}\" -eq 1; then " \
+ "avb init ${mmcdev};" \
+ "if avb verify $slot_suffix; then " \
+ "echo AVB verification OK.;" \
+ "setenv bootargs \"$bootargs $avb_bootargs\";" \
+ "else " \
+ "echo AVB verification failed.;" \
+ "exit; fi;" \
+ "else " \
+ "setenv bootargs \"$bootargs androidboot.verifiedbootstate=orange\";" \
+ "echo Running without AVB...; "\
+ "fi;\0"
+#else
+#define AVB_VERIFY_CMD "avb_verify_cmd=true\0"
+#endif
+
+#if defined(CONFIG_CMD_AB_SELECT)
+#define AB_SELECT_SLOT_CMD "ab_select_slot_cmd=" \
+ "part number mmc ${mmcdev} " CONTROL_PARTITION " control_part_number;" \
+ "if test $? -ne 0; then " \
+ "echo " CONTROL_PARTITION " partition not found;" \
+ "exit;" \
+ "fi;" \
+ "echo " CONTROL_PARTITION " partition number:${control_part_number};" \
+ "ab_select current_slot mmc ${mmcdev}:${control_part_number};" \
+ "if test -z ${current_slot}; then " \
+ "echo current_slot not found;" \
+ "exit;" \
+ "fi;" \
+ "setenv slot_suffix _${current_slot}; " \
+ "setenv bootargs_ab androidboot.slot_suffix=${slot_suffix}; " \
+ "echo A/B cmdline addition: ${bootargs_ab};" \
+ "setenv bootargs ${bootargs} ${bootargs_ab};\0"
+
+#define AB_BOOTARGS " androidboot.force_normal_boot=1"
+#define RECOVERY_PARTITION "boot"
+#else
+#define AB_SELECT_SLOT_CMD "ab_select_slot_cmd=true\0"
+#define AB_BOOTARGS " "
+#define RECOVERY_PARTITION "recovery"
+#endif
+
+/*
+ * Prepares complete device tree blob for current board (for Android boot).
+ *
+ * Boot image or recovery image should be loaded into $loadaddr prior to running
+ * these commands. The logic of these commnads is next:
+ *
+ * 1. Read correct DTB for current SoC/board from boot image in $loadaddr
+ * to $fdtaddr
+ * 2. Merge all needed DTBO for current board from 'dtbo' partition into read
+ * DTB
+ * 3. User should provide $fdtaddr as 3rd argument to 'bootm'
+ */
+#define PREPARE_FDT_CMD "prepare_fdt_cmd=" \
+ "echo Preparing FDT...; " \
+ "if test $board_name = am62x_skevm; then " \
+ "echo \" Reading DTB for am62x_skevm...\"; " \
+ "setenv dtb_index 0;" \
+ "elif test $board_name = am62x_lp_skevm; then " \
+ "echo \" Reading DTB for am62x_lp_skevm...\"; " \
+ "setenv dtb_index 1;" \
+ "else " \
+ "echo Error: Android boot is not supported for $board_name; " \
+ "exit; " \
+ "fi; " \
+ "abootimg get dtb --index=$dtb_index dtb_start dtb_size; " \
+ "cp.b $dtb_start $fdt_addr_r $dtb_size; " \
+ "fdt addr $fdt_addr_r $fdt_size; " \
+ "part start mmc ${mmcdev} dtbo${slot_suffix} dtbo_start; " \
+ "part size mmc ${mmcdev} dtbo${slot_suffix} dtbo_size; " \
+ "mmc read ${dtboaddr} ${dtbo_start} ${dtbo_size}; " \
+ "echo \" Applying DTBOs...\"; " \
+ "adtimg addr $dtboaddr; " \
+ "dtbo_idx=''; " \
+ "for index in $dtbo_index; do " \
+ "adtimg get dt --index=$index dtbo_addr; " \
+ "fdt resize; " \
+ "fdt apply $dtbo_addr; " \
+ "if test $dtbo_idx = ''; then " \
+ "dtbo_idx=${index}; " \
+ "else " \
+ "dtbo_idx=${dtbo_idx},${index}; " \
+ "fi; " \
+ "done; " \
+ "setenv bootargs \"$bootargs androidboot.dtbo_idx=$dtbo_idx \"; \0"
+
+#define BOOT_CMD "bootm ${loadaddr} ${loadaddr} ${fdt_addr_r};"
+
+#define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
+ "bootcmd_fastboot=" \
+ "setenv run_fastboot 0;" \
+ "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
+ "else " \
+ "echo Broken MMC partition scheme;" \
+ "setenv run_fastboot 1;" \
+ "fi; " \
+ "if test \"${run_fastboot}\" -eq 0; then " \
+ "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
+ CONTROL_PARTITION "; then " \
+ "if bcb test command = bootonce-bootloader; then " \
+ "echo BCB: Bootloader boot...; " \
+ "bcb clear command; bcb store; " \
+ "setenv run_fastboot 1;" \
+ "elif bcb test command = boot-fastboot; then " \
+ "echo BCB: fastboot userspace boot...; " \
+ "setenv force_recovery 1;" \
+ "fi; " \
+ "else " \
+ "echo Warning: BCB is corrupted or does not exist; " \
+ "fi;" \
+ "fi;" \
+ "if test \"${run_fastboot}\" -eq 1; then " \
+ "echo Running Fastboot...;" \
+ "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
+ "fi\0"
+
+#define BOOTENV_DEV_NAME_FASTBOOT(devtypeu, devtypel, instance) \
+ "fastboot "
+
+#define BOOTENV_DEV_RECOVERY(devtypeu, devtypel, instance) \
+ "bootcmd_recovery=" \
+ "setenv run_recovery 0;" \
+ "if bcb load " __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV) " " \
+ CONTROL_PARTITION "; then " \
+ "if bcb test command = boot-recovery; then; " \
+ "echo BCB: Recovery boot...; " \
+ "setenv run_recovery 1;" \
+ "fi;" \
+ "else " \
+ "echo Warning: BCB is corrupted or does not exist; " \
+ "fi;" \
+ "if test \"${skip_recovery}\" -eq 1; then " \
+ "echo Recovery skipped by environment;" \
+ "setenv run_recovery 0;" \
+ "fi;" \
+ "if test \"${force_recovery}\" -eq 1; then " \
+ "echo Recovery forced by environment;" \
+ "setenv run_recovery 1;" \
+ "fi;" \
+ "if test \"${run_recovery}\" -eq 1; then " \
+ "echo Running Recovery...;" \
+ "mmc dev ${mmcdev};" \
+ "setenv bootargs \"${bootargs} androidboot.serialno=${serial#}\";" \
+ "run ab_select_slot_cmd;" \
+ "run avb_verify_cmd;" \
+ "part start mmc ${mmcdev} " RECOVERY_PARTITION "${slot_suffix} boot_start;" \
+ "part size mmc ${mmcdev} " RECOVERY_PARTITION "${slot_suffix} boot_size;" \
+ "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
+ "run prepare_fdt_cmd;" \
+ "echo Running Android Recovery...;" \
+ BOOT_CMD \
+ "fi;" \
+ "echo Failed to boot Android...;" \
+ "reset;" \
+ "fi\0" \
+
+#define BOOTENV_DEV_NAME_RECOVERY(devtypeu, devtypel, instance) \
+ "recovery "
+
+#define BOOTENV_DEV_SYSTEM(devtypeu, devtypel, instance) \
+ "bootcmd_system=" \
+ "echo Loading Android " BOOT_PARTITION " partition...;" \
+ "mmc dev ${mmcdev};" \
+ "setenv bootargs ${bootargs} androidboot.serialno=${serial#};" \
+ "run ab_select_slot_cmd;" \
+ "run avb_verify_cmd;" \
+ "part start mmc ${mmcdev} " BOOT_PARTITION "${slot_suffix} boot_start;" \
+ "part size mmc ${mmcdev} " BOOT_PARTITION "${slot_suffix} boot_size;" \
+ "if mmc read ${loadaddr} ${boot_start} ${boot_size}; then " \
+ "run prepare_fdt_cmd;" \
+ "setenv bootargs \"${bootargs} " AB_BOOTARGS "\" ; " \
+ "echo Running Android...;" \
+ BOOT_CMD \
+ "fi;" \
+ "echo Failed to boot Android...\0"
+
+#define BOOTENV_DEV_NAME_SYSTEM(devtypeu, devtypel, instance) \
+ "system "
+
+#define BOOTENV_DEV_PANIC(devtypeu, devtypel, instance) \
+ "bootcmd_panic=" \
+ "fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
+ "reset\0" \
+
+#define BOOTENV_DEV_NAME_PANIC(devtypeu, devtypel, instance) \
+ "panic "
+
+#define EXTRA_ENV_ANDROID_ARGS \
+ AB_SELECT_SLOT_CMD \
+ AVB_VERIFY_CMD \
+ PREPARE_FDT_CMD \
+ BOOTENV
+
+#undef BOOT_TARGET_DEVICES
+#define BOOT_TARGET_DEVICES(func) \
+ func(FASTBOOT, fastboot, na) \
+ func(RECOVERY, recovery, na) \
+ func(SYSTEM, system, na) \
+ func(PANIC, panic, na) \
+
+#undef CFG_EXTRA_ENV_SETTINGS
+#define CFG_EXTRA_ENV_SETTINGS \
+ BOOTENV \
+ EXTRA_ENV_ANDROID_ARGS
diff --git a/include/environment/ti/mmc_android.env b/include/environment/ti/mmc_android.env
new file mode 100644
index 0000000000..fbf5d25312
--- /dev/null
+++ b/include/environment/ti/mmc_android.env
@@ -0,0 +1,21 @@
+/* Android partitions
+ * note that += is needed because \n is converted by space in .env files */
+partitions=
+ name=bootloader,start=5M,size=8M,uuid=${uuid_gpt_bootloader};
+partitions+=name=tiboot3,start=4M,size=1M,uuid=${uuid_gpt_tiboot3};
+partitions+=name=uboot-env,start=13M,size=512K,uuid=${uuid_gpt_env};
+partitions+=name=misc,start=13824K,size=512K,uuid=${uuid_gpt_misc};
+partitions+=name=boot_a,size=40M,uuid=${uuid_gpt_boot_a};
+partitions+=name=boot_b,size=40M,uuid=${uuid_gpt_boot_b};
+partitions+=name=dtbo_a,size=8M,uuid=${uuid_gpt_dtbo_a};
+partitions+=name=dtbo_b,size=8M,uuid=${uuid_gpt_dtbo_b};
+partitions+=name=vbmeta_a,size=64K,uuid=${uuid_gpt_vbmeta_a};
+partitions+=name=vbmeta_b,size=64K,uuid=${uuid_gpt_vbmeta_b};
+partitions+=name=super,size=4608M,uuid=${uuid_gpt_super};
+partitions+=name=metadata,size=16M,uuid=${uuid_gpt_metadata};
+partitions+=name=persist,size=32M,uuid=${uuid_gpt_persist};
+partitions+=name=userdata,size=-,uuid=${uuid_gpt_userdata}
+
+mmcdev=0
+force_avb=0
+envboot=run distro_bootcmd