From patchwork Thu Sep 17 16:52:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Nortmann X-Patchwork-Id: 518967 X-Patchwork-Delegate: hdegoede@redhat.com 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 E343A141869 for ; Fri, 18 Sep 2015 02:53:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 33DAE4B7DF; Thu, 17 Sep 2015 18:53:40 +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 KYwzwdM4uczG; Thu, 17 Sep 2015 18:53:40 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 367D74B7ED; Thu, 17 Sep 2015 18:53:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1A4D44B7EB for ; Thu, 17 Sep 2015 18:53:11 +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 4H8aIT60fxyy for ; Thu, 17 Sep 2015 18:53:10 +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 mout.web.de (mout.web.de [212.227.15.3]) by theia.denx.de (Postfix) with ESMTPS id 9FAD54B7DF for ; Thu, 17 Sep 2015 18:53:06 +0200 (CEST) Received: from olymp.nortmann.local ([79.244.53.105]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0M6mgu-1YiKPe1VI4-00wWDA; Thu, 17 Sep 2015 18:53:06 +0200 From: Bernhard Nortmann To: u-boot@lists.denx.de Date: Thu, 17 Sep 2015 18:52:51 +0200 Message-Id: <1442508773-29993-3-git-send-email-bernhard.nortmann@web.de> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1442508773-29993-1-git-send-email-bernhard.nortmann@web.de> References: <1442508773-29993-1-git-send-email-bernhard.nortmann@web.de> X-Provags-ID: V03:K0:my1vKmFJsQQNUMXXT5gEOmZYOTWWOX9iACykFNbKKbN3ex/dIoq MxN+e9lLFaKTpBnXdupx9oJa+V5zVgxWMflhjZeluLX9T9srp9Q6uWLBj0F2bChvdyH6XlL 1DiynwoFx7YOoyp9XAMIwylIDO8ipNtgdv75pDwLB7qVjlvQQRDPlUBdIVbIfQtZxqZD/Xa 7P0AGsDR4nlfC7jRVAbxQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:2E2Dk9MHRRQ=:NhvaLzo25FknQCoa38PcWH 2wPVdeDeBaMjJaGVDif2IcrAF54SRQdcRtFONMpv7GY4T8OSOaaeCKYFGgs/LjQnaT/pND8mL vOW1jH+UAlCznIV3mTnLS0vUFxwi6O0JnNNB8TyQ2g6L5RiK/fDiRmyypPC8jgb/YoTuTuZ1K 15xRi1zce6g1JH+ykQXgMGdC6Gccgobngc/9fkvCvGerP39qK5Y17sQtjfaBCQRszJgOlMJNE Mk4wogJpKd6IzROnzwpzrg+BjEpz6rlKFEXEcx1WYM9lzQ2WmV3kU6EiXiVbLuX5D8ImqL+sI 9y07Xm9ShJZoiyCGCPi7JG4N6vUDrmhft/0sWXcmmiG1blbNp1dGKGAJbdialXs8f4iWuYaZt jAHfyB84UZOAWunKtWtiQAzifdNvqJApJFr51ecAfrnrLvqUeRc8C2ikSGEUFRgRWqD8HAcF7 uTLrhOnDhP+K7WBoQQcO/bzwMAXqBLbtHuYogN19KEHPFxOXdQZ+n4lDQdZQAF2saSRICINs2 PNuIEjJNeccbNo1oGXj9m3zrutunyCkBn4E4SuyqwL+gFfXX9GMelS7anKClbHzD/NJE/t31e SIv34YU/Eyy8OqlkynmNs9a+lMJNLsHAcCTkryTFca9NxoHL8wUcp6zU17MxfKU3+Cadv/Kui IhKfWAyT0t0NsBuqzdn3Dfh8j8OIMSCR6xL+OVfIIUvpJhjZGPdrFQxCWh7TsbcfdVr5GRv9x uT7I8ETeNX+/qkgh Cc: Tom Rini , Roy Spliet , =?UTF-8?q?Daniel=20Kochma=C5=84ski?= , Ian Campbell , Ian Campbell , Bernhard Nortmann Subject: [U-Boot] [PATCH v3 2/4] sunxi: (mksunxiboot) signature to indicate "sunxi" SPL variant 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" This patch follows up on a discussion of ways to improve support for the sunxi FEL ("USB boot") mechanism, especially with regard to boot scripts, see: https://groups.google.com/d/msg/linux-sunxi/wBEGUoLNRro/rHGq6nSYCQAJ The idea is to convert the (currently unused) "pad" bytes in the SPL header into an area where data can be passed to U-Boot. To do this safely, we have to make sure that we're actually using our "sunxi" flavor of the SPL, and not the Allwinner boot0. The modified mksunxiboot introduces a special signature to the SPL header in place of the "pub_head_size" field. This can be used to reliably distinguish between compatible versions of sunxi SPL and anything else (older variants or Allwinner's boot0). Signed-off-by: Bernhard Nortmann --- Changes in v3: - adapted to use asm/arch/spl.h Changes in v2: - Rename field to fel_script_address, discard fel_data_size - Clearing header fields is no longer needed, as mksunxiboot.c zeroes entire image first arch/arm/include/asm/arch-sunxi/spl.h | 19 ++++++++++++++++++- tools/mksunxiboot.c | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h index 751de75..08fe32d 100644 --- a/arch/arm/include/asm/arch-sunxi/spl.h +++ b/arch/arm/include/asm/arch-sunxi/spl.h @@ -10,6 +10,8 @@ #define _ASM_ARCH_SPL_H_ #define BOOT0_MAGIC "eGON.BT0" +#define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */ +#define SPL_HEADER_VERSION 1 /* boot head definition from sun4i boot code */ struct boot_file_head { @@ -22,8 +24,23 @@ struct boot_file_head { * by the boot ROM. To be compatible with Allwinner tools we * would need to implement the proper fields here instead of * padding. + * + * Actually we want the ability to recognize our "sunxi" variant + * of the SPL. To do so, let's place a special signature into the + * "pub_head_size" field. We can reasonably expect Allwinner's + * boot0 to always have the upper 16 bits of this set to 0 (after + * all the value shouldn't be larger than the limit imposed by + * SRAM size). + * If the signature is present (at 0x14), then we know it's safe + * to use the remaining 8 bytes (at 0x18) for our own purposes. + * (E.g. sunxi-tools "fel" utility can pass information there.) */ - uint8_t pad[12]; /* align to 32 bytes */ + union { + uint32_t pub_head_size; + uint8_t spl_signature[4]; + }; + uint32_t fel_script_address; + uint32_t reserved; /* padding, align to 32 bytes */ }; #endif diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c index 54f4d05..9c1c5b7 100644 --- a/tools/mksunxiboot.c +++ b/tools/mksunxiboot.c @@ -118,6 +118,10 @@ int main(int argc, char *argv[]) ALIGN(file_size + sizeof(struct boot_file_head), BLOCK_SIZE); img.header.b_instruction = cpu_to_le32(img.header.b_instruction); img.header.length = cpu_to_le32(img.header.length); + + memcpy(img.header.spl_signature, SPL_SIGNATURE, 3); /* "sunxi" marker */ + img.header.spl_signature[3] = SPL_HEADER_VERSION; + gen_check_sum(&img.header); count = write(fd_out, &img, le32_to_cpu(img.header.length));