From patchwork Wed Jun 19 02:05:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1118416 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="bpMSfWwo"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45T7cd5YwDz9s7h for ; Wed, 19 Jun 2019 12:07:13 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 70CBEC2207A; Wed, 19 Jun 2019 02:06:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 51C06C2205F; Wed, 19 Jun 2019 02:05:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D9669C22027; Wed, 19 Jun 2019 02:05:34 +0000 (UTC) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30048.outbound.protection.outlook.com [40.107.3.48]) by lists.denx.de (Postfix) with ESMTPS id B4444C2204C for ; Wed, 19 Jun 2019 02:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hgLxShXb7Lo4NjSpyCGhO9BI4DAQOjn6iH5otRmBkIY=; b=bpMSfWwoFHMGh8LbaMATuqYqB4/lNjBXHivPb8NsgRO5ac9MxUOoWBaquqRQXxOkxYIcf8J3UpJB4CNvYPsOECMlrU6CeU7rZImLhqH3Wi0sBCxgrTQJQFSL+tRaL5TLWwl9a1wCV4Ydqhch4sh5rGB38haF5ujeJPlh+N7r5Fw= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5682.eurprd04.prod.outlook.com (20.178.202.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Wed, 19 Jun 2019 02:05:29 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015%3]) with mapi id 15.20.1987.014; Wed, 19 Jun 2019 02:05:29 +0000 From: Peng Fan To: "sbabic@denx.de" Thread-Topic: [PATCH V2 1/5] spl: Add function to get u-boot raw sector Thread-Index: AQHVJkN4kPO6YxVfAUKCYIlh1oxHLg== Date: Wed, 19 Jun 2019 02:05:29 +0000 Message-ID: <20190619021958.31790-2-peng.fan@nxp.com> References: <20190619021958.31790-1-peng.fan@nxp.com> In-Reply-To: <20190619021958.31790-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e4ecba23-f752-440c-0e61-08d6f45a9a65 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5682; x-ms-traffictypediagnostic: AM0PR04MB5682: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:164; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(396003)(39860400002)(199004)(189003)(25786009)(36756003)(6512007)(6116002)(52116002)(81156014)(7736002)(4326008)(6436002)(8676002)(1730700003)(81166006)(476003)(2616005)(86362001)(44832011)(486006)(3846002)(14454004)(54906003)(66556008)(6506007)(66446008)(66476007)(386003)(64756008)(73956011)(478600001)(6916009)(66946007)(2351001)(305945005)(71190400001)(102836004)(2501003)(316002)(446003)(8936002)(256004)(5640700003)(50226002)(6486002)(66066001)(2906002)(11346002)(71200400001)(53936002)(5660300002)(1076003)(99286004)(186003)(68736007)(26005)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5682; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: /+Ux4ip2J1MnqkGzM1D64IE4/+Ov9Dz4QqU3Pd/Di4zh1XI0CQ+uGiJMR1CDn2UrbQ0KJ1tjWJDIjA4YekQ1x8veyZYirnbfeZt47SZ2SFEgiaWGPNE0hxGjddC6RTbCE2xY3WFZnsX0OJ4A9rC4Ejx4m7EGjXlp+Sz86F3j1SXfAeZya8f0YS3WWJyd1PRPbiWtADEFbe6yW3nEL4cmsXVo0KUhNk4gWKA066orb7RFprjlgZGRjGOfEo8IXwxBpRYTiOHqmFFjaGwvNPlXwd6D/36A7j4gRGr9GualunhxUzdJhkWfc14wNvQNGkmvHejOVoQH1BuPxQ6NRfYxxIkorYCeARsb3G8uBbP1t8rS4oIQb5coisSJ+2yqI2y5svbBejudnvAVkl6fMMQYT/xmpyr3H9w2K1k75JKatAU= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e4ecba23-f752-440c-0e61-08d6f45a9a65 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2019 02:05:29.8499 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: peng.fan@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5682 Cc: Marek Vasut , Tien Fong Chee , "u-boot@lists.denx.de" , dl-uboot-imx , York Sun Subject: [U-Boot] [PATCH V2 1/5] spl: Add function to get u-boot raw sector X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a weak function spl_mmc_get_uboot_raw_sector to get u-boot raw sector. At default it returns CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR. Users can overwrite it to return customized offset. This is to support i.MX8 specific image type container image type. Cc: Tien Fong Chee Cc: Peng Fan Cc: Simon Goldschmidt Cc: York Sun Cc: Marek Vasut Cc: Alex Kiernan Signed-off-by: Peng Fan --- common/spl/spl_mmc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 324d91c884..bf53a1dadf 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -149,6 +149,13 @@ static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device) return 0; } +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR +unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc) +{ + return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR; +} +#endif + #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, struct mmc *mmc, int partition) @@ -181,7 +188,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR return mmc_load_image_raw_sector(spl_image, mmc, - info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); + info.start + spl_mmc_get_uboot_raw_sector(mmc)); #else return mmc_load_image_raw_sector(spl_image, mmc, info.start); #endif @@ -366,7 +373,7 @@ int spl_mmc_load_image(struct spl_image_info *spl_image, #endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR err = mmc_load_image_raw_sector(spl_image, mmc, - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); + spl_mmc_get_uboot_raw_sector(mmc)); if (!err) return err; #endif From patchwork Wed Jun 19 02:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1118414 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="VffCrTN5"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45T7bF4PN3z9sN6 for ; Wed, 19 Jun 2019 12:06:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 40271C2205C; Wed, 19 Jun 2019 02:05:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AEF7DC22036; Wed, 19 Jun 2019 02:05:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 51F03C22060; Wed, 19 Jun 2019 02:05:36 +0000 (UTC) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30083.outbound.protection.outlook.com [40.107.3.83]) by lists.denx.de (Postfix) with ESMTPS id 2FD6AC2205D for ; Wed, 19 Jun 2019 02:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nJ2adgsRLTcr1/LxeBzOZ9zSjm/uJz4InU2qiLSS7Bc=; b=VffCrTN5r6F3S3J5u87oJ6LO01hh0pqgy3cFDlBF3nvaCHt71PdrQ8wFbhC4OE6bxLusFlyvAP8NwFvzPwnqu/OoRkdo/Dos9Ajr8oOzd1wZSCl4Ex6kldswEPr/IBwlmEKlhRHK1mXIyDQCdUm7yJRt0LWDZS18EH5cn4zOpwA= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5682.eurprd04.prod.outlook.com (20.178.202.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Wed, 19 Jun 2019 02:05:32 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015%3]) with mapi id 15.20.1987.014; Wed, 19 Jun 2019 02:05:32 +0000 From: Peng Fan To: "sbabic@denx.de" Thread-Topic: [PATCH V2 2/5] imx8: support parsing i.MX8 Container file Thread-Index: AQHVJkN5/S8rvVaDekKJG2n9WpcKvA== Date: Wed, 19 Jun 2019 02:05:32 +0000 Message-ID: <20190619021958.31790-3-peng.fan@nxp.com> References: <20190619021958.31790-1-peng.fan@nxp.com> In-Reply-To: <20190619021958.31790-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 873c7d95-84d8-4ae3-704a-08d6f45a9be4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5682; x-ms-traffictypediagnostic: AM0PR04MB5682: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:138; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(396003)(39860400002)(199004)(189003)(25786009)(36756003)(6512007)(6116002)(52116002)(81156014)(7736002)(4326008)(6436002)(8676002)(1730700003)(81166006)(476003)(2616005)(86362001)(44832011)(486006)(3846002)(14454004)(54906003)(66556008)(6506007)(66446008)(66476007)(386003)(64756008)(73956011)(478600001)(6916009)(66946007)(2351001)(305945005)(71190400001)(102836004)(2501003)(316002)(446003)(8936002)(256004)(5640700003)(50226002)(6486002)(66066001)(2906002)(11346002)(71200400001)(53936002)(5660300002)(1076003)(99286004)(186003)(68736007)(26005)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5682; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Sgf9XQxLUJoCzN6sgeJijX81Q6nSmIa2lRs+wsQC6y4oABMKgj19A5pLgRD8hYGirC/bAF6Nj9op3zKwhcnHEVhYW5ZN5ALIn+GR0/5pdqlQzce5sJ+QDgaaEGJgVmxBOz4+Ym0mNsYg16FGoD5aCQxCJg6OH7lUdhWvjkCCUlTM1YUgh8dkSLDWJx3ULlm8bjKsftWE7UbwTjM9RINlCra47bxZGmoMlZ8Zs7hbI9IS0lTduqzgfYy8Z7F49h7rMz5mO1Ojt4ZYNAxv6n823JjHwRM1G91rgeC0DB+K//1RllXmRaRgV51sTMgLxQ6HgMRPP6f7d1lCGHouJcTBIXHXOfwjq5CIny4EahVjPyX2YmxDCewcRhjLOA/bz7H5GaKsPp2OOPfIjWGqQKFnweV8DCr7fPY1YBMs4ACFoyw= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 873c7d95-84d8-4ae3-704a-08d6f45a9be4 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2019 02:05:32.1945 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: peng.fan@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5682 Cc: "u-boot@lists.denx.de" , dl-uboot-imx Subject: [U-Boot] [PATCH V2 2/5] imx8: support parsing i.MX8 Container file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add parsing i.MX8 Container file support, this is to let SPL could load images in a container file to destination address. Signed-off-by: Peng Fan --- arch/arm/include/asm/arch-imx8/image.h | 56 +++++++++++++++ arch/arm/mach-imx/imx8/Kconfig | 6 ++ arch/arm/mach-imx/imx8/Makefile | 4 ++ arch/arm/mach-imx/imx8/parse-container.c | 120 +++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 arch/arm/include/asm/arch-imx8/image.h create mode 100644 arch/arm/mach-imx/imx8/parse-container.c diff --git a/arch/arm/include/asm/arch-imx8/image.h b/arch/arm/include/asm/arch-imx8/image.h new file mode 100644 index 0000000000..c1e5700859 --- /dev/null +++ b/arch/arm/include/asm/arch-imx8/image.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2018-2019 NXP + */ + +#ifndef __CONTAINER_HEADER_H_ +#define __CONTAINER_HEADER_H_ + +#include +#include + +#define IV_MAX_LEN 32 +#define HASH_MAX_LEN 64 + +#define CONTAINER_HDR_ALIGNMENT 0x400 +#define CONTAINER_HDR_EMMC_OFFSET 0 +#define CONTAINER_HDR_MMCSD_OFFSET SZ_32K +#define CONTAINER_HDR_QSPI_OFFSET SZ_4K +#define CONTAINER_HDR_NAND_OFFSET SZ_128M + +struct container_hdr { + u8 version; + u8 length_lsb; + u8 length_msb; + u8 tag; + u32 flags; + u16 sw_version; + u8 fuse_version; + u8 num_images; + u16 sig_blk_offset; + u16 reserved; +} __packed; + +struct boot_img_t { + u32 offset; + u32 size; + u64 dst; + u64 entry; + u32 hab_flags; + u32 meta; + u8 hash[HASH_MAX_LEN]; + u8 iv[IV_MAX_LEN]; +} __packed; + +struct signature_block_hdr { + u8 version; + u8 length_lsb; + u8 length_msb; + u8 tag; + u16 srk_table_offset; + u16 cert_offset; + u16 blob_offset; + u16 signature_offset; + u32 reserved; +} __packed; +#endif diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig index bbe323d5ca..e9496cb611 100644 --- a/arch/arm/mach-imx/imx8/Kconfig +++ b/arch/arm/mach-imx/imx8/Kconfig @@ -23,6 +23,12 @@ config IMX8QXP config SYS_SOC default "imx8" +config SPL_LOAD_IMX_CONTAINER + bool "Enable SPL loading U-Boot as a i.MX Container image" + depends on SPL + help + This is to let SPL could load i.MX8 Container image + choice prompt "i.MX8 board select" optional diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile index 31ad169ccf..19690110a5 100644 --- a/arch/arm/mach-imx/imx8/Makefile +++ b/arch/arm/mach-imx/imx8/Makefile @@ -5,3 +5,7 @@ # obj-y += cpu.o iomux.o + +ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_LOAD_IMX_CONTAINER) += parse-container.o +endif diff --git a/arch/arm/mach-imx/imx8/parse-container.c b/arch/arm/mach-imx/imx8/parse-container.c new file mode 100644 index 0000000000..32f78bdddf --- /dev/null +++ b/arch/arm/mach-imx/imx8/parse-container.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018-2019 NXP + */ + +#include +#include +#include +#include + +static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image, + struct spl_load_info *info, + struct container_hdr *container, + int image_index, + u32 container_sector) +{ + struct boot_img_t *images; + ulong sector; + u32 sectors; + + if (image_index > container->num_images) { + debug("Invalid image number\n"); + return NULL; + } + + images = (struct boot_img_t *)((u8 *)container + + sizeof(struct container_hdr)); + + if (images[image_index].offset % info->bl_len) { + printf("%s: image%d offset not aligned to %u\n", + __func__, image_index, info->bl_len); + return NULL; + } + + sectors = roundup(images[image_index].size, info->bl_len) / + info->bl_len; + sector = images[image_index].offset / info->bl_len + + container_sector; + + debug("%s: container: %p sector: %lu sectors: %u\n", __func__, + container, sector, sectors); + if (info->read(info, sector, sectors, + (void *)images[image_index].entry) != sectors) { + printf("%s wrong\n", __func__); + return NULL; + } + + return &images[image_index]; +} + +static int read_auth_container(struct spl_image_info *spl_image, + struct spl_load_info *info, ulong sector) +{ + struct container_hdr *container = NULL; + u16 length; + u32 sectors; + int i, size; + + size = roundup(CONTAINER_HDR_ALIGNMENT, info->bl_len); + sectors = size / info->bl_len; + + /* + * It will not override the ATF code, so safe to use it here, + * no need malloc + */ + container = (struct container_hdr *)spl_get_load_buffer(-size, size); + + debug("%s: container: %p sector: %lu sectors: %u\n", __func__, + container, sector, sectors); + if (info->read(info, sector, sectors, container) != sectors) + return -EIO; + + if (container->tag != 0x87 && container->version != 0x0) { + printf("Wrong container header"); + return -ENOENT; + } + + if (!container->num_images) { + printf("Wrong container, no image found"); + return -ENOENT; + } + + length = container->length_lsb + (container->length_msb << 8); + debug("Container length %u\n", length); + + if (length > CONTAINER_HDR_ALIGNMENT) { + size = roundup(length, info->bl_len); + sectors = size / info->bl_len; + + container = (struct container_hdr *)spl_get_load_buffer(-size, size); + + debug("%s: container: %p sector: %lu sectors: %u\n", + __func__, container, sector, sectors); + if (info->read(info, sector, sectors, container) != + sectors) + return -EIO; + } + + for (i = 0; i < container->num_images; i++) { + struct boot_img_t *image = read_auth_image(spl_image, info, + container, i, + sector); + + if (!image) + return -EINVAL; + + if (i == 0) { + spl_image->load_addr = image->dst; + spl_image->entry_point = image->entry; + } + } + + return 0; +} + +int spl_load_imx_container(struct spl_image_info *spl_image, + struct spl_load_info *info, ulong sector) +{ + return read_auth_container(spl_image, info, sector); +} From patchwork Wed Jun 19 02:05:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1118417 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="GaqJN/lw"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45T7d22Rydz9s4V for ; Wed, 19 Jun 2019 12:07:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 07176C22074; Wed, 19 Jun 2019 02:06:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0CC55C2204C; Wed, 19 Jun 2019 02:06:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2DE2EC22017; Wed, 19 Jun 2019 02:05:41 +0000 (UTC) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30077.outbound.protection.outlook.com [40.107.3.77]) by lists.denx.de (Postfix) with ESMTPS id F1562C22052 for ; Wed, 19 Jun 2019 02:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KLbNlnQr3YAqjcPgb6BfuwdByfjTCmy5KG8Fm4Sl3W8=; b=GaqJN/lwjogC7K9WTkRDYtYlreTcnFYB4hrCpxHb7oTeRyHqwLztXWpidTdxMK+3je9oF+3ZnjHgZ/mt989QsxNlZEJmkVLV+7ZoYXVlLV+/eyfMFXHTxRxZV+9Ei2CqdrDTAhbtwC0dlPMfp838s0xnVHc9r438ippq5VDmIsQ= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5682.eurprd04.prod.outlook.com (20.178.202.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Wed, 19 Jun 2019 02:05:37 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015%3]) with mapi id 15.20.1987.014; Wed, 19 Jun 2019 02:05:37 +0000 From: Peng Fan To: "sbabic@denx.de" Thread-Topic: [PATCH V2 3/5] spl: mmc: support loading i.MX container format file Thread-Index: AQHVJkN8Q23bxlUmO0+pZY5Y61K0pQ== Date: Wed, 19 Jun 2019 02:05:36 +0000 Message-ID: <20190619021958.31790-4-peng.fan@nxp.com> References: <20190619021958.31790-1-peng.fan@nxp.com> In-Reply-To: <20190619021958.31790-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c77a9e5a-e168-47c8-e586-08d6f45a9eae x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5682; x-ms-traffictypediagnostic: AM0PR04MB5682: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(396003)(39860400002)(199004)(189003)(25786009)(36756003)(6512007)(6116002)(52116002)(81156014)(7736002)(4326008)(6436002)(8676002)(1730700003)(81166006)(476003)(2616005)(86362001)(44832011)(486006)(3846002)(14454004)(54906003)(66556008)(6506007)(66446008)(66476007)(386003)(64756008)(73956011)(478600001)(6916009)(66946007)(2351001)(305945005)(71190400001)(102836004)(2501003)(316002)(446003)(8936002)(256004)(5640700003)(50226002)(6486002)(66066001)(2906002)(11346002)(71200400001)(7416002)(53936002)(5660300002)(1076003)(99286004)(186003)(68736007)(26005)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5682; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Ng94OBzXoYFYJIqrDYKqAxckTihqYzEWVoRae9mUNPMBbXLD/Vy+VSDTjmBjNpr7sO9SrbuLvfcSKVrVQfuMItFxAyYQeCkoq/m6NK2ngvF4WmJ8wSWpKJCpPcKbzIFwRnlNmT4yTn2iupwU3IBYI5ll5LxTqBXMunz+prRWKmmgxrjAb3VWtumV1vtHO4im/fWUg71fwbfxcuPJlnhjz+0FRLGc9Pba94NPj+Kt56d3HHtiImM+h+FrAr8eg3h9te4RJDpqMkfIqDPcMOHENezjbE8JLfvyPEXc3+W+QAW39s0ap0SXjZm09W0yrx7c9FiiWYssgP3IPn9nK3sLI1OMRdnqNIiPKP2pSFO7R2Vpf37iBPeCj9pwjOqUZG47E4ey0xcqgNRA9E7l+fjV2B8x2HwXYyVZ/RWtumej+WA= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c77a9e5a-e168-47c8-e586-08d6f45a9eae X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2019 02:05:36.9637 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: peng.fan@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5682 Cc: Marek Vasut , Tien Fong Chee , "u-boot@lists.denx.de" , dl-uboot-imx , York Sun Subject: [U-Boot] [PATCH V2 3/5] spl: mmc: support loading i.MX container format file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" i.MX8 only support AHAB secure boot with Container format image, we could not use FIT to support secure boot, so introduce container support to let SPL could load container images. Cc: Simon Goldschmidt Cc: Tien Fong Chee Cc: York Sun Cc: Marek Vasut Cc: Alex Kiernan Cc: Simon Glass Cc: Philipp Tomsich Cc: Kever Yang Cc: Heiko Schocher Signed-off-by: Peng Fan --- common/spl/spl_mmc.c | 10 ++++++++++ include/spl.h | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index bf53a1dadf..6320af055b 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -79,6 +79,16 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, load.bl_len = mmc->read_bl_len; load.read = h_spl_load_read; ret = spl_load_simple_fit(spl_image, &load, sector, header); + } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { + struct spl_load_info load; + + load.dev = mmc; + load.priv = NULL; + load.filename = NULL; + load.bl_len = mmc->read_bl_len; + load.read = h_spl_load_read; + + ret = spl_load_imx_container(spl_image, &load, sector); } else { ret = mmc_load_legacy(spl_image, mmc, sector, header); } diff --git a/include/spl.h b/include/spl.h index a9aaef345f..e280685b68 100644 --- a/include/spl.h +++ b/include/spl.h @@ -125,6 +125,18 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, #define SPL_COPY_PAYLOAD_ONLY 1 #define SPL_FIT_FOUND 2 +/** + * spl_load_imx_container() - Loads a imx container image from a device. + * @spl_image: Image description to set up + * @info: Structure containing the information required to load data. + * @sector: Sector number where container image is located in the device + * + * Reads the container image @sector in the device. Loads u-boot image to + * specified load address. + */ +int spl_load_imx_container(struct spl_image_info *spl_image, + struct spl_load_info *info, ulong sector); + /* SPL common functions */ void preloader_console_init(void); u32 spl_boot_device(void); From patchwork Wed Jun 19 02:05:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1118415 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="na7Ln/uJ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45T7c74lSGz9s7h for ; Wed, 19 Jun 2019 12:06:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4872BC21F8A; Wed, 19 Jun 2019 02:06:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DEBF9C21F3C; Wed, 19 Jun 2019 02:06:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9D904C21F3C; Wed, 19 Jun 2019 02:05:43 +0000 (UTC) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30068.outbound.protection.outlook.com [40.107.3.68]) by lists.denx.de (Postfix) with ESMTPS id 31AFCC22067 for ; Wed, 19 Jun 2019 02:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z8iYd+Z6v4sO6w8IfBlBsFgCX+R6PiNx78zSMlJ/su0=; b=na7Ln/uJOY/CllvjsubzLVMicRR4fxVAvJBqcqKUqygiihQhkHBAc3FOFiZTweI0M6cSGURhFcciIg+I3K5wiKQVsbI8D1zVjovJqp9zvIEmmPhh8ygSiBqzEmAgEQWkXHL5oBsgXxATZzMstzqr22W53tnTEqwOclmzATDXkRc= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5682.eurprd04.prod.outlook.com (20.178.202.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Wed, 19 Jun 2019 02:05:39 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015%3]) with mapi id 15.20.1987.014; Wed, 19 Jun 2019 02:05:39 +0000 From: Peng Fan To: "sbabic@denx.de" Thread-Topic: [PATCH V2 4/5] imx: add container target Thread-Index: AQHVJkN97ONb5YkQcUmtHwd/yyCiVA== Date: Wed, 19 Jun 2019 02:05:39 +0000 Message-ID: <20190619021958.31790-5-peng.fan@nxp.com> References: <20190619021958.31790-1-peng.fan@nxp.com> In-Reply-To: <20190619021958.31790-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d734fa6d-3f12-43d2-ed3d-08d6f45aa021 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5682; x-ms-traffictypediagnostic: AM0PR04MB5682: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(396003)(39860400002)(199004)(189003)(25786009)(36756003)(6512007)(6116002)(52116002)(81156014)(7736002)(4326008)(6436002)(8676002)(1730700003)(81166006)(476003)(2616005)(86362001)(44832011)(486006)(3846002)(14454004)(54906003)(66556008)(6506007)(66446008)(66476007)(386003)(64756008)(73956011)(478600001)(6916009)(66946007)(2351001)(305945005)(71190400001)(102836004)(2501003)(316002)(446003)(8936002)(256004)(5640700003)(50226002)(6486002)(66066001)(2906002)(11346002)(71200400001)(53936002)(5660300002)(1076003)(99286004)(186003)(68736007)(26005)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5682; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jWfmrYMrNkdLytuAXwxLgBpm2pR6kPGktys9ocRHPJNhHGBJCNt+KE4ab17+lOe7XJxfF8s5pjvBAJNLYKEk8K49OxW7bxK8/TxhWR5BQCUPnJyt+MBCfVoFrqodiU1dsZJQcDl63OPL8bkOsq/tNoYZpFERRDj2uAehvOo2i/LGjeUME4DOC/ARNYcEndrv/EMjd5q4+wo5uZFP2jfg7/YAX0RuX+V55yFSoYYw0bUjsVk16/u4TWzzI/dX8K7bWzxnSYkfHG4M0msxC3ZzrH/bdj78L5CbXKpGlQor8gPPesOc5/7bG9ci9iklDNFeX5N7g/kDf1r0Ft88hB3V599HolPmHBXAMcFL+6x/mufvFWMK7zBZpjmYFG4DKKgzRmoDWc6/7DG310aEmlMwZj058HhrtdBhf3xDV4iPhn0= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d734fa6d-3f12-43d2-ed3d-08d6f45aa021 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2019 02:05:39.2944 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: peng.fan@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5682 Cc: "u-boot@lists.denx.de" , dl-uboot-imx Subject: [U-Boot] [PATCH V2 4/5] imx: add container target X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" To support SPL loading container file, add a new Makefile target, and introduce a new Kconfig file to source the cfg file which will be parsed by mkimage. Signed-off-by: Peng Fan --- Makefile | 8 ++++++++ arch/arm/mach-imx/Makefile | 14 ++++++++++++-- arch/arm/mach-imx/imx8/Kconfig | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c55ffa265f..09b354bea9 100644 --- a/Makefile +++ b/Makefile @@ -1333,9 +1333,17 @@ SPL: spl/u-boot-spl.bin FORCE $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ ifeq ($(CONFIG_ARCH_IMX8M)$(CONFIG_ARCH_IMX8), y) +ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y) +u-boot.cnt: u-boot.bin FORCE + $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ + +flash.bin: spl/u-boot-spl.bin u-boot.cnt FORCE + $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ +else flash.bin: spl/u-boot-spl.bin u-boot.itb FORCE $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ endif +endif u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index 898478fc4a..6de81408f8 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -89,6 +89,11 @@ IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%) $(Q)mkdir -p $(dir $@) $(call if_changed_dep,cpp_cfg) +IMX_CONTAINER_CFG = $(CONFIG_IMX_CONTAINER_CFG:"%"=%) +container.cfg: $(IMX_CONTAINER_CFG) FORCE + $(Q)mkdir -p $(dir $@) + $(call if_changed_dep,cpp_cfg) + ifeq ($(CONFIG_ARCH_IMX8), y) CNTR_DEPFILES := $(srctree)/tools/imx_cntr_image.sh IMAGE_TYPE := imx8image @@ -157,10 +162,15 @@ SPL: MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout -T $(IMAGE_TYPE) -e 0x100000 flash.bin: MKIMAGEOUTPUT = flash.log -flash.bin: spl/u-boot-spl.bin u-boot.itb FORCE -ifeq ($(SPL_DEPFILE_EXISTS),0) +MKIMAGEFLAGS_u-boot.cnt = -n container.cfg -T $(IMAGE_TYPE) -e 0x100000 +u-boot.cnt: MKIMAGEOUTPUT = u-boot.cnt.log + +ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y) +u-boot.cnt: u-boot.bin container.cfg FORCE $(call if_changed,mkimage) endif +flash.bin: spl/u-boot-spl.bin FORCE + $(call if_changed,mkimage) endif else diff --git a/arch/arm/mach-imx/imx8/Kconfig b/arch/arm/mach-imx/imx8/Kconfig index e9496cb611..d17760e333 100644 --- a/arch/arm/mach-imx/imx8/Kconfig +++ b/arch/arm/mach-imx/imx8/Kconfig @@ -29,6 +29,13 @@ config SPL_LOAD_IMX_CONTAINER help This is to let SPL could load i.MX8 Container image +config IMX_CONTAINER_CFG + string "i.MX Container config file" + depends on SPL + help + This is to specific the cfg file for generating container + image which will be loaded by SPL. + choice prompt "i.MX8 board select" optional From patchwork Wed Jun 19 02:05:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 1118418 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="ByTQ4Adw"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45T7dc2nmzz9s7h for ; Wed, 19 Jun 2019 12:08:04 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 12CB8C2205F; Wed, 19 Jun 2019 02:06:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7C5A3C2206D; Wed, 19 Jun 2019 02:06:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DEC60C2204B; Wed, 19 Jun 2019 02:05:47 +0000 (UTC) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60043.outbound.protection.outlook.com [40.107.6.43]) by lists.denx.de (Postfix) with ESMTPS id D97E0C2204A for ; Wed, 19 Jun 2019 02:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A0kuHp+zAhHE7Jt94Ceo9WvBSlknP+tngoRtRkUoGp4=; b=ByTQ4AdwZvZNAUBjb9yesVu/C8YqGOJ4huNhrCgmUkU3jALYT42NBoPlfFwThAb2Bw6jfzkXxXre80dnb7179MgmFFEsFzXXX5zb3sc4ArZLQgnSvr2DFpZOXHF9WSqU5dModcCgSOJVfDYcumnKLi5QaHiekFZp9yCq9uwaF+8= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5682.eurprd04.prod.outlook.com (20.178.202.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Wed, 19 Jun 2019 02:05:41 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::6090:1f0b:b85b:8015%3]) with mapi id 15.20.1987.014; Wed, 19 Jun 2019 02:05:41 +0000 From: Peng Fan To: "sbabic@denx.de" Thread-Topic: [PATCH V2 5/5] imx8qxp_mek: switch to use container image Thread-Index: AQHVJkN/HxozDDj9f0Cf/osRLM1jfw== Date: Wed, 19 Jun 2019 02:05:41 +0000 Message-ID: <20190619021958.31790-6-peng.fan@nxp.com> References: <20190619021958.31790-1-peng.fan@nxp.com> In-Reply-To: <20190619021958.31790-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0PR01CA0062.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::26) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 809e0de9-c3f3-4215-030b-08d6f45aa186 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:AM0PR04MB5682; x-ms-traffictypediagnostic: AM0PR04MB5682: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2512; x-forefront-prvs: 0073BFEF03 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(376002)(346002)(396003)(39860400002)(199004)(189003)(25786009)(36756003)(6512007)(6116002)(52116002)(81156014)(7736002)(4326008)(6436002)(8676002)(1730700003)(81166006)(476003)(2616005)(86362001)(44832011)(486006)(3846002)(14454004)(54906003)(66556008)(6506007)(66446008)(66476007)(386003)(64756008)(73956011)(478600001)(6916009)(66946007)(2351001)(305945005)(71190400001)(102836004)(14444005)(2501003)(316002)(446003)(8936002)(256004)(5640700003)(50226002)(6486002)(66066001)(2906002)(11346002)(71200400001)(53936002)(5660300002)(1076003)(99286004)(186003)(68736007)(26005)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5682; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: DYgeGpbja1Hcx/kzKvqB+BKIR4CvssZ2oagP0SJ8/n035LiCSB+xixCnlk/G7XuhIb533MW/nRbXtwWHaOxO2drzNieCRFYvC9tKn6tPiyxMn/BDDM2xyuRW4wSMT0g+UIcQjs6sTqGby5u8hCl5RDOdIzrFlEs7y7wdUCaxN0aETNKZXPg20rEPcWgFrvM3+guhpqLAW3gz9VrrtiXfZVDphSV6cMT+wrYzHRFchdpPTjr9MlR2o0/jzGXtTkL03OCwOTfcDOIlutzZTZ2yHl4n1rHu624aLIzow0fSD82G3syWyO8SG/9nJ6fihPgIkwNIwSC2Pr6/do5bGIrirNSdBX7kVoPukmGTg9Val5QWdDaRESLEsYoSYAODmigLHlMS8Rh0fNvnVMIQZpMtnK9HaiAEHmmjRfD1EOwhcm0= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 809e0de9-c3f3-4215-030b-08d6f45aa186 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Jun 2019 02:05:41.7140 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: peng.fan@nxp.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5682 Cc: "u-boot@lists.denx.de" , dl-uboot-imx Subject: [U-Boot] [PATCH V2 5/5] imx8qxp_mek: switch to use container image X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Because FIT could not be used for AHAB secure boot on i.MX8, so switch to use container image that could let SPL verify ATF and U-Boot with AHAB. Note: The AHAB related code has not been added. Signed-off-by: Peng Fan --- board/freescale/imx8qxp_mek/README | 4 +--- board/freescale/imx8qxp_mek/uboot-container.cfg | 13 +++++++++++++ configs/imx8qxp_mek_defconfig | 5 ++--- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 board/freescale/imx8qxp_mek/uboot-container.cfg diff --git a/board/freescale/imx8qxp_mek/README b/board/freescale/imx8qxp_mek/README index f32290e3a2..6dc151b166 100644 --- a/board/freescale/imx8qxp_mek/README +++ b/board/freescale/imx8qxp_mek/README @@ -39,11 +39,9 @@ $ cp imx-sc-firmware-0.7/mx8qx-mek-scfw-tcm.bin . Build U-Boot ============ -$ export ATF_LOAD_ADDR=0x80000000 -$ export BL33_LOAD_ADDR=0x80020000 $ make imx8qxp_mek_defconfig $ make flash.bin -$ dd if=u-boot.itb of=flash.bin bs=512 seek=528 +$ dd if=u-boot.cnt of=flash.bin bs=512 seek=528 Flash the binary into the SD card ================================= diff --git a/board/freescale/imx8qxp_mek/uboot-container.cfg b/board/freescale/imx8qxp_mek/uboot-container.cfg new file mode 100644 index 0000000000..8165811818 --- /dev/null +++ b/board/freescale/imx8qxp_mek/uboot-container.cfg @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019 NXP + */ + +#define __ASSEMBLY__ + +/* This file is to create a container image could be loaded by SPL */ +BOOT_FROM SD 0x400 +SOC_TYPE IMX8QX +CONTAINER +IMAGE A35 bl31.bin 0x80000000 +IMAGE A35 u-boot.bin CONFIG_SYS_TEXT_BASE diff --git a/configs/imx8qxp_mek_defconfig b/configs/imx8qxp_mek_defconfig index d735d34b8b..5d6c5f968f 100644 --- a/configs/imx8qxp_mek_defconfig +++ b/configs/imx8qxp_mek_defconfig @@ -7,15 +7,14 @@ CONFIG_SPL_GPIO_SUPPORT=y CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SPL_LOAD_IMX_CONTAINER=y +CONFIG_IMX_CONTAINER_CFG="board/freescale/imx8qxp_mek/uboot-container.cfg" CONFIG_TARGET_IMX8QXP_MEK=y CONFIG_SPL_MMC_SUPPORT=y CONFIG_SPL_SERIAL_SUPPORT=y CONFIG_SPL_DRIVERS_MISC_SUPPORT=y CONFIG_NR_DRAM_BANKS=3 CONFIG_SPL=y -CONFIG_FIT=y -CONFIG_SPL_LOAD_FIT=y -CONFIG_SPL_FIT_GENERATOR="arch/arm/mach-imx/mkimage_fit_atf.sh" CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/imx8qxp_mek/imximage.cfg" CONFIG_BOOTDELAY=3 CONFIG_LOG=y