#include <linux/sizes.h>
-#define CONFIG_SYS_MALLOC_LEN SZ_128M
-
#ifndef BOOT_PARTITION
#define BOOT_PARTITION "boot"
#endif
#define CONTROL_PARTITION "misc"
#endif
+#ifndef EXTRA_ANDROID_ENV_SETTINGS
+#define EXTRA_ANDROID_ENV_SETTINGS ""
+#endif
+
#if defined(CONFIG_CMD_AVB)
#define AVB_VERIFY_CHECK \
"if test \"${force_avb}\" -eq 1; then " \
#define RECOVERY_PARTITION "recovery"
#endif
+#if defined(CONFIG_CMD_ABOOTIMG)
+/*
+ * 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 \
+ "echo Preparing FDT...; " \
+ "if test $board_name = sei510; then " \
+ "echo \" Reading DTB for sei510...\"; " \
+ "setenv dtb_index 0;" \
+ "elif test $board_name = sei610; then " \
+ "echo \" Reading DTB for sei610...\"; " \
+ "setenv dtb_index 1;" \
+ "elif test $board_name = vim3l; then " \
+ "echo \" Reading DTB for vim3l...\"; " \
+ "setenv dtb_index 2;" \
+ "elif test $board_name = vim3; then " \
+ "echo \" Reading DTB for vim3...\"; " \
+ "setenv dtb_index 3;" \
+ "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 0x80000; " \
+ "if test $board_name = sei510; then " \
+ "echo \" Reading DTBO for sei510...\"; " \
+ "setenv dtbo_index 0;" \
+ "elif test $board_name = sei610; then " \
+ "echo \" Reading DTBO for sei610...\"; " \
+ "setenv dtbo_index 1;" \
+ "elif test $board_name = vim3l; then " \
+ "echo \" Reading DTBO for vim3l...\"; " \
+ "setenv dtbo_index 2;" \
+ "elif test $board_name = vim3; then " \
+ "echo \" Reading DTBO for vim3...\"; " \
+ "setenv dtbo_index 3;" \
+ "else " \
+ "echo Error: Android boot is not supported for $board_name; " \
+ "exit; " \
+ "fi; " \
+ "part start mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_start; " \
+ "part size mmc ${mmcdev} dtbo${slot_suffix} p_dtbo_size; " \
+ "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
+ "echo \" Applying DTBOs...\"; " \
+ "adtimg addr $dtboaddr; " \
+ "adtimg get dt --index=$dtbo_index dtbo0_addr; " \
+ "fdt apply $dtbo0_addr;" \
+ "setenv bootargs \"$bootargs androidboot.dtbo_idx=$dtbo_index \";"\
+
+#define BOOT_CMD "bootm ${loadaddr} ${loadaddr} ${fdt_addr_r};"
+
+#else
+#define PREPARE_FDT " "
#define BOOT_CMD "bootm ${loadaddr};"
+#endif
#define BOOTENV_DEV_FASTBOOT(devtypeu, devtypel, instance) \
"bootcmd_fastboot=" \
"echo Fastboot forced by usb rom boot;" \
"setenv run_fastboot 1;" \
"fi;" \
- "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
- "else " \
- "echo Broken MMC partition scheme;" \
- "setenv run_fastboot 1;" \
- "fi;" \
- "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; " \
+ "if test \"${run_fastboot}\" -eq 0; then " \
+ "if gpt verify mmc ${mmcdev} ${partitions}; then; " \
+ "else " \
+ "echo Broken MMC partition scheme;" \
"setenv run_fastboot 1;" \
"fi; " \
- "if 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;" \
+ "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...;" \
"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 " \
+ PREPARE_FDT \
"echo Running Android Recovery...;" \
BOOT_CMD \
"fi;" \
"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 " \
+ PREPARE_FDT \
"setenv bootargs \"${bootargs} " AB_BOOTARGS "\" ; " \
"echo Running Android...;" \
BOOT_CMD \
"fi;" \
- "echo Failed to boot Android...;" \
- "reset\0"
+ "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 BOOT_TARGET_DEVICES(func) \
func(FASTBOOT, fastboot, na) \
func(RECOVERY, recovery, na) \
func(SYSTEM, system, na) \
+ func(PANIC, panic, na) \
#define PREBOOT_LOAD_LOGO \
"if test \"${boot_source}\" != \"usb\" && " \
"fi;" \
"fi;"
-#define CONFIG_EXTRA_ENV_SETTINGS \
+#define CFG_EXTRA_ENV_SETTINGS \
+ EXTRA_ANDROID_ENV_SETTINGS \
"partitions=" PARTS_DEFAULT "\0" \
"mmcdev=2\0" \
+ "fastboot_raw_partition_bootloader=0x1 0xfff mmcpart 1\0" \
+ "fastboot_raw_partition_bootenv=0x0 0xfff mmcpart 2\0" \
ANDROIDBOOT_GET_CURRENT_SLOT_CMD \
AVB_VERIFY_CMD \
"force_avb=0\0" \
"stdin=" STDIN_CFG "\0" \
"stdout=" STDOUT_CFG "\0" \
"stderr=" STDOUT_CFG "\0" \
- "loadaddr=0x01000000\0" \
+ "dtboaddr=0x08200000\0" \
+ "loadaddr=0x01080000\0" \
"fdt_addr_r=0x01000000\0" \
"scriptaddr=0x08000000\0" \
"kernel_addr_r=0x01080000\0" \