arm/arm64: implement a boot header capability
Subsystems (4)
PATCH v4 1/1 arm/arm64: implement a boot header capability
From: Andre Przywara <[email protected]>
Some SPL loaders (like Allwinner's boot0, and Broadcom's boot0) require a header before the actual U-Boot binary to both check its validity and to find other data to load. Sometimes this header may only be a few bytes of information, and sometimes this might simply be space that needs to be reserved for a post-processing tool.
Introduce a config option to allow assembler preprocessor commands to be inserted into the code at the appropriate location; typical assembler preprocessor commands might be:
.space 1000
.word 0x12345678
Commit Notes:
Please note that the current code:
start.S (arm64) and
vectors.S (arm)
already jumps over some portion of data already, so this option basically just increases the size of this region (and the resulting binary).
For 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.
[1] https://github.com/apritzel/pine64/tree/master/tools
END
---
Changes in v4:
as per Tom Rini <[email protected]>:
- move definitions out of the "include/configs/*" files
- rename definitions
and moved some of the commit message into commit notes.
Changes in v3:
( v3 submitted by: Steve Rae <[email protected]>
at the request of: Andre Przywara <[email protected]> )
- changed from just reserving space (with the .space command) to executing the assembler preprocessor commands
( also updated the subject and the original commit messaage )
Changes in v2:
( by: Andre Przywara <[email protected]> )
Changes in v1:
( by: Andre Przywara <[email protected]> )
arch/arm/Kconfig | 8 ++++++++ arch/arm/cpu/armv8/start.S | 10 ++++++++++ arch/arm/include/asm/arch-bcm281xx/boot0.h | 15 +++++++++++++++ arch/arm/include/asm/arch-sunxi/boot0.h | 14 ++++++++++++++ arch/arm/lib/vectors.S | 10 ++++++++++ configs/bcm28155_ap_defconfig | 1 + configs/bcm28155_w1d_defconfig | 1 + configs/pine64_plus_defconfig | 1 + 8 files changed, 60 insertions(+) create mode 100644 arch/arm/include/asm/arch-bcm281xx/boot0.h create mode 100644 arch/arm/include/asm/arch-sunxi/boot0.h
arch/arm/Kconfig +8 -0
@@ -77,6 +77,14 @@ config SYS_L2CACHE_OFF If SoC does not support L2CACHE or one do not want to enable L2CACHE, choose this option. +config ENABLE_ARM_SOC_BOOT0_HOOK + bool "prepare BOOT0 header" + help + If the SoC's BOOT0 requires a header area filled with (magic) + values, then choose this option, and create a define called + ARM_SOC_BOOT0_HOOK which contains the required assembler + preprocessor code. + choice prompt "Target select" default TARGET_HIKEY
arch/arm/cpu/armv8/start.S +10 -0
@@ -21,6 +21,16 @@ _start: b reset +#ifdef CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK +/* + * Various SoCs need something special and SoC-specific up front in + * order to boot, allow them to set that in their boot0.h file and then + * use it here. + */ +#include <asm/arch/boot0.h> +ARM_SOC_BOOT0_HOOK +#endif + .align 3 .globl _TEXT_BASE
arch/arm/include/asm/arch-bcm281xx/boot0.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright 2016 Broadcom Corporation. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __BOOT0_H +#define __BOOT0_H + +/* BOOT0 header information */ +#define ARM_SOC_BOOT0_HOOK \ + .word 0xbabeface; \ + .word _end - _start + +#endif /* __BOOT0_H */
arch/arm/include/asm/arch-sunxi/boot0.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* Configuration settings for the Allwinner A64 (sun50i) CPU +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef __BOOT0_H +#define __BOOT0_H + +/* reserve space for BOOT0 header information */ +#define ARM_SOC_BOOT0_HOOK \ + .space 1532 + +#endif /* __BOOT0_H */
arch/arm/lib/vectors.S +10 -0
@@ -60,6 +60,16 @@ _start: ldr pc, _irq ldr pc, _fiq +#ifdef CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK +/* + * Various SoCs need something special and SoC-specific up front in + * order to boot, allow them to set that in their boot0.h file and then + * use it here. + */ +#include <asm/arch/boot0.h> +ARM_SOC_BOOT0_HOOK +#endif + /* ************************************************************************* *
configs/bcm28155_ap_defconfig +1 -0
@@ -22,3 +22,4 @@ CONFIG_G_DNL_MANUFACTURER="Broadcom Corporation" CONFIG_G_DNL_VENDOR_NUM=0x18d1 CONFIG_G_DNL_PRODUCT_NUM=0x0d02 CONFIG_OF_LIBFDT=y +CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
configs/bcm28155_w1d_defconfig +1 -0
@@ -22,3 +22,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Broadcom Corporation" CONFIG_G_DNL_VENDOR_NUM=0x18d1 CONFIG_G_DNL_PRODUCT_NUM=0x0d02 +CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
configs/pine64_plus_defconfig +1 -0
@@ -9,3 +9,4 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus" # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set +CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
Signature · 1 line
1.8.5
PATCH v4 1/1 arm/arm64: implement a boot header capability
Quoted 23 lines · Steve Rae
From: Andre Przywara <[email protected]>
Some SPL loaders (like Allwinner's boot0, and Broadcom's boot0) require a header before the actual U-Boot binary to both check its validity and to find other data to load. Sometimes this header may only be a few bytes of information, and sometimes this might simply be space that needs to be reserved for a post-processing tool.
Introduce a config option to allow assembler preprocessor commands to be inserted into the code at the appropriate location; typical assembler preprocessor commands might be:
.space 1000
.word0x12345678Signed-off-by Andre Przywara <[email protected]>Signed-off-by Steve Rae <[email protected]>Commit Notes:
Please note that the current code:
start.S(arm64) and
vectors.S(arm)
already jumps over some portion of data already, so this option basically just increases the size of this region (and the resulting binary).
Quoted 8 lines
For 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.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160531/c01b8900/attachment.sig>
PATCH v4 1/1 arm/arm64: implement a boot header capability
In reply to Steve RaeQuoted 23 lines · Steve Rae
From: Andre Przywara <[email protected]>
Some SPL loaders (like Allwinner's boot0, and Broadcom's boot0) require a header before the actual U-Boot binary to both check its validity and to find other data to load. Sometimes this header may only be a few bytes of information, and sometimes this might simply be space that needs to be reserved for a post-processing tool.
Introduce a config option to allow assembler preprocessor commands to be inserted into the code at the appropriate location; typical assembler preprocessor commands might be:
.space 1000
.word0x12345678Signed-off-by Andre Przywara <[email protected]>Signed-off-by Steve Rae <[email protected]>Commit Notes:
Please note that the current code:
start.S(arm64) and
vectors.S(arm)
already jumps over some portion of data already, so this option basically just increases the size of this region (and the resulting binary).
Quoted 8 lines
For 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.
[1] https://github.com/apritzel/pine64/tree/master/tools
ENDReviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160606/f1077164/attachment.sig>