diff mbox series

[4/5] arm: ti: boot: Add dtbo partition for Android boot

Message ID 20180416203227.26523-5-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
New Android boot scheme looks like this [1], and it involves adding new
partition for storing Device Tree Overlays. This patch adds dtbo
partition. While at it, let's revise Android partition table a bit.

List of changes:
 - rename "misc" to "hole" (not used for anything, just a guard hole)
 - rename "reserved" to "uenv" (because it hold U-Boot environment)
 - rename "environment" to "dtb" (because it actually holds .dtb file)
 - move "dtb" after "uenv" (so that changes of dtb size won't affect
   "uenv" offset)
 - make "hole" size twice as bigger (to keep "uenv" offset the same,
   because "dtb" was moved after "uenv")
 - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
 - while at it, increase "boot" partition size up to 20 MiB; that's
   needed because while playing with some additional drivers built-in
   and different compression techniques, and also for HS signing, we
   have seen the boot partition size reach close to border and
   sometimes reach over the limit of 10 MiB

Now eMMC layout looks like this:

    offset           content             size          partition
    (KiB)                                (KiB)

    ===============================================================

    0       +------------------------+
            | MBR/GPT header         |   128           -
    128     +------------------------+
            | MLO                    |   256           xloader
    384     +------------------------+
            | u-boot.img             |   1792          bootloader
    2176    +------------------------+
            | //////// hole //////// |   256           hole
    2432    +------------------------+
            | U-Boot environment     |   256           uenv
            | (+ redundant)          |
    2688    +------------------------+
            | dtb files              |   1024          dtb
    3712    +------------------------+
            | dtbo files             |   1024          dtbo
    4736    +------------------------+
              Android partitions         remaining     *

    ===============================================================

"hole" partition is needed just to keep U-Boot environment at 2432 KiB
offset, because:
 - this offset is used in DFU_ALT_INFO_EMMC:

       "u-env.raw raw 0x1300 0x200;"
       0x1300 = 4864 sectors = 2432 KiB

 - which in turn relies on CONFIG_ENV_OFFSET:

       CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB

We are using "hole" partition instead of specifying "start" property to
"uenv" partition, because this way it's easier to maintain change of
preceding partitions.

Also fix Android boot commands appropriately.

[1] https://source.android.com/devices/architecture/dto/partitions

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 include/environment/ti/boot.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Andrew Davis April 17, 2018, 9:10 p.m. UTC | #1
On 04/16/2018 03:32 PM, Sam Protsenko wrote:
> New Android boot scheme looks like this [1], and it involves adding new
> partition for storing Device Tree Overlays. This patch adds dtbo
> partition. While at it, let's revise Android partition table a bit.
> 
> List of changes:
>  - rename "misc" to "hole" (not used for anything, just a guard hole)

Could we instead expand the bootloader partition and just remove this
hole partition?

>  - rename "reserved" to "uenv" (because it hold U-Boot environment)

This is fine.

>  - rename "environment" to "dtb" (because it actually holds .dtb file)


We are working to move to FIT with our Android releases, so the
"boot.img" image will now be a FIT image that contains kernel, dtb,
dtbo, op-tee, ipu, ipu2, etc...

The end result is all these custom partitions we had before all just get
folded into the one boot partition.

Andrew


>  - move "dtb" after "uenv" (so that changes of dtb size won't affect
>    "uenv" offset)
>  - make "hole" size twice as bigger (to keep "uenv" offset the same,
>    because "dtb" was moved after "uenv")
>  - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
>  - while at it, increase "boot" partition size up to 20 MiB; that's
>    needed because while playing with some additional drivers built-in
>    and different compression techniques, and also for HS signing, we
>    have seen the boot partition size reach close to border and
>    sometimes reach over the limit of 10 MiB
> 
> Now eMMC layout looks like this:
> 
>     offset           content             size          partition
>     (KiB)                                (KiB)
> 
>     ===============================================================
> 
>     0       +------------------------+
>             | MBR/GPT header         |   128           -
>     128     +------------------------+
>             | MLO                    |   256           xloader
>     384     +------------------------+
>             | u-boot.img             |   1792          bootloader
>     2176    +------------------------+
>             | //////// hole //////// |   256           hole
>     2432    +------------------------+
>             | U-Boot environment     |   256           uenv
>             | (+ redundant)          |
>     2688    +------------------------+
>             | dtb files              |   1024          dtb
>     3712    +------------------------+
>             | dtbo files             |   1024          dtbo
>     4736    +------------------------+
>               Android partitions         remaining     *
> 
>     ===============================================================
> 
> "hole" partition is needed just to keep U-Boot environment at 2432 KiB
> offset, because:
>  - this offset is used in DFU_ALT_INFO_EMMC:
> 
>        "u-env.raw raw 0x1300 0x200;"
>        0x1300 = 4864 sectors = 2432 KiB
> 
>  - which in turn relies on CONFIG_ENV_OFFSET:
> 
>        CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB
> 
> We are using "hole" partition instead of specifying "start" property to
> "uenv" partition, because this way it's easier to maintain change of
> preceding partitions.
> 
> Also fix Android boot commands appropriately.
> 
> [1] https://source.android.com/devices/architecture/dto/partitions
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  include/environment/ti/boot.h | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 4f3d748b5c..f2d91f5298 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -26,13 +26,14 @@
>  	"uuid_disk=${uuid_gpt_disk};" \
>  	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
>  	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> +	"name=hole,size=256K,uuid=${uuid_gpt_hole};" \
> +	"name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
> +	"name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
> +	"name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
>  	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
>  	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
>  	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> +	"name=boot,size=20M,uuid=${uuid_gpt_boot};" \
>  	"name=system,size=768M,uuid=${uuid_gpt_system};" \
>  	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
>  	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> @@ -66,8 +67,8 @@
>  		"setenv machid fe6; " \
>  		"mmc dev $mmcdev; " \
>  		"mmc rescan; " \
> -		"part start mmc ${mmcdev} environment fdt_start; " \
> -		"part size mmc ${mmcdev} environment fdt_size; " \
> +		"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}; " \
>
Sam Protsenko April 19, 2018, 8:33 p.m. UTC | #2
On 18 April 2018 at 00:10, Andrew F. Davis <afd@ti.com> wrote:
> On 04/16/2018 03:32 PM, Sam Protsenko wrote:
>> New Android boot scheme looks like this [1], and it involves adding new
>> partition for storing Device Tree Overlays. This patch adds dtbo
>> partition. While at it, let's revise Android partition table a bit.
>>
>> List of changes:
>>  - rename "misc" to "hole" (not used for anything, just a guard hole)
>
> Could we instead expand the bootloader partition and just remove this
> hole partition?
>

We can, I just think having dedicated partition for this can spare us
some debugging time in future. As I explained it in my commit message:

  We are using "hole" partition instead of specifying "start" property to
  "uenv" partition, because this way it's easier to maintain change of
  preceding partitions.

>>  - rename "reserved" to "uenv" (because it hold U-Boot environment)
>
> This is fine.
>
>>  - rename "environment" to "dtb" (because it actually holds .dtb file)
>
>
> We are working to move to FIT with our Android releases, so the
> "boot.img" image will now be a FIT image that contains kernel, dtb,
> dtbo, op-tee, ipu, ipu2, etc...
>
> The end result is all these custom partitions we had before all just get
> folded into the one boot partition.
>

As I understand, it's not completely our shot. If Google says it's
mandatory to use DT image format, we will use it. That's why I
implemented this patch series. Please discuss it with Praneeth, some
of us obviously is not on the same page with others... For now we are
going to add DT image format support, and once we have confirmation
from Google, we can choose which one to prefer in upstream. But having
support of this format won't hurt anyone, especially knowing that
Google recommends this format in their documentation.

> Andrew
>
>
>>  - move "dtb" after "uenv" (so that changes of dtb size won't affect
>>    "uenv" offset)
>>  - make "hole" size twice as bigger (to keep "uenv" offset the same,
>>    because "dtb" was moved after "uenv")
>>  - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
>>  - while at it, increase "boot" partition size up to 20 MiB; that's
>>    needed because while playing with some additional drivers built-in
>>    and different compression techniques, and also for HS signing, we
>>    have seen the boot partition size reach close to border and
>>    sometimes reach over the limit of 10 MiB
>>
>> Now eMMC layout looks like this:
>>
>>     offset           content             size          partition
>>     (KiB)                                (KiB)
>>
>>     ===============================================================
>>
>>     0       +------------------------+
>>             | MBR/GPT header         |   128           -
>>     128     +------------------------+
>>             | MLO                    |   256           xloader
>>     384     +------------------------+
>>             | u-boot.img             |   1792          bootloader
>>     2176    +------------------------+
>>             | //////// hole //////// |   256           hole
>>     2432    +------------------------+
>>             | U-Boot environment     |   256           uenv
>>             | (+ redundant)          |
>>     2688    +------------------------+
>>             | dtb files              |   1024          dtb
>>     3712    +------------------------+
>>             | dtbo files             |   1024          dtbo
>>     4736    +------------------------+
>>               Android partitions         remaining     *
>>
>>     ===============================================================
>>
>> "hole" partition is needed just to keep U-Boot environment at 2432 KiB
>> offset, because:
>>  - this offset is used in DFU_ALT_INFO_EMMC:
>>
>>        "u-env.raw raw 0x1300 0x200;"
>>        0x1300 = 4864 sectors = 2432 KiB
>>
>>  - which in turn relies on CONFIG_ENV_OFFSET:
>>
>>        CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB
>>
>> We are using "hole" partition instead of specifying "start" property to
>> "uenv" partition, because this way it's easier to maintain change of
>> preceding partitions.
>>
>> Also fix Android boot commands appropriately.
>>
>> [1] https://source.android.com/devices/architecture/dto/partitions
>>
>> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
>> ---
>>  include/environment/ti/boot.h | 13 +++++++------
>>  1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
>> index 4f3d748b5c..f2d91f5298 100644
>> --- a/include/environment/ti/boot.h
>> +++ b/include/environment/ti/boot.h
>> @@ -26,13 +26,14 @@
>>       "uuid_disk=${uuid_gpt_disk};" \
>>       "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
>>       "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
>> -     "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
>> -     "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
>> -     "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
>> +     "name=hole,size=256K,uuid=${uuid_gpt_hole};" \
>> +     "name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
>> +     "name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
>> +     "name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
>>       "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
>>       "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
>>       "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
>> -     "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
>> +     "name=boot,size=20M,uuid=${uuid_gpt_boot};" \
>>       "name=system,size=768M,uuid=${uuid_gpt_system};" \
>>       "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
>>       "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
>> @@ -66,8 +67,8 @@
>>               "setenv machid fe6; " \
>>               "mmc dev $mmcdev; " \
>>               "mmc rescan; " \
>> -             "part start mmc ${mmcdev} environment fdt_start; " \
>> -             "part size mmc ${mmcdev} environment fdt_size; " \
>> +             "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}; " \
>>
Sam Protsenko April 19, 2018, 8:34 p.m. UTC | #3
On 16 April 2018 at 23:32, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> New Android boot scheme looks like this [1], and it involves adding new
> partition for storing Device Tree Overlays. This patch adds dtbo
> partition. While at it, let's revise Android partition table a bit.
>
> List of changes:
>  - rename "misc" to "hole" (not used for anything, just a guard hole)
>  - rename "reserved" to "uenv" (because it hold U-Boot environment)
>  - rename "environment" to "dtb" (because it actually holds .dtb file)
>  - move "dtb" after "uenv" (so that changes of dtb size won't affect
>    "uenv" offset)
>  - make "hole" size twice as bigger (to keep "uenv" offset the same,
>    because "dtb" was moved after "uenv")
>  - add "dtbo" partition (after "dtb", to not affect "uenv" offset)
>  - while at it, increase "boot" partition size up to 20 MiB; that's
>    needed because while playing with some additional drivers built-in
>    and different compression techniques, and also for HS signing, we
>    have seen the boot partition size reach close to border and
>    sometimes reach over the limit of 10 MiB
>
> Now eMMC layout looks like this:
>
>     offset           content             size          partition
>     (KiB)                                (KiB)
>
>     ===============================================================
>
>     0       +------------------------+
>             | MBR/GPT header         |   128           -
>     128     +------------------------+
>             | MLO                    |   256           xloader
>     384     +------------------------+
>             | u-boot.img             |   1792          bootloader
>     2176    +------------------------+
>             | //////// hole //////// |   256           hole
>     2432    +------------------------+
>             | U-Boot environment     |   256           uenv
>             | (+ redundant)          |
>     2688    +------------------------+
>             | dtb files              |   1024          dtb
>     3712    +------------------------+
>             | dtbo files             |   1024          dtbo
>     4736    +------------------------+
>               Android partitions         remaining     *
>
>     ===============================================================
>
> "hole" partition is needed just to keep U-Boot environment at 2432 KiB
> offset, because:
>  - this offset is used in DFU_ALT_INFO_EMMC:
>
>        "u-env.raw raw 0x1300 0x200;"
>        0x1300 = 4864 sectors = 2432 KiB
>
>  - which in turn relies on CONFIG_ENV_OFFSET:
>
>        CONFIG_ENV_OFFSET = 0x260000 = 2432 KiB
>
> We are using "hole" partition instead of specifying "start" property to
> "uenv" partition, because this way it's easier to maintain change of
> preceding partitions.
>
> Also fix Android boot commands appropriately.
>
> [1] https://source.android.com/devices/architecture/dto/partitions
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  include/environment/ti/boot.h | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
> index 4f3d748b5c..f2d91f5298 100644
> --- a/include/environment/ti/boot.h
> +++ b/include/environment/ti/boot.h
> @@ -26,13 +26,14 @@
>         "uuid_disk=${uuid_gpt_disk};" \
>         "name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
>         "name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
> -       "name=environment,size=128K,uuid=${uuid_gpt_environment};" \
> -       "name=misc,size=128K,uuid=${uuid_gpt_misc};" \
> -       "name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
> +       "name=hole,size=256K,uuid=${uuid_gpt_hole};" \
> +       "name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
> +       "name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
> +       "name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
>         "name=efs,size=16M,uuid=${uuid_gpt_efs};" \
>         "name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
>         "name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
> -       "name=boot,size=10M,uuid=${uuid_gpt_boot};" \
> +       "name=boot,size=20M,uuid=${uuid_gpt_boot};" \
>         "name=system,size=768M,uuid=${uuid_gpt_system};" \
>         "name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
>         "name=cache,size=256M,uuid=${uuid_gpt_cache};" \
> @@ -66,8 +67,8 @@
>                 "setenv machid fe6; " \
>                 "mmc dev $mmcdev; " \
>                 "mmc rescan; " \
> -               "part start mmc ${mmcdev} environment fdt_start; " \
> -               "part size mmc ${mmcdev} environment fdt_size; " \
> +               "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}; " \
> --
> 2.17.0
>

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

Patch

diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
index 4f3d748b5c..f2d91f5298 100644
--- a/include/environment/ti/boot.h
+++ b/include/environment/ti/boot.h
@@ -26,13 +26,14 @@ 
 	"uuid_disk=${uuid_gpt_disk};" \
 	"name=xloader,start=128K,size=256K,uuid=${uuid_gpt_xloader};" \
 	"name=bootloader,size=1792K,uuid=${uuid_gpt_bootloader};" \
-	"name=environment,size=128K,uuid=${uuid_gpt_environment};" \
-	"name=misc,size=128K,uuid=${uuid_gpt_misc};" \
-	"name=reserved,size=256K,uuid=${uuid_gpt_reserved};" \
+	"name=hole,size=256K,uuid=${uuid_gpt_hole};" \
+	"name=uenv,size=256K,uuid=${uuid_gpt_uenv};" \
+	"name=dtb,size=1M,uuid=${uuid_gpt_dtb};" \
+	"name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};" \
 	"name=efs,size=16M,uuid=${uuid_gpt_efs};" \
 	"name=crypto,size=16K,uuid=${uuid_gpt_crypto};" \
 	"name=recovery,size=40M,uuid=${uuid_gpt_recovery};" \
-	"name=boot,size=10M,uuid=${uuid_gpt_boot};" \
+	"name=boot,size=20M,uuid=${uuid_gpt_boot};" \
 	"name=system,size=768M,uuid=${uuid_gpt_system};" \
 	"name=vendor,size=256M,uuid=${uuid_gpt_vendor};" \
 	"name=cache,size=256M,uuid=${uuid_gpt_cache};" \
@@ -66,8 +67,8 @@ 
 		"setenv machid fe6; " \
 		"mmc dev $mmcdev; " \
 		"mmc rescan; " \
-		"part start mmc ${mmcdev} environment fdt_start; " \
-		"part size mmc ${mmcdev} environment fdt_size; " \
+		"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}; " \