Re: [U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format

2018-04-19 Thread Sam Protsenko
On 16 April 2018 at 23:32, Sam Protsenko  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 
> ---
>  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
> 

[U-Boot] [PATCH 5/5] arm: ti: boot: Implement Android boot using DT image format

2018-04-16 Thread Sam Protsenko
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 
---
 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=0x8200\0" \
"kernel_addr_r=0x8200\0" \
"fdtaddr=0x8800\0" \
+   "dtboaddr=0x8900\0" \
"fdt_addr_r=0x8800\0" \