diff mbox

[U-Boot,v2] arm64: allow space reservation for boot header

Message ID 1464165626-16564-1-git-send-email-andre.przywara@arm.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Andre Przywara May 25, 2016, 8:40 a.m. UTC
Some SPL loaders (like Allwinner's boot0) require a header before the
actual U-Boot binary to both check its validity and to find other data
to load.
Introduce a config option to reserve some space at the beginning of the
binary to later hold the header if needed.
Please note that the current arm64 start.S jumps over some portion of
data already, so this option bascially just increases this region
to allow post-processing tools to insert more data there.
This also means that both filling the header is optional and also having
some extra space in there does not hurt apart from enlarging the binary.

For the use with Allwinner's boot0 blob there is a tool called
boot0img[1], which fills the header to allow booting A64 based boards.
For the Pine64 we need a 1536 Byte header (including the branch
instruction) at the moment, so we add this to the defconfig.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>

[1] https://github.com/apritzel/pine64/tree/master/tools
---
 arch/arm/cpu/armv8/start.S    | 3 +++
 board/sunxi/Kconfig           | 7 +++++++
 configs/pine64_plus_defconfig | 1 +
 include/configs/sun50i.h      | 4 ++++
 4 files changed, 15 insertions(+)

Comments

Hans de Goede May 25, 2016, 8:48 a.m. UTC | #1
Hi,

On 25-05-16 10:40, Andre Przywara wrote:
> Some SPL loaders (like Allwinner's boot0) require a header before the
> actual U-Boot binary to both check its validity and to find other data
> to load.
> Introduce a config option to reserve some space at the beginning of the
> binary to later hold the header if needed.
> Please note that the current arm64 start.S jumps over some portion of
> data already, so this option bascially just increases this region
> to allow post-processing tools to insert more data there.
> This also means that both filling the header is optional and also having
> some extra space in there does not hurt apart from enlarging the binary.
>
> For the use with Allwinner's boot0 blob there is a tool called
> boot0img[1], which fills the header to allow booting A64 based boards.
> For the Pine64 we need a 1536 Byte header (including the branch
> instruction) at the moment, so we add this to the defconfig.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>
> [1] https://github.com/apritzel/pine64/tree/master/tools

v2 looks good to me:

Acked-by: Hans de Goede <hdegoede@redhat.com>

Tom, can you pick this one up please (I'm asking you since it is
touching some non sunxi files) ?

Regards,

Hans


> ---
>  arch/arm/cpu/armv8/start.S    | 3 +++
>  board/sunxi/Kconfig           | 7 +++++++
>  configs/pine64_plus_defconfig | 1 +
>  include/configs/sun50i.h      | 4 ++++
>  4 files changed, 15 insertions(+)
>
> diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
> index e933021..a9cd7e9 100644
> --- a/arch/arm/cpu/armv8/start.S
> +++ b/arch/arm/cpu/armv8/start.S
> @@ -21,6 +21,9 @@
>  _start:
>  	b	reset
>
> +#ifdef CONFIG_START_HEADER_SPACE
> +	.space CONFIG_START_HEADER_SPACE /* can be filled with a boot0 header */
> +#endif
>  	.align 3
>
>  .globl	_TEXT_BASE
> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> index fa78720..9f2e17e 100644
> --- a/board/sunxi/Kconfig
> +++ b/board/sunxi/Kconfig
> @@ -15,6 +15,13 @@ config SUNXI_GEN_SUN6I
>  	separate ahb reset control registers, custom pmic bus, new style
>  	watchdog, etc.
>
> +config SUNXI_BOOT0
> +	bool "prepare for boot0 header"
> +	---help---
> +	If U-Boot is loaded from the Allwinner provided boot0 blob, it
> +	expects a header area filled with magic values.
> +	This option will add some space at the beginning of the image to
> +	let a tool later on fill in this header with sensible data.
>
>  choice
>  	prompt "Sunxi SoC Variant"
> diff --git a/configs/pine64_plus_defconfig b/configs/pine64_plus_defconfig
> index 0977334..b93e4da 100644
> --- a/configs/pine64_plus_defconfig
> +++ b/configs/pine64_plus_defconfig
> @@ -18,3 +18,4 @@ CONFIG_CMD_EXT2=y
>  CONFIG_CMD_EXT4=y
>  CONFIG_CMD_FAT=y
>  CONFIG_CMD_FS_GENERIC=y
> +CONFIG_SUNXI_BOOT0=y
> diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h
> index 0fdb4c7..6923b60 100644
> --- a/include/configs/sun50i.h
> +++ b/include/configs/sun50i.h
> @@ -17,6 +17,10 @@
>  #define GICD_BASE		0x1c81000
>  #define GICC_BASE		0x1c82000
>
> +#ifdef CONFIG_SUNXI_BOOT0
> +#define CONFIG_START_HEADER_SPACE	1532
> +#endif
> +
>  /*
>   * Include common sunxi configuration where most the settings are
>   */
>
Steve Rae May 25, 2016, 4:15 p.m. UTC | #2
Hi,

On Wed, May 25, 2016 at 1:48 AM, Hans de Goede <hdegoede@redhat.com> wrote:

> Hi,
>
> On 25-05-16 10:40, Andre Przywara wrote:
>
>> Some SPL loaders (like Allwinner's boot0) require a header before the
>> actual U-Boot binary to both check its validity and to find other data
>> to load.
>> Introduce a config option to reserve some space at the beginning of the
>> binary to later hold the header if needed.
>> Please note that the current arm64 start.S jumps over some portion of
>> data already, so this option bascially just increases this region
>> to allow post-processing tools to insert more data there.
>> This also means that both filling the header is optional and also having
>> some extra space in there does not hurt apart from enlarging the binary.
>>
>> For the use with Allwinner's boot0 blob there is a tool called
>> boot0img[1], which fills the header to allow booting A64 based boards.
>> For the Pine64 we need a 1536 Byte header (including the branch
>> instruction) at the moment, so we add this to the defconfig.
>>
>> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
>>
>> [1] https://github.com/apritzel/pine64/tree/master/tools
>>
>
> v2 looks good to me:
>
> Acked-by: Hans de Goede <hdegoede@redhat.com>
>
> Tom, can you pick this one up please (I'm asking you since it is
> touching some non sunxi files) ?
>
> Regards,
>
> Hans
>
>
>
> ---
>>  arch/arm/cpu/armv8/start.S    | 3 +++
>>  board/sunxi/Kconfig           | 7 +++++++
>>  configs/pine64_plus_defconfig | 1 +
>>  include/configs/sun50i.h      | 4 ++++
>>  4 files changed, 15 insertions(+)
>>
>> diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
>> index e933021..a9cd7e9 100644
>> --- a/arch/arm/cpu/armv8/start.S
>> +++ b/arch/arm/cpu/armv8/start.S
>> @@ -21,6 +21,9 @@
>>  _start:
>>         b       reset
>>
>> +#ifdef CONFIG_START_HEADER_SPACE
>> +       .space CONFIG_START_HEADER_SPACE /* can be filled with a boot0
>> header */
>> +#endif
>>         .align 3
>>
>>
Just wondering, is there any way to make this even more generic?
In your case, you are wanting
        .space 1532
But in my case I am actually wanting something like:
        .word   0x12345678
        .word   _end - _start
Thanks, Steve

 .globl _TEXT_BASE
>> diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>> index fa78720..9f2e17e 100644
>> --- a/board/sunxi/Kconfig
>> +++ b/board/sunxi/Kconfig
>> @@ -15,6 +15,13 @@ config SUNXI_GEN_SUN6I
>>         separate ahb reset control registers, custom pmic bus, new style
>>         watchdog, etc.
>>
>> +config SUNXI_BOOT0
>> +       bool "prepare for boot0 header"
>> +       ---help---
>> +       If U-Boot is loaded from the Allwinner provided boot0 blob, it
>> +       expects a header area filled with magic values.
>> +       This option will add some space at the beginning of the image to
>> +       let a tool later on fill in this header with sensible data.
>>
>>  choice
>>         prompt "Sunxi SoC Variant"
>> diff --git a/configs/pine64_plus_defconfig b/configs/pine64_plus_defconfig
>> index 0977334..b93e4da 100644
>> --- a/configs/pine64_plus_defconfig
>> +++ b/configs/pine64_plus_defconfig
>> @@ -18,3 +18,4 @@ CONFIG_CMD_EXT2=y
>>  CONFIG_CMD_EXT4=y
>>  CONFIG_CMD_FAT=y
>>  CONFIG_CMD_FS_GENERIC=y
>> +CONFIG_SUNXI_BOOT0=y
>> diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h
>> index 0fdb4c7..6923b60 100644
>> --- a/include/configs/sun50i.h
>> +++ b/include/configs/sun50i.h
>> @@ -17,6 +17,10 @@
>>  #define GICD_BASE              0x1c81000
>>  #define GICC_BASE              0x1c82000
>>
>> +#ifdef CONFIG_SUNXI_BOOT0
>> +#define CONFIG_START_HEADER_SPACE      1532
>> +#endif
>> +
>>  /*
>>   * Include common sunxi configuration where most the settings are
>>   */
>>
>>
Andre Przywara May 25, 2016, 4:50 p.m. UTC | #3
Hi,

On 25/05/16 17:15, Steve Rae wrote:
> Hi,
> 
> On Wed, May 25, 2016 at 1:48 AM, Hans de Goede <hdegoede@redhat.com
> <mailto:hdegoede@redhat.com>> wrote:
> 
>     Hi,
> 
>     On 25-05-16 10:40, Andre Przywara wrote:
> 
>         Some SPL loaders (like Allwinner's boot0) require a header
>         before the
>         actual U-Boot binary to both check its validity and to find
>         other data
>         to load.
>         Introduce a config option to reserve some space at the beginning
>         of the
>         binary to later hold the header if needed.
>         Please note that the current arm64 start.S jumps over some
>         portion of
>         data already, so this option bascially just increases this region
>         to allow post-processing tools to insert more data there.
>         This also means that both filling the header is optional and
>         also having
>         some extra space in there does not hurt apart from enlarging the
>         binary.
> 
>         For the use with Allwinner's boot0 blob there is a tool called
>         boot0img[1], which fills the header to allow booting A64 based
>         boards.
>         For the Pine64 we need a 1536 Byte header (including the branch
>         instruction) at the moment, so we add this to the defconfig.
> 
>         Signed-off-by: Andre Przywara <andre.przywara@arm.com
>         <mailto:andre.przywara@arm.com>>
> 
>         [1] https://github.com/apritzel/pine64/tree/master/tools
> 
> 
>     v2 looks good to me:
> 
>     Acked-by: Hans de Goede <hdegoede@redhat.com
>     <mailto:hdegoede@redhat.com>>
> 
>     Tom, can you pick this one up please (I'm asking you since it is
>     touching some non sunxi files) ?
> 
>     Regards,
> 
>     Hans
> 
> 
> 
>         ---
>          arch/arm/cpu/armv8/start.S    | 3 +++
>          board/sunxi/Kconfig           | 7 +++++++
>          configs/pine64_plus_defconfig | 1 +
>          include/configs/sun50i.h      | 4 ++++
>          4 files changed, 15 insertions(+)
> 
>         diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
>         index e933021..a9cd7e9 100644
>         --- a/arch/arm/cpu/armv8/start.S
>         +++ b/arch/arm/cpu/armv8/start.S
>         @@ -21,6 +21,9 @@
>          _start:
>                 b       reset
> 
>         +#ifdef CONFIG_START_HEADER_SPACE
>         +       .space CONFIG_START_HEADER_SPACE /* can be filled with a
>         boot0 header */
>         +#endif
>                 .align 3
> 
> 
> Just wondering, is there any way to make this even more generic?
> In your case, you are wanting
>         .space 1532
> But in my case I am actually wanting something like:
>         .word   0x12345678
>         .word   _end - _start
> Thanks, Steve

I don't think we should go down that rabbit hole. Mainline U-Boot just
provides the space for it, and you have a post-processing tool that
fills it. This is what we do for Allwinner's boot0 (which includes
magics, checksums, sizes, load address, etc.) You could even include
this tool in the build process, similar to mkimage calls.

Or if you like, feel free to send a patch which shows how you imagine that.

Cheers,
Andre.

> 
>          .globl _TEXT_BASE
>         diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>         index fa78720..9f2e17e 100644
>         --- a/board/sunxi/Kconfig
>         +++ b/board/sunxi/Kconfig
>         @@ -15,6 +15,13 @@ config SUNXI_GEN_SUN6I
>                 separate ahb reset control registers, custom pmic bus,
>         new style
>                 watchdog, etc.
> 
>         +config SUNXI_BOOT0
>         +       bool "prepare for boot0 header"
>         +       ---help---
>         +       If U-Boot is loaded from the Allwinner provided boot0
>         blob, it
>         +       expects a header area filled with magic values.
>         +       This option will add some space at the beginning of the
>         image to
>         +       let a tool later on fill in this header with sensible data.
> 
>          choice
>                 prompt "Sunxi SoC Variant"
>         diff --git a/configs/pine64_plus_defconfig
>         b/configs/pine64_plus_defconfig
>         index 0977334..b93e4da 100644
>         --- a/configs/pine64_plus_defconfig
>         +++ b/configs/pine64_plus_defconfig
>         @@ -18,3 +18,4 @@ CONFIG_CMD_EXT2=y
>          CONFIG_CMD_EXT4=y
>          CONFIG_CMD_FAT=y
>          CONFIG_CMD_FS_GENERIC=y
>         +CONFIG_SUNXI_BOOT0=y
>         diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h
>         index 0fdb4c7..6923b60 100644
>         --- a/include/configs/sun50i.h
>         +++ b/include/configs/sun50i.h
>         @@ -17,6 +17,10 @@
>          #define GICD_BASE              0x1c81000
>          #define GICC_BASE              0x1c82000
> 
>         +#ifdef CONFIG_SUNXI_BOOT0
>         +#define CONFIG_START_HEADER_SPACE      1532
>         +#endif
>         +
>          /*
>           * Include common sunxi configuration where most the settings are
>           */
> 
>
Steve Rae May 25, 2016, 4:56 p.m. UTC | #4
On Wed, May 25, 2016 at 9:50 AM, Andre Przywara <andre.przywara@arm.com>
wrote:

> Hi,
>
> On 25/05/16 17:15, Steve Rae wrote:
> > Hi,
> >
> > On Wed, May 25, 2016 at 1:48 AM, Hans de Goede <hdegoede@redhat.com
> > <mailto:hdegoede@redhat.com>> wrote:
> >
> >     Hi,
> >
> >     On 25-05-16 10:40, Andre Przywara wrote:
> >
> >         Some SPL loaders (like Allwinner's boot0) require a header
> >         before the
> >         actual U-Boot binary to both check its validity and to find
> >         other data
> >         to load.
> >         Introduce a config option to reserve some space at the beginning
> >         of the
> >         binary to later hold the header if needed.
> >         Please note that the current arm64 start.S jumps over some
> >         portion of
> >         data already, so this option bascially just increases this region
> >         to allow post-processing tools to insert more data there.
> >         This also means that both filling the header is optional and
> >         also having
> >         some extra space in there does not hurt apart from enlarging the
> >         binary.
> >
> >         For the use with Allwinner's boot0 blob there is a tool called
> >         boot0img[1], which fills the header to allow booting A64 based
> >         boards.
> >         For the Pine64 we need a 1536 Byte header (including the branch
> >         instruction) at the moment, so we add this to the defconfig.
> >
> >         Signed-off-by: Andre Przywara <andre.przywara@arm.com
> >         <mailto:andre.przywara@arm.com>>
> >
> >         [1] https://github.com/apritzel/pine64/tree/master/tools
> >
> >
> >     v2 looks good to me:
> >
> >     Acked-by: Hans de Goede <hdegoede@redhat.com
> >     <mailto:hdegoede@redhat.com>>
> >
> >     Tom, can you pick this one up please (I'm asking you since it is
> >     touching some non sunxi files) ?
> >
> >     Regards,
> >
> >     Hans
> >
> >
> >
> >         ---
> >          arch/arm/cpu/armv8/start.S    | 3 +++
> >          board/sunxi/Kconfig           | 7 +++++++
> >          configs/pine64_plus_defconfig | 1 +
> >          include/configs/sun50i.h      | 4 ++++
> >          4 files changed, 15 insertions(+)
> >
> >         diff --git a/arch/arm/cpu/armv8/start.S
> b/arch/arm/cpu/armv8/start.S
> >         index e933021..a9cd7e9 100644
> >         --- a/arch/arm/cpu/armv8/start.S
> >         +++ b/arch/arm/cpu/armv8/start.S
> >         @@ -21,6 +21,9 @@
> >          _start:
> >                 b       reset
> >
> >         +#ifdef CONFIG_START_HEADER_SPACE
> >         +       .space CONFIG_START_HEADER_SPACE /* can be filled with a
> >         boot0 header */
> >         +#endif
> >                 .align 3
> >
> >
> > Just wondering, is there any way to make this even more generic?
> > In your case, you are wanting
> >         .space 1532
> > But in my case I am actually wanting something like:
> >         .word   0x12345678
> >         .word   _end - _start
> > Thanks, Steve
>
> I don't think we should go down that rabbit hole. Mainline U-Boot just
> provides the space for it, and you have a post-processing tool that
> fills it. This is what we do for Allwinner's boot0 (which includes
> magics, checksums, sizes, load address, etc.) You could even include
> this tool in the build process, similar to mkimage calls.
>
> Or if you like, feel free to send a patch which shows how you imagine that.
>
> Cheers,
> Andre.
>
>
I agree that this _might_ be a rabbit hole, but the following is fairly
straightforward and seems to work:

+#ifdef CONFIG_BOOT0_CODE
+CONFIG_BOOT0_CODE
+#endif

( then elsewhere: )
+#define CONFIG_BOOT0_CODE      \
+       .word  0x12345678;     \
+       .word   _end - _start

And for your code:
+#define CONFIG_BOOT0_CODE      \
+       .space  1532

The "hint" is that these lines need to start with a tab, and need the
semi-colon to separate lines....
Would this work for you?
Thanks Steve

>
> >          .globl _TEXT_BASE
> >         diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
> >         index fa78720..9f2e17e 100644
> >         --- a/board/sunxi/Kconfig
> >         +++ b/board/sunxi/Kconfig
> >         @@ -15,6 +15,13 @@ config SUNXI_GEN_SUN6I
> >                 separate ahb reset control registers, custom pmic bus,
> >         new style
> >                 watchdog, etc.
> >
> >         +config SUNXI_BOOT0
> >         +       bool "prepare for boot0 header"
> >         +       ---help---
> >         +       If U-Boot is loaded from the Allwinner provided boot0
> >         blob, it
> >         +       expects a header area filled with magic values.
> >         +       This option will add some space at the beginning of the
> >         image to
> >         +       let a tool later on fill in this header with sensible
> data.
> >
> >          choice
> >                 prompt "Sunxi SoC Variant"
> >         diff --git a/configs/pine64_plus_defconfig
> >         b/configs/pine64_plus_defconfig
> >         index 0977334..b93e4da 100644
> >         --- a/configs/pine64_plus_defconfig
> >         +++ b/configs/pine64_plus_defconfig
> >         @@ -18,3 +18,4 @@ CONFIG_CMD_EXT2=y
> >          CONFIG_CMD_EXT4=y
> >          CONFIG_CMD_FAT=y
> >          CONFIG_CMD_FS_GENERIC=y
> >         +CONFIG_SUNXI_BOOT0=y
> >         diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h
> >         index 0fdb4c7..6923b60 100644
> >         --- a/include/configs/sun50i.h
> >         +++ b/include/configs/sun50i.h
> >         @@ -17,6 +17,10 @@
> >          #define GICD_BASE              0x1c81000
> >          #define GICC_BASE              0x1c82000
> >
> >         +#ifdef CONFIG_SUNXI_BOOT0
> >         +#define CONFIG_START_HEADER_SPACE      1532
> >         +#endif
> >         +
> >          /*
> >           * Include common sunxi configuration where most the settings
> are
> >           */
> >
> >
>
Andre Przywara May 26, 2016, 9:49 a.m. UTC | #5
Hi Steve,

On 25/05/16 17:56, Steve Rae wrote:
> 
> 
> On Wed, May 25, 2016 at 9:50 AM, Andre Przywara <andre.przywara@arm.com
> <mailto:andre.przywara@arm.com>> wrote:
> 
>     Hi,
> 
>     On 25/05/16 17:15, Steve Rae wrote:
>     > Hi,
>     >
>     > On Wed, May 25, 2016 at 1:48 AM, Hans de Goede <hdegoede@redhat.com <mailto:hdegoede@redhat.com>
>     > <mailto:hdegoede@redhat.com <mailto:hdegoede@redhat.com>>> wrote:
>     >
>     >     Hi,
>     >
>     >     On 25-05-16 10:40, Andre Przywara wrote:
>     >
>     >         Some SPL loaders (like Allwinner's boot0) require a header
>     >         before the
>     >         actual U-Boot binary to both check its validity and to find
>     >         other data
>     >         to load.
>     >         Introduce a config option to reserve some space at the
>     beginning
>     >         of the
>     >         binary to later hold the header if needed.
>     >         Please note that the current arm64 start.S jumps over some
>     >         portion of
>     >         data already, so this option bascially just increases this
>     region
>     >         to allow post-processing tools to insert more data there.
>     >         This also means that both filling the header is optional and
>     >         also having
>     >         some extra space in there does not hurt apart from
>     enlarging the
>     >         binary.
>     >
>     >         For the use with Allwinner's boot0 blob there is a tool called
>     >         boot0img[1], which fills the header to allow booting A64 based
>     >         boards.
>     >         For the Pine64 we need a 1536 Byte header (including the
>     branch
>     >         instruction) at the moment, so we add this to the defconfig.
>     >
>     >         Signed-off-by: Andre Przywara <andre.przywara@arm.com
>     <mailto:andre.przywara@arm.com>
>     >         <mailto:andre.przywara@arm.com
>     <mailto:andre.przywara@arm.com>>>
>     >
>     >         [1] https://github.com/apritzel/pine64/tree/master/tools
>     >
>     >
>     >     v2 looks good to me:
>     >
>     >     Acked-by: Hans de Goede <hdegoede@redhat.com <mailto:hdegoede@redhat.com>
>     >     <mailto:hdegoede@redhat.com <mailto:hdegoede@redhat.com>>>
>     >
>     >     Tom, can you pick this one up please (I'm asking you since it is
>     >     touching some non sunxi files) ?
>     >
>     >     Regards,
>     >
>     >     Hans
>     >
>     >
>     >
>     >         ---
>     >          arch/arm/cpu/armv8/start.S    | 3 +++
>     >          board/sunxi/Kconfig           | 7 +++++++
>     >          configs/pine64_plus_defconfig | 1 +
>     >          include/configs/sun50i.h      | 4 ++++
>     >          4 files changed, 15 insertions(+)
>     >
>     >         diff --git a/arch/arm/cpu/armv8/start.S
>     b/arch/arm/cpu/armv8/start.S
>     >         index e933021..a9cd7e9 100644
>     >         --- a/arch/arm/cpu/armv8/start.S
>     >         +++ b/arch/arm/cpu/armv8/start.S
>     >         @@ -21,6 +21,9 @@
>     >          _start:
>     >                 b       reset
>     >
>     >         +#ifdef CONFIG_START_HEADER_SPACE
>     >         +       .space CONFIG_START_HEADER_SPACE /* can be filled
>     with a
>     >         boot0 header */
>     >         +#endif
>     >                 .align 3
>     >
>     >
>     > Just wondering, is there any way to make this even more generic?
>     > In your case, you are wanting
>     >         .space 1532
>     > But in my case I am actually wanting something like:
>     >         .word   0x12345678
>     >         .word   _end - _start
>     > Thanks, Steve
> 
>     I don't think we should go down that rabbit hole. Mainline U-Boot just
>     provides the space for it, and you have a post-processing tool that
>     fills it. This is what we do for Allwinner's boot0 (which includes
>     magics, checksums, sizes, load address, etc.) You could even include
>     this tool in the build process, similar to mkimage calls.
> 
>     Or if you like, feel free to send a patch which shows how you
>     imagine that.
> 
>     Cheers,
>     Andre.
> 
> 
> I agree that this _might_ be a rabbit hole, but the following is fairly
> straightforward and seems to work:
> 
> +#ifdef CONFIG_BOOT0_CODE
> +CONFIG_BOOT0_CODE
> +#endif
> 
> ( then elsewhere: )
> +#define CONFIG_BOOT0_CODE      \
> +       .word  0x12345678;     \
> +       .word   _end - _start
> 
> And for your code:
> +#define CONFIG_BOOT0_CODE      \
> +       .space  1532
> 
> The "hint" is that these lines need to start with a tab, and need the
> semi-colon to separate lines....
> Would this work for you?

Frankly: I don't like this so much, but also don't have a strong opinion
on this.

So if you like please make a proper patch and send it to the list.

Cheers,
Andre.

>     >
>     >          .globl _TEXT_BASE
>     >         diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
>     >         index fa78720..9f2e17e 100644
>     >         --- a/board/sunxi/Kconfig
>     >         +++ b/board/sunxi/Kconfig
>     >         @@ -15,6 +15,13 @@ config SUNXI_GEN_SUN6I
>     >                 separate ahb reset control registers, custom pmic bus,
>     >         new style
>     >                 watchdog, etc.
>     >
>     >         +config SUNXI_BOOT0
>     >         +       bool "prepare for boot0 header"
>     >         +       ---help---
>     >         +       If U-Boot is loaded from the Allwinner provided boot0
>     >         blob, it
>     >         +       expects a header area filled with magic values.
>     >         +       This option will add some space at the beginning
>     of the
>     >         image to
>     >         +       let a tool later on fill in this header with
>     sensible data.
>     >
>     >          choice
>     >                 prompt "Sunxi SoC Variant"
>     >         diff --git a/configs/pine64_plus_defconfig
>     >         b/configs/pine64_plus_defconfig
>     >         index 0977334..b93e4da 100644
>     >         --- a/configs/pine64_plus_defconfig
>     >         +++ b/configs/pine64_plus_defconfig
>     >         @@ -18,3 +18,4 @@ CONFIG_CMD_EXT2=y
>     >          CONFIG_CMD_EXT4=y
>     >          CONFIG_CMD_FAT=y
>     >          CONFIG_CMD_FS_GENERIC=y
>     >         +CONFIG_SUNXI_BOOT0=y
>     >         diff --git a/include/configs/sun50i.h
>     b/include/configs/sun50i.h
>     >         index 0fdb4c7..6923b60 100644
>     >         --- a/include/configs/sun50i.h
>     >         +++ b/include/configs/sun50i.h
>     >         @@ -17,6 +17,10 @@
>     >          #define GICD_BASE              0x1c81000
>     >          #define GICC_BASE              0x1c82000
>     >
>     >         +#ifdef CONFIG_SUNXI_BOOT0
>     >         +#define CONFIG_START_HEADER_SPACE      1532
>     >         +#endif
>     >         +
>     >          /*
>     >           * Include common sunxi configuration where most the
>     settings are
>     >           */
>     >
>     >
> 
>
diff mbox

Patch

diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index e933021..a9cd7e9 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -21,6 +21,9 @@ 
 _start:
 	b	reset
 
+#ifdef CONFIG_START_HEADER_SPACE
+	.space CONFIG_START_HEADER_SPACE /* can be filled with a boot0 header */
+#endif
 	.align 3
 
 .globl	_TEXT_BASE
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index fa78720..9f2e17e 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -15,6 +15,13 @@  config SUNXI_GEN_SUN6I
 	separate ahb reset control registers, custom pmic bus, new style
 	watchdog, etc.
 
+config SUNXI_BOOT0
+	bool "prepare for boot0 header"
+	---help---
+	If U-Boot is loaded from the Allwinner provided boot0 blob, it
+	expects a header area filled with magic values.
+	This option will add some space at the beginning of the image to
+	let a tool later on fill in this header with sensible data.
 
 choice
 	prompt "Sunxi SoC Variant"
diff --git a/configs/pine64_plus_defconfig b/configs/pine64_plus_defconfig
index 0977334..b93e4da 100644
--- a/configs/pine64_plus_defconfig
+++ b/configs/pine64_plus_defconfig
@@ -18,3 +18,4 @@  CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
+CONFIG_SUNXI_BOOT0=y
diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h
index 0fdb4c7..6923b60 100644
--- a/include/configs/sun50i.h
+++ b/include/configs/sun50i.h
@@ -17,6 +17,10 @@ 
 #define GICD_BASE		0x1c81000
 #define GICC_BASE		0x1c82000
 
+#ifdef CONFIG_SUNXI_BOOT0
+#define CONFIG_START_HEADER_SPACE	1532
+#endif
+
 /*
  * Include common sunxi configuration where most the settings are
  */