]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
configs: meson64_android: boot android via abootimg
authorGuillaume La Roque <glaroque@baylibre.com>
Thu, 5 Aug 2021 15:17:25 +0000 (17:17 +0200)
committerNeil Armstrong <narmstrong@baylibre.com>
Tue, 10 Aug 2021 08:43:54 +0000 (10:43 +0200)
Since Android 10, we are required to use a "dtbo" partition which
includes the various device-tree overlays [1].
It's also possible to provide a "dtb" partition.

This is supported via the "abootimg" command.

On Yukawa, the assumption is that we have only a "dtbo" partition, which
includes all board dtbs and their dtbos [2]

[1] https://source.android.com/devices/architecture/dto/partitions
[2] https://android.googlesource.com/device/amlogic/yukawa/+/refs/heads/master/build/tasks/dtimages.mk#16
Signed-off-by: Guillaume La Roque <glaroque@baylibre.com>
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
include/configs/meson64_android.h

index 0ce616c17edd5d1914bd0122e9a394cc002b5d57..358e0a5c714aca2d852ea3d000cd70cd9ef4d392 100644 (file)
 #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;" \
+       "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;" \
+       "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=" \
                        "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 \
        "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"                                  \