diff mbox series

[5/5] arm: ti: boot: Implement Android boot using DT image format

Message ID 20180416203227.26523-6-semen.protsenko@linaro.org
State New
Headers show
Series Use Android DT image format for TI boards | expand

Commit Message

Sam Protsenko April 16, 2018, 8:32 p.m. UTC
Make sure we can boot Android on TI boards using scheme described in
Android documentation [1]. For this do next:
 1. Enable "dtimg" command. We will need it to boot the Android using
    new DTB/DTBO image format.
 2. Add fdt overlay support. We will need that to be able to apply fdt
    overlays to dtb file.
 3. Provide new Android boot commands. In case we don't know what board
    it is, let's provide fallback mechanism:
     - use just dtb[0] from dtb.img
     - don't apply any dtbo files on top of it
     - but still that dtb file must be packed into Android DT image

To use new boot scheme, user has to do next:

1. Prepare dtb.img and dtbo.img images, generated with mkdtimg tool (can
   be found in Android sources, see prebuilts/misc/linux-x86/libufdt).
   Example:

   $ ./mkdtimg create dtb.img                            \
                      am57xx-beagle-x15.dtb      --id=0  \
                      am57xx-beagle-x15-revc.dtb --id=1

   $ ./mkdtimg create dtbo.img \
                      am57xx-evm-common.dtbo     --id=0  \
                      mt9t111.dtbo               --id=1  \
                      ov10635.dtbo               --id=2  \
                      am57xx-evm.dtbo            --id=3  \
                      am57xx-evm-reva3.dtbo      --id=4

   Current boot commands rely on that specific order of dtb/dtbo files.
   Also, be sure to compile .dtb files with -@ dtc flag, so that
   overlays can be applied to dtb files.

2. Flash new U-Boot, set new environment and format eMMC:

   $ fastboot flash xloader MLO
   $ fastboot flash bootloader u-boot.img

   => env default -f -a
   => setenv partitions $partitions_android
   => env save
   => fastboot 1

   $ fastboot oem format

3. Flash dtb.img, dtbo.img:

   $ fastboot flash dtb dtb.img
   $ fastboot flash dtbo dtbo.img

4. Flash Android images:

   $ fastboot flash boot boot.img
   $ fastboot flash cache cache.img
   $ fastboot flash recovery recovery.img
   $ fastboot flash system system.img
   $ fastboot flash userdata userdata.img
   $ fastboot flash vendor vendor.img

For more detailed instructions, see [2].

[1] https://source.android.com/devices/architecture/dto/partitions
[2] https://wiki.linaro.org/Boards/BeagleBoard-X15

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 board/ti/common/Kconfig           |  1 +
 configs/am57xx_evm_defconfig      |  1 +
 configs/am57xx_hs_evm_defconfig   |  1 +
 configs/dra7xx_evm_defconfig      |  1 +
 configs/dra7xx_hs_evm_defconfig   |  1 +
 include/configs/ti_armv7_common.h |  1 +
 include/environment/ti/boot.h     | 40 +++++++++++++++++++++++++------
 7 files changed, 39 insertions(+), 7 deletions(-)

Comments

Sam Protsenko April 19, 2018, 8:36 p.m. UTC | #1
On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> Make sure we can boot Android on TI boards using scheme described in
> Android documentation [1]. For this do next:
>  1. Enable "dtimg" command. We will need it to boot the Android using
>     new DTB/DTBO image format.
>  2. Add fdt overlay support. We will need that to be able to apply fdt
>     overlays to dtb file.
>  3. Provide new Android boot commands. In case we don't know what board
>     it is, let's provide fallback mechanism:
>      - use just dtb[0] from dtb.img
>      - don't apply any dtbo files on top of it
>      - but still that dtb file must be packed into Android DT image
>
> To use new boot scheme, user has to do next:
>
> 1. Prepare dtb.img and dtbo.img images, generated with mkdtimg tool (can
>    be found in Android sources, see prebuilts/misc/linux-x86/libufdt).
>    Example:
>
>    $ ./mkdtimg create dtb.img                            \
>                       am57xx-beagle-x15.dtb      --id=0  \
>                       am57xx-beagle-x15-revc.dtb --id=1
>
>    $ ./mkdtimg create dtbo.img \
>                       am57xx-evm-common.dtbo     --id=0  \
>                       mt9t111.dtbo               --id=1  \
>                       ov10635.dtbo               --id=2  \
>                       am57xx-evm.dtbo            --id=3  \
>                       am57xx-evm-reva3.dtbo      --id=4
>
>    Current boot commands rely on that specific order of dtb/dtbo files.
>    Also, be sure to compile .dtb files with -@ dtc flag, so that
>    overlays can be applied to dtb files.
>
> 2. Flash new U-Boot, set new environment and format eMMC:
>
>    $ fastboot flash xloader MLO
>    $ fastboot flash bootloader u-boot.img
>
>    => env default -f -a
>    => setenv partitions $partitions_android
>    => env save
>    => fastboot 1
>
>    $ fastboot oem format
>
> 3. Flash dtb.img, dtbo.img:
>
>    $ fastboot flash dtb dtb.img
>    $ fastboot flash dtbo dtbo.img
>
> 4. Flash Android images:
>
>    $ fastboot flash boot boot.img
>    $ fastboot flash cache cache.img
>    $ fastboot flash recovery recovery.img
>    $ fastboot flash system system.img
>    $ fastboot flash userdata userdata.img
>    $ fastboot flash vendor vendor.img
>
> For more detailed instructions, see [2].
>
> [1] https://source.android.com/devices/architecture/dto/partitions
> [2] https://wiki.linaro.org/Boards/BeagleBoard-X15
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  board/ti/common/Kconfig           |  1 +
>  configs/am57xx_evm_defconfig      |  1 +
>  configs/am57xx_hs_evm_defconfig   |  1 +
>  configs/dra7xx_evm_defconfig      |  1 +
>  configs/dra7xx_hs_evm_defconfig   |  1 +
>  include/configs/ti_armv7_common.h |  1 +
>  include/environment/ti/boot.h     | 40 +++++++++++++++++++++++++------
>  7 files changed, 39 insertions(+), 7 deletions(-)
>
> diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
> index c21eb8c2d2..f5bd9160b3 100644
> --- a/board/ti/common/Kconfig
> +++ b/board/ti/common/Kconfig
> @@ -21,6 +21,7 @@ config TI_COMMON_CMD_OPTIONS
>         imply CRC32_VERIFY if ARCH_KEYSTONE
>         imply CMD_DFU if USB_GADGET_DOWNLOAD
>         imply CMD_DHCP
> +       imply CMD_DTIMG
>         imply CMD_EEPROM
>         imply CMD_EXT2
>         imply CMD_EXT4
> diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
> index 6b11b3476c..7198542d9e 100644
> --- a/configs/am57xx_evm_defconfig
> +++ b/configs/am57xx_evm_defconfig
> @@ -78,3 +78,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
> index ca9742f118..e4948d549b 100644
> --- a/configs/am57xx_hs_evm_defconfig
> +++ b/configs/am57xx_hs_evm_defconfig
> @@ -81,3 +81,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
> index e17135c8f6..4ce687fbda 100644
> --- a/configs/dra7xx_evm_defconfig
> +++ b/configs/dra7xx_evm_defconfig
> @@ -96,3 +96,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
> index 606f99938c..6546daa080 100644
> --- a/configs/dra7xx_hs_evm_defconfig
> +++ b/configs/dra7xx_hs_evm_defconfig
> @@ -95,3 +95,4 @@ CONFIG_USB_GADGET=y
>  CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
>  CONFIG_USB_GADGET_VENDOR_NUM=0x0451
>  CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
> +CONFIG_OF_LIBFDT_OVERLAY=y
> diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
> index 4771e74940..4340b5188f 100644
> --- a/include/configs/ti_armv7_common.h
> +++ b/include/configs/ti_armv7_common.h
> @@ -43,6 +43,7 @@
>         "loadaddr=0x82000000\0" \
>         "kernel_addr_r=0x82000000\0" \
>         "fdtaddr=0x88000000\0" \
> +       "dtboaddr=0x89000000\0" \
>         "fdt_addr_r=0x88000000\0" \
>         "rdaddr=0x88080000\0" \
>         "ramdisk_addr_r=0x88080000\0" \
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index f2d91f5298..52c9f129ed 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -65,15 +65,41 @@
>                 "run eval_bootargs; " \
>                 "setenv mmcdev 1; " \
>                 "setenv machid fe6; " \
> +               "setenv dtbaddr $fdtaddr; " \
> +               "setenv dtb_size 0x100000; " \
>                 "mmc dev $mmcdev; " \
>                 "mmc rescan; " \
> -               "part start mmc ${mmcdev} dtb fdt_start; " \
> -               "part size mmc ${mmcdev} dtb fdt_size; " \
> -               "part start mmc ${mmcdev} boot boot_start; " \
> -               "part size mmc ${mmcdev} boot boot_size; " \
> -               "mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
> -               "mmc read ${loadaddr} ${boot_start} ${boot_size}; " \
> -               "bootm $loadaddr $loadaddr $fdtaddr;\0"
> +               "part start mmc ${mmcdev} dtb p_dtb_start; " \
> +               "part size mmc ${mmcdev} dtb p_dtb_size; " \
> +               "part start mmc ${mmcdev} dtbo p_dtbo_start; " \
> +               "part size mmc ${mmcdev} dtbo p_dtbo_size; " \
> +               "part start mmc ${mmcdev} boot p_boot_start; " \
> +               "part size mmc ${mmcdev} boot p_boot_size; " \
> +               "mmc read ${dtbaddr} ${p_dtb_start} ${p_dtb_size}; " \
> +               "mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
> +               "mmc read ${loadaddr} ${p_boot_start} ${p_boot_size}; " \
> +               "if test $board_name = am57xx_evm; then " \
> +                       "dtimg start ${dtbaddr} 0 dtb_addr; " \
> +                       "fdt addr $dtb_addr $dtb_size; " \
> +                       "dtimg start ${dtboaddr} 0 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +                       "dtimg start ${dtboaddr} 3 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +               "elif test $board_name = am57xx_evm_reva3; then " \
> +                       "dtimg start ${dtbaddr} 1 dtb_addr; " \
> +                       "fdt addr $dtb_addr $dtb_size; " \
> +                       "dtimg start ${dtboaddr} 0 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +                       "dtimg start ${dtboaddr} 4 dtbo_addr; " \
> +                       "fdt apply $dtbo_addr; " \
> +               "elif test $board_name = beagle_x15; then " \
> +                       "dtimg start ${dtbaddr} 0 dtb_addr; " \
> +               "elif test $board_name = beagle_x15_revc; then " \
> +                       "dtimg start ${dtbaddr} 1 dtb_addr; " \
> +               "else " \
> +                       "dtimg start ${dtbaddr} 0 dtb_addr; " \
> +               "fi; " \
> +               "bootm $loadaddr $loadaddr $dtb_addr;\0"
>
>  #ifdef CONFIG_OMAP54XX
>
> --
> 2.17.0
>

Abandon this patch. I'm gonna send v2 soon.
diff mbox series

Patch

diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index c21eb8c2d2..f5bd9160b3 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -21,6 +21,7 @@  config TI_COMMON_CMD_OPTIONS
 	imply CRC32_VERIFY if ARCH_KEYSTONE
 	imply CMD_DFU if USB_GADGET_DOWNLOAD
 	imply CMD_DHCP
+	imply CMD_DTIMG
 	imply CMD_EEPROM
 	imply CMD_EXT2
 	imply CMD_EXT4
diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index 6b11b3476c..7198542d9e 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -78,3 +78,4 @@  CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index ca9742f118..e4948d549b 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -81,3 +81,4 @@  CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index e17135c8f6..4ce687fbda 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -96,3 +96,4 @@  CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 606f99938c..6546daa080 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -95,3 +95,4 @@  CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="Texas Instruments"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0451
 CONFIG_USB_GADGET_PRODUCT_NUM=0xd022
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
index 4771e74940..4340b5188f 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -43,6 +43,7 @@ 
 	"loadaddr=0x82000000\0" \
 	"kernel_addr_r=0x82000000\0" \
 	"fdtaddr=0x88000000\0" \
+	"dtboaddr=0x89000000\0" \
 	"fdt_addr_r=0x88000000\0" \
 	"rdaddr=0x88080000\0" \
 	"ramdisk_addr_r=0x88080000\0" \
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index f2d91f5298..52c9f129ed 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -65,15 +65,41 @@ 
 		"run eval_bootargs; " \
 		"setenv mmcdev 1; " \
 		"setenv machid fe6; " \
+		"setenv dtbaddr $fdtaddr; " \
+		"setenv dtb_size 0x100000; " \
 		"mmc dev $mmcdev; " \
 		"mmc rescan; " \
-		"part start mmc ${mmcdev} dtb fdt_start; " \
-		"part size mmc ${mmcdev} dtb fdt_size; " \
-		"part start mmc ${mmcdev} boot boot_start; " \
-		"part size mmc ${mmcdev} boot boot_size; " \
-		"mmc read ${fdtaddr} ${fdt_start} ${fdt_size}; " \
-		"mmc read ${loadaddr} ${boot_start} ${boot_size}; " \
-		"bootm $loadaddr $loadaddr $fdtaddr;\0"
+		"part start mmc ${mmcdev} dtb p_dtb_start; " \
+		"part size mmc ${mmcdev} dtb p_dtb_size; " \
+		"part start mmc ${mmcdev} dtbo p_dtbo_start; " \
+		"part size mmc ${mmcdev} dtbo p_dtbo_size; " \
+		"part start mmc ${mmcdev} boot p_boot_start; " \
+		"part size mmc ${mmcdev} boot p_boot_size; " \
+		"mmc read ${dtbaddr} ${p_dtb_start} ${p_dtb_size}; " \
+		"mmc read ${dtboaddr} ${p_dtbo_start} ${p_dtbo_size}; " \
+		"mmc read ${loadaddr} ${p_boot_start} ${p_boot_size}; " \
+		"if test $board_name = am57xx_evm; then " \
+			"dtimg start ${dtbaddr} 0 dtb_addr; " \
+			"fdt addr $dtb_addr $dtb_size; " \
+			"dtimg start ${dtboaddr} 0 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+			"dtimg start ${dtboaddr} 3 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+		"elif test $board_name = am57xx_evm_reva3; then " \
+			"dtimg start ${dtbaddr} 1 dtb_addr; " \
+			"fdt addr $dtb_addr $dtb_size; " \
+			"dtimg start ${dtboaddr} 0 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+			"dtimg start ${dtboaddr} 4 dtbo_addr; " \
+			"fdt apply $dtbo_addr; " \
+		"elif test $board_name = beagle_x15; then " \
+			"dtimg start ${dtbaddr} 0 dtb_addr; " \
+		"elif test $board_name = beagle_x15_revc; then " \
+			"dtimg start ${dtbaddr} 1 dtb_addr; " \
+		"else " \
+			"dtimg start ${dtbaddr} 0 dtb_addr; " \
+		"fi; " \
+		"bootm $loadaddr $loadaddr $dtb_addr;\0"
 
 #ifdef CONFIG_OMAP54XX