From patchwork Mon May 30 16:51:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 627888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rJN2b6rBgz9sBf for ; Tue, 31 May 2016 02:52:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b=JFFM7neH; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 614E1A74D6; Mon, 30 May 2016 18:52:21 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ePdCGMWj4R3p; Mon, 30 May 2016 18:52:20 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5B959A74BA; Mon, 30 May 2016 18:52:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D0F0A74BA for ; Mon, 30 May 2016 18:52:15 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w_HhtbeKhye7 for ; Mon, 30 May 2016 18:52:15 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) by theia.denx.de (Postfix) with ESMTPS id B7C4EA7498 for ; Mon, 30 May 2016 18:52:10 +0200 (CEST) Received: by mail-pf0-f177.google.com with SMTP id b124so65996982pfb.0 for ; Mon, 30 May 2016 09:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=UrRBDBRKqBr8JWI2Hl59gpX29moNRY57YXE4gbe4YFg=; b=JFFM7neHLfVvKFN1OU++Qilpn5yeW39+Q3b/5t5AvY6wKo7eHvki6/1nqLtw6k8tSk pslgO2DuNQGUwUh6qyWWdvuuyS6xLgewx+Spp8qdR/yCKGvM8LDiul5E67KJjHHbvkZz vYn/2xPnfwCF3TwmmWzMjmUfjc7HXeo0U2tEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UrRBDBRKqBr8JWI2Hl59gpX29moNRY57YXE4gbe4YFg=; b=kfIYC70vhc20QZfHi1VVf48AvtVW5EYLSJEeZrNlCh1liuy5ofO1VgAC3A3vehjl3H UBDNyr1jKSrlZ+Po3f7vZtgVH0qO5qZ76MXTvHRKRcJ0gZvLlgysRrOEOpxYIN/01Fs/ WVGERIDJNrTLeRQILdIi6bHTzmreTVjou/gyQ8UwWQAZBs6k+ZN2s2n3eFHRpcFs8DuU ylcvLq9batDhJxEOHIFTLXi19lGBXmFIoAY25mj8yaMtSUWzEvL8XG+LAMzqsVYvInX7 3Qdi5bpg+FP7CNqd/maGoKmLHaxHLx2mt8pqHFSrd/xSDMBNpHhJO08GubUOPapuItsX CalQ== X-Gm-Message-State: ALyK8tIj2MHa/r+D4sz3uIXxTptavDEr+W9n7cEP+faJ21oCLdxl6+9924/VT66lnqGxY8Vv X-Received: by 10.98.67.7 with SMTP id q7mr48080122pfa.70.1464627128221; Mon, 30 May 2016 09:52:08 -0700 (PDT) Received: from VM-host64-64-A1.ric.broadcom.com ([216.31.219.19]) by smtp.gmail.com with ESMTPSA id j3sm14686556pfk.94.2016.05.30.09.52.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 09:52:07 -0700 (PDT) From: Steve Rae To: u-boot@lists.denx.de Date: Mon, 30 May 2016 09:51:22 -0700 Message-Id: <1464627083-12301-1-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 Cc: Steve Rae , Tom Rini , Andre Przywara Subject: [U-Boot] [PATCH v3] arm64: arm: implement a boot header capability X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Andre Przywara 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 preprocessor commands might be: .space 1000 .word 0x12345678 etc. 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. Signed-off-by: Andre Przywara Signed-off-by: Steve Rae [1] https://github.com/apritzel/pine64/tree/master/tools Commit Notes: - [v3] also updated the subject and the original commit messaage END --- Changes in v3: ( v3 submitted by: Steve Rae at the request of: Andre Przywara ) - changed from just reserving space (with the .space command) to executing the assembler preprocessor commands Changes in v2: ( by: Andre Przywara ) Changes in v1: ( by: Andre Przywara ) arch/arm/cpu/armv8/start.S | 4 ++++ arch/arm/lib/vectors.S | 4 ++++ board/sunxi/Kconfig | 7 +++++++ configs/pine64_plus_defconfig | 1 + include/configs/bcm28155_ap.h | 4 ++++ include/configs/sun50i.h | 5 +++++ 6 files changed, 25 insertions(+) diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S index e933021..9202889 100644 --- a/arch/arm/cpu/armv8/start.S +++ b/arch/arm/cpu/armv8/start.S @@ -21,6 +21,10 @@ _start: b reset +#ifdef CONFIG_BOOT0_CODE +CONFIG_BOOT0_CODE +#endif + .align 3 .globl _TEXT_BASE diff --git a/arch/arm/lib/vectors.S b/arch/arm/lib/vectors.S index 49238ed..5dcfab5 100644 --- a/arch/arm/lib/vectors.S +++ b/arch/arm/lib/vectors.S @@ -60,6 +60,10 @@ _start: ldr pc, _irq ldr pc, _fiq +#ifdef CONFIG_BOOT0_CODE +CONFIG_BOOT0_CODE +#endif + /* ************************************************************************* * diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index c1ae6f5..d2678c9 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 489b75c..ef96dab 100644 --- a/configs/pine64_plus_defconfig +++ b/configs/pine64_plus_defconfig @@ -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_SUNXI_BOOT0=y diff --git a/include/configs/bcm28155_ap.h b/include/configs/bcm28155_ap.h index 889e5db..515552b 100644 --- a/include/configs/bcm28155_ap.h +++ b/include/configs/bcm28155_ap.h @@ -137,4 +137,8 @@ #define CONFIG_USB_GADGET_BCM_UDC_OTG_PHY #define CONFIG_USBID_ADDR 0x34052c46 +#define CONFIG_BOOT0_CODE \ + .word 0xbabeface; \ + .word _end - _start + #endif /* __BCM28155_AP_H */ diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h index 0fdb4c7..fe9624b 100644 --- a/include/configs/sun50i.h +++ b/include/configs/sun50i.h @@ -17,6 +17,11 @@ #define GICD_BASE 0x1c81000 #define GICC_BASE 0x1c82000 +#ifdef CONFIG_SUNXI_BOOT0 +#define CONFIG_BOOT0_CODE \ + .space 1532 +#endif + /* * Include common sunxi configuration where most the settings are */