From patchwork Tue Sep 12 14:45:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812884 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="lNkbSbRQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs70k0XJJz9s7g for ; Wed, 13 Sep 2017 00:46:46 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id AD5C4C21FB8; Tue, 12 Sep 2017 14:46:05 +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=RCVD_IN_DNSWL_NONE, 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 90F9EC220AB; Tue, 12 Sep 2017 14:45:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 174DBC21E9C; Tue, 12 Sep 2017 14:45:48 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id A71B5C21EC9 for ; Tue, 12 Sep 2017 14:45:44 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEje12005273; Tue, 12 Sep 2017 09:45:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227540; bh=6IaI0iMIkDb3vs7qKf12r0uc5boH5X2wHuKNJxVGds8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lNkbSbRQn11V/5vSP4khWkzlr7FQsrDM55gAV/yIbNdwFeqmwLt8S/etdUroMNmSh QgSXul+bbS1T3npEkHUIonzborlb/GsWMWaFkOaxF3UEwTHKnqcdgH2V4iupHKQVog k7js9HuCPTWqp4NprNz0FdSwGyKLgN/kmlNNVlQY= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjeg5012334; Tue, 12 Sep 2017 09:45:40 -0500 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:40 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:39 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjd9A015514; Tue, 12 Sep 2017 09:45:39 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:30 +0200 Message-ID: <1505227539-17560-2-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 01/10] dts: renamed FIT_EMBED to MULTI_DTB_FIT and moved it to the dts Kconfig 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" CONFIG_FIT_EMBED might be confused with CONFIG_OF_EMBED, rename it MULTI_DTB_FIT as it is able to get a DTB from a FIT image containing multiple DTBs. Also move the option to the Kconfig dedicated to the DTS options and create a README for this feature. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- Makefile | 2 +- board/ti/ks2_evm/board_k2e.c | 2 +- board/ti/ks2_evm/board_k2g.c | 2 +- board/ti/ks2_evm/board_k2hk.c | 2 +- board/ti/ks2_evm/board_k2l.c | 2 +- common/Kconfig | 16 ---------------- common/Makefile | 2 +- configs/k2e_evm_defconfig | 2 +- configs/k2g_evm_defconfig | 2 +- configs/k2hk_evm_defconfig | 2 +- configs/k2l_evm_defconfig | 2 +- doc/README.multi-dtb-fit | 15 +++++++++++++++ dts/Kconfig | 20 +++++++++++++++++++- lib/fdtdec.c | 2 +- 14 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 doc/README.multi-dtb-fit diff --git a/Makefile b/Makefile index 8086f3c..833aad2 100644 --- a/Makefile +++ b/Makefile @@ -877,7 +877,7 @@ dts/dt.dtb: checkdtc u-boot quiet_cmd_copy = COPY $@ cmd_copy = cp $< $@ -ifeq ($(CONFIG_FIT_EMBED),y) +ifeq ($(CONFIG_MULTI_DTB_FIT),y) fit-dtb.blob: dts/dt.dtb FORCE $(call if_changed,mkimage) diff --git a/board/ti/ks2_evm/board_k2e.c b/board/ti/ks2_evm/board_k2e.c index 266a66b..6c77d91 100644 --- a/board/ti/ks2_evm/board_k2e.c +++ b/board/ti/ks2_evm/board_k2e.c @@ -166,7 +166,7 @@ int get_num_eth_ports(void) } #endif -#if defined(CONFIG_FIT_EMBED) +#if defined(CONFIG_MULTI_DTB_FIT) int board_fit_config_name_match(const char *name) { if (!strcmp(name, "keystone-k2e-evm")) diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c index 15f0f54..5120b2c 100644 --- a/board/ti/ks2_evm/board_k2g.c +++ b/board/ti/ks2_evm/board_k2g.c @@ -216,7 +216,7 @@ int board_mmc_init(bd_t *bis) } #endif -#if defined(CONFIG_FIT_EMBED) +#if defined(CONFIG_MULTI_DTB_FIT) int board_fit_config_name_match(const char *name) { bool eeprom_read = board_ti_was_eeprom_read(); diff --git a/board/ti/ks2_evm/board_k2hk.c b/board/ti/ks2_evm/board_k2hk.c index c733099..e99e635 100644 --- a/board/ti/ks2_evm/board_k2hk.c +++ b/board/ti/ks2_evm/board_k2hk.c @@ -150,7 +150,7 @@ int board_early_init_f(void) } #endif -#if defined(CONFIG_FIT_EMBED) +#if defined(CONFIG_MULTI_DTB_FIT) int board_fit_config_name_match(const char *name) { if (!strcmp(name, "keystone-k2hk-evm")) diff --git a/board/ti/ks2_evm/board_k2l.c b/board/ti/ks2_evm/board_k2l.c index 166367b..c65f331 100644 --- a/board/ti/ks2_evm/board_k2l.c +++ b/board/ti/ks2_evm/board_k2l.c @@ -138,7 +138,7 @@ int board_early_init_f(void) } #endif -#if defined(CONFIG_FIT_EMBED) +#if defined(CONFIG_MULTI_DTB_FIT) int board_fit_config_name_match(const char *name) { if (!strcmp(name, "keystone-k2l-evm")) diff --git a/common/Kconfig b/common/Kconfig index 4d8cae9..972b12b 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -384,22 +384,6 @@ config SYS_STDIO_DEREGISTER endmenu -config DTB_RESELECT - bool "Support swapping dtbs at a later point in boot" - depends on FIT_EMBED - help - It is possible during initial boot you may need to use a generic - dtb until you can fully determine the board your running on. This - config allows boards to implement a function at a later point - during boot to switch to the "correct" dtb. - -config FIT_EMBED - bool "Support a FIT image embedded in the U-boot image" - help - This option provides hooks to allow U-boot to parse an - appended FIT image and enable board specific code to then select - the correct DTB to be used. - config DEFAULT_FDT_FILE string "Default fdt file" help diff --git a/common/Makefile b/common/Makefile index 1b56cf9..c3d8d3f 100644 --- a/common/Makefile +++ b/common/Makefile @@ -103,7 +103,7 @@ obj-y += image.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o -obj-$(CONFIG_FIT_EMBED) += boot_fit.o common_fit.o +obj-$(CONFIG_$(SPL_)MULTI_DTB_FIT) += boot_fit.o common_fit.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += image-sig.o obj-$(CONFIG_IO_TRACE) += iotrace.o obj-y += memsize.o diff --git a/configs/k2e_evm_defconfig b/configs/k2e_evm_defconfig index fed6add..b6a5282 100644 --- a/configs/k2e_evm_defconfig +++ b/configs/k2e_evm_defconfig @@ -12,7 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="keystone-k2e-evm" CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DTB_RESELECT=y -CONFIG_FIT_EMBED=y +CONFIG_MULTI_DTB_FIT=y CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL=y diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig index 2b29bf4..9c8b66d 100644 --- a/configs/k2g_evm_defconfig +++ b/configs/k2g_evm_defconfig @@ -12,7 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="keystone-k2g-evm" CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DTB_RESELECT=y -CONFIG_FIT_EMBED=y +CONFIG_MULTI_DTB_FIT=y CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL=y diff --git a/configs/k2hk_evm_defconfig b/configs/k2hk_evm_defconfig index 80546ec..bfb95ab 100644 --- a/configs/k2hk_evm_defconfig +++ b/configs/k2hk_evm_defconfig @@ -12,7 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="keystone-k2hk-evm" CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DTB_RESELECT=y -CONFIG_FIT_EMBED=y +CONFIG_MULTI_DTB_FIT=y CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL=y diff --git a/configs/k2l_evm_defconfig b/configs/k2l_evm_defconfig index 732c9d2..7ab0d47 100644 --- a/configs/k2l_evm_defconfig +++ b/configs/k2l_evm_defconfig @@ -12,7 +12,7 @@ CONFIG_DEFAULT_DEVICE_TREE="keystone-k2l-evm" CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DTB_RESELECT=y -CONFIG_FIT_EMBED=y +CONFIG_MULTI_DTB_FIT=y CONFIG_VERSION_VARIABLE=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_SPL=y diff --git a/doc/README.multi-dtb-fit b/doc/README.multi-dtb-fit new file mode 100644 index 0000000..0d4f068 --- /dev/null +++ b/doc/README.multi-dtb-fit @@ -0,0 +1,15 @@ +MULTI DTB FIT + +The purpose of this feature is to enable u-boot to select its DTB from a FIT +appended at the end of the binary. + +Usually the DTB is selected by the SPL and passed down to U-Boot. But some +platforms don't use the SPL. In this case MULTI_DTB_FIT can used to provide +U-Boot with a choice of DTBs. +The relevant DTBs are packed into a FIT (list provided by CONFIG__OF_LIST). The +FIT is automatically generated at the end of the compilation and appended to +u-boot.bin so that U-Boot can locate it and select the correct DTB from inside +the FIT. +The selection is done using board_fit_config_name_match() (same as what the SPL +uses to select the DTB for U-Boot). The selection happens during fdtdec_setup() +which is called during before relocation by board_init_f(). diff --git a/dts/Kconfig b/dts/Kconfig index b4b7ddc..31cbc1f 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -98,7 +98,7 @@ config DEFAULT_DEVICE_TREE config OF_LIST string "List of device tree files to include for DT control" - depends on SPL_LOAD_FIT || FIT_EMBED + depends on SPL_LOAD_FIT || MULTI_DTB_FIT default DEFAULT_DEVICE_TREE help This option specifies a list of device tree files to use for DT @@ -108,6 +108,24 @@ config OF_LIST device tree files (without the directory or .dtb suffix) separated by . + +config DTB_RESELECT + bool "Support swapping dtbs at a later point in boot" + depends on MULTI_DTB_FIT + help + It is possible during initial boot you may need to use a generic + dtb until you can fully determine the board your running on. This + config allows boards to implement a function at a later point + during boot to switch to the "correct" dtb. + +config MULTI_DTB_FIT + bool "support embedding several DTBs in a FIT image for u-boot" + help + This option provides hooks to allow U-boot to parse an + appended FIT image and enable board specific code to then select + the correct DTB to be used. Use this if you need to support + multiple DTBs but don't use the SPL. + config OF_SPL_REMOVE_PROPS string "List of device tree properties to drop for SPL" depends on SPL_OF_CONTROL diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 107a892..630e040 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1217,7 +1217,7 @@ int fdtdec_setup(void) else gd->fdt_blob = (ulong *)&__bss_end; -# elif defined CONFIG_FIT_EMBED +# elif defined CONFIG_MULTI_DTB_FIT gd->fdt_blob = locate_dtb_in_fit(&_end); if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) { From patchwork Tue Sep 12 14:45:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812885 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="vQri2BnN"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs72j6T6yz9s7g for ; Wed, 13 Sep 2017 00:48:29 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 92BE9C22100; Tue, 12 Sep 2017 14:46:32 +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=RCVD_IN_DNSWL_NONE, 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 89386C220F6; Tue, 12 Sep 2017 14:45:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4E571C22021; Tue, 12 Sep 2017 14:45:47 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id 7C3C1C21DC4 for ; Tue, 12 Sep 2017 14:45:44 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjfVl024379; Tue, 12 Sep 2017 09:45:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227541; bh=WwPyDkFXPXu5yctfQUe8tM0+fhUIoD4yuFXcujJqJzQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=vQri2BnN6Wmu+ZcoT8DvMkjFEHusIObm7cDIZtVnMULECA1lPyRAUJ5CWI8R3a0EW zjXSKhxBakxhOyDm1RrHTz/tqbJngcZdw8LtA2Y5oBpI77l0XKlzFt5nSYaQFhGWgv RJzpZewqKMBM4EaQKqq3kA1JT/+4I/s6c22F2Ics= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjfn1012363; Tue, 12 Sep 2017 09:45:41 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:41 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:41 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjeep015528; Tue, 12 Sep 2017 09:45:40 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:31 +0200 Message-ID: <1505227539-17560-3-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 02/10] fit: use 'const' for the input of fdt_offset() and locate_dtb_in_fit() 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" Those 2 functions don't modify their input, we can mark it const. This prevents compilation warnings when they are provided const input. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- common/boot_fit.c | 4 ++-- include/boot_fit.h | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/common/boot_fit.c b/common/boot_fit.c index 0a72315..ce42931 100644 --- a/common/boot_fit.c +++ b/common/boot_fit.c @@ -13,7 +13,7 @@ #include #include -int fdt_offset(void *fit) +static int fdt_offset(const void *fit) { int images, node, fdt_len, fdt_node, fdt_offset; const char *fdt_name; @@ -55,7 +55,7 @@ int fdt_offset(void *fit) return fdt_offset; } -void *locate_dtb_in_fit(void *fit) +void *locate_dtb_in_fit(const void *fit) { struct image_header *header; int size; diff --git a/include/boot_fit.h b/include/boot_fit.h index b7d2462..e16ae5b 100644 --- a/include/boot_fit.h +++ b/include/boot_fit.h @@ -5,5 +5,10 @@ * SPDX-License-Identifier: GPL-2.0+ */ -int fdt_offset(void *fit); -void *locate_dtb_in_fit(void *fit); +/** + * locate_dtb_in_fit - Find a DTB matching the board in a FIT image + * @fit: pointer to the FIT image + * + * @return a pointer to a matching DTB blob if found, NULL otherwise + */ +void *locate_dtb_in_fit(const void *fit); From patchwork Tue Sep 12 14:45:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812892 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="jEIaNpJi"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs74148nyz9s7g for ; Wed, 13 Sep 2017 00:49:37 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 491A4C221B3; Tue, 12 Sep 2017 14:47:33 +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=RCVD_IN_DNSWL_NONE, 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 75A34C21FE0; Tue, 12 Sep 2017 14:46:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 48B7FC2209D; Tue, 12 Sep 2017 14:45:49 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id 00E93C22021 for ; Tue, 12 Sep 2017 14:45:45 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjgWX024385; Tue, 12 Sep 2017 09:45:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227542; bh=Oc1Kn4JlXVcQg2Uxy00nVrUGC0sTlMWojIU0EqBP74A=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jEIaNpJirUq2jTdqOYXDFfHUoTQiIb2irwXB/gH5na1QU0eNAnjU7YI9AnGyrYn9h GeX19BA00IHOcJoa2rM2Jy0a+/zKUMcBgWtxuh+H+IL5A74wEhQRjaJC4Vck3muC3l Co647AovXAsbOfWrCo8L5uU6936oxkBx95CpODZo= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjgBm012398; Tue, 12 Sep 2017 09:45:42 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:42 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:42 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjfSU025340; Tue, 12 Sep 2017 09:45:42 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:32 +0200 Message-ID: <1505227539-17560-4-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 03/10] fit: fixed bug in locate_dtb_in_fit() 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" If the dtb is the first data of the FIT, the its offset is 0x0. Change the test to '<' instead of '<=' Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- common/boot_fit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/boot_fit.c b/common/boot_fit.c index ce42931..add65c4 100644 --- a/common/boot_fit.c +++ b/common/boot_fit.c @@ -73,7 +73,7 @@ void *locate_dtb_in_fit(const void *fit) ret = fdt_offset(fit); - if (ret <= 0) + if (ret < 0) return NULL; else return (void *)fit+size+ret; From patchwork Tue Sep 12 14:45:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812891 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="OwHxufRf"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs73w6KYcz9s7g for ; Wed, 13 Sep 2017 00:49:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A4FDFC22021; Tue, 12 Sep 2017 14:46:55 +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=RCVD_IN_DNSWL_NONE, 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 07C4BC2217E; Tue, 12 Sep 2017 14:46:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DB2E8C22000; Tue, 12 Sep 2017 14:45:50 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id 982B8C22000 for ; Tue, 12 Sep 2017 14:45:46 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjiRv005285; Tue, 12 Sep 2017 09:45:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227544; bh=A5kYzcQI1Z1fQCsBp/rr43FH0Ee1+yGUk4Kv7tIw0rQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OwHxufRfRjCoT+SyKdU+h1KtgOhc/Jw6GmsrchOe3JMPr55Piq1kb7bPyzJ+SeVaS Qu09drkfNvv1xtZVjFAxTlb80AqMBppSCGzZMiJhXxDECSMPdE+A6MiyJlddB/pJmA VJgMMh1E9uCb8weSkD5CSvSYLZ8cFLKVbJOw/pWM= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjiG9012446; Tue, 12 Sep 2017 09:45:44 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:43 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:43 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjg5g002974; Tue, 12 Sep 2017 09:45:43 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:33 +0200 Message-ID: <1505227539-17560-5-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 04/10] fit: If no matching config is found in fit_find_config_node(), use the default one 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" If board_fit_config_name_match() doesn't match any configuration node, then use the default one (if provided). Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- common/common_fit.c | 20 ++++++++++++++++++++ include/image.h | 13 +++++++++++++ 2 files changed, 33 insertions(+) diff --git a/common/common_fit.c b/common/common_fit.c index 5f5f3f9..85b33d8 100644 --- a/common/common_fit.c +++ b/common/common_fit.c @@ -32,6 +32,9 @@ int fit_find_config_node(const void *fdt) { const char *name; int conf, node, len; + const char *dflt_conf_name; + const char *dflt_conf_desc = NULL; + int dflt_conf_node = -ENOENT; conf = fdt_path_offset(fdt, FIT_CONFS_PATH); if (conf < 0) { @@ -39,6 +42,9 @@ int fit_find_config_node(const void *fdt) conf); return -EINVAL; } + + dflt_conf_name = fdt_getprop(fdt, conf, "default", &len); + for (node = fdt_first_subnode(fdt, conf); node >= 0; node = fdt_next_subnode(fdt, node)) { @@ -50,6 +56,15 @@ int fit_find_config_node(const void *fdt) #endif return -EINVAL; } + + if (dflt_conf_name) { + const char *node_name = fdt_get_name(fdt, node, NULL); + if (strcmp(dflt_conf_name, node_name) == 0) { + dflt_conf_node = node; + dflt_conf_desc = name; + } + } + if (board_fit_config_name_match(name)) continue; @@ -58,5 +73,10 @@ int fit_find_config_node(const void *fdt) return node; } + if (dflt_conf_node != -ENOENT) { + debug("Selecting default config '%s'", dflt_conf_desc); + return dflt_conf_node; + } + return -ENOENT; } diff --git a/include/image.h b/include/image.h index 1f4bfda..3d1e3c3 100644 --- a/include/image.h +++ b/include/image.h @@ -1273,6 +1273,19 @@ void board_fit_image_post_process(void **p_image, size_t *p_size); #define FDT_ERROR ((ulong)(-1)) ulong fdt_getprop_u32(const void *fdt, int node, const char *prop); + +/** + * fit_find_config_node() - Find the node for the best DTB in a FIT image + * + * A FIT image contains one or more DTBs. This function parses the + * configurations described in the FIT images and returns the node of + * the first matching DTB. To check if a DTB matches a board, this function + * calls board_fit_config_name_match(). If no matching DTB is found, it returns + * the node described by the default configuration if it exists. + * + * @fdt: pointer to flat device tree + * @return the node if found, -ve otherwise + */ int fit_find_config_node(const void *fdt); /** From patchwork Tue Sep 12 14:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812887 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="RmcvMMy3"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs73K6p5tz9s7g for ; Wed, 13 Sep 2017 00:49:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 93F16C21FC3; Tue, 12 Sep 2017 14:48:06 +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=RCVD_IN_DNSWL_NONE, 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 8B596C221FA; Tue, 12 Sep 2017 14:46:08 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A1750C2209D; Tue, 12 Sep 2017 14:45:52 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id 972A3C2202A for ; Tue, 12 Sep 2017 14:45:48 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjjDZ024391; Tue, 12 Sep 2017 09:45:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227545; bh=IGUALYn1QJVlYc0fUxLeqliUmbVrPL3Agev9C3LOWNM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=RmcvMMy3yJUh+b6dptbkcCVSEZUdola//AXybvdBSTsbliF1mlJY3aqvXegKzFsSp N8QXChCIX4GI6GucMS9CF4WTQmgkH2cAmkJmkK96xOFihdxy9Ko2uguW959C+azScI qUL/jFonDIMFdWxlwzTYR3wvmwBhv06dSlWQqtuw= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjjT2012482; Tue, 12 Sep 2017 09:45:45 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:45 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:45 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjiQ6003002; Tue, 12 Sep 2017 09:45:44 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:34 +0200 Message-ID: <1505227539-17560-6-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 05/10] lzo: add a function to check the validity of the header 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" Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- include/linux/lzo.h | 3 +++ lib/lzo/lzo1x_decompress.c | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/linux/lzo.h b/include/linux/lzo.h index 88687fa..8981d04 100644 --- a/include/linux/lzo.h +++ b/include/linux/lzo.h @@ -31,6 +31,9 @@ int lzo1x_decompress_safe(const unsigned char *src, size_t src_len, int lzop_decompress(const unsigned char *src, size_t src_len, unsigned char *dst, size_t *dst_len); +/* check if the header is valid (based on magic numbers) */ +bool lzop_is_valid_header(const unsigned char *src); + /* * Return values (< 0 = Error) */ diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c index ccc90b8..65fef0b 100644 --- a/lib/lzo/lzo1x_decompress.c +++ b/lib/lzo/lzo1x_decompress.c @@ -30,16 +30,29 @@ static const unsigned char lzop_magic[] = { #define HEADER_HAS_FILTER 0x00000800L -static inline const unsigned char *parse_header(const unsigned char *src) + +bool lzop_is_valid_header(const unsigned char *src) { - u16 version; int i; - /* read magic: 9 first bytes */ for (i = 0; i < ARRAY_SIZE(lzop_magic); i++) { if (*src++ != lzop_magic[i]) - return NULL; + return false; } + return true; +} + +static inline const unsigned char *parse_header(const unsigned char *src) +{ + u16 version; + int i; + + if (!lzop_is_valid_header(src)) + return NULL; + + /* skip header */ + src += 9; + /* get version (2bytes), skip library version (2), * 'need to be extracted' version (2) and * method (1) */ From patchwork Tue Sep 12 14:45:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812886 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="FRIy6YF9"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs7382cJGz9s7g for ; Wed, 13 Sep 2017 00:48:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 22AA8C221C5; Tue, 12 Sep 2017 14:47:50 +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=RCVD_IN_DNSWL_NONE, 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 9BADFC221AD; Tue, 12 Sep 2017 14:46:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 75AC2C2202D; Tue, 12 Sep 2017 14:45:52 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id F18D1C220D3 for ; Tue, 12 Sep 2017 14:45:48 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjkHJ024399; Tue, 12 Sep 2017 09:45:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227546; bh=9DtuyoWSIrnjau2qK7U+qqNxAbBbkfp/dpJVLfBbebM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=FRIy6YF9a9hIfm3dwjOcNWORgcl1tXtAqWtKj7jJnmHAHwHLf/782ytxz9hME78S2 R8cylsUL+7tKmYp6YRy6fsAjE5O/Uurz0NrG1VMWKi9jFYEY+7GBWek9GMwUSEmZEV Y/sdVvwz3Q1A/MfM1wrwfVLvh/ExiibsyYg8S5XM= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjkfY012520; Tue, 12 Sep 2017 09:45:46 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:46 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:46 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjjGE025439; Tue, 12 Sep 2017 09:45:45 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:35 +0200 Message-ID: <1505227539-17560-7-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 06/10] gzip: add a function to parse the header 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" Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- include/common.h | 1 + lib/gunzip.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/common.h b/include/common.h index aaed131..36c1ac8 100644 --- a/include/common.h +++ b/include/common.h @@ -624,6 +624,7 @@ ulong usec2ticks (unsigned long usec); ulong ticks2usec (unsigned long ticks); /* lib/gunzip.c */ +int gzip_parse_header(const unsigned char *src, unsigned long len); int gunzip(void *, int, unsigned char *, unsigned long *); int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp, int stoponerr, int offset); diff --git a/lib/gunzip.c b/lib/gunzip.c index 832b306..adb86c7 100644 --- a/lib/gunzip.c +++ b/lib/gunzip.c @@ -42,7 +42,7 @@ void gzfree(void *x, void *addr, unsigned nb) free (addr); } -int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp) +int gzip_parse_header(const unsigned char *src, unsigned long len) { int i, flags; @@ -63,12 +63,21 @@ int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp) ; if ((flags & HEAD_CRC) != 0) i += 2; - if (i >= *lenp) { + if (i >= len) { puts ("Error: gunzip out of data in header\n"); return (-1); } + return i; +} + +int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp) +{ + int offset = gzip_parse_header(src, *lenp); + + if (offset < 0) + return offset; - return zunzip(dst, dstlen, src, lenp, 1, i); + return zunzip(dst, dstlen, src, lenp, 1, offset); } #ifdef CONFIG_CMD_UNZIP From patchwork Tue Sep 12 14:45:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812894 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="axCnnRgN"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs74k0gFBz9s7g for ; Wed, 13 Sep 2017 00:50:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C24E9C2224C; Tue, 12 Sep 2017 14:48:24 +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=RCVD_IN_DNSWL_NONE, 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 D1680C22132; Tue, 12 Sep 2017 14:46:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C709DC220EA; Tue, 12 Sep 2017 14:45:54 +0000 (UTC) Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by lists.denx.de (Postfix) with ESMTPS id 4BA40C220EA for ; Tue, 12 Sep 2017 14:45:50 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjlLn025611; Tue, 12 Sep 2017 09:45:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227547; bh=KqyTcsDEEXcBZtY1i7wywbQqGman+1r309XMg78YPsc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=axCnnRgNIVEccA+ICX/XR9XcE9iDNyn48TBj9ic5r+I84t/uPS442+lVzqW+Pq6/5 z/d/nklUisfNf7fIl6GOTFROrRmN6HGf5AXK7r5rm8xsizWuvWq8eBX+kMDw4COYHj iVQCqIGkaW7g9jgBabizsPJdJbUKrdke0j+/JRDo= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjlwE012536; Tue, 12 Sep 2017 09:45:47 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:47 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:47 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjke1023830; Tue, 12 Sep 2017 09:45:47 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:36 +0200 Message-ID: <1505227539-17560-8-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 07/10] lib: allow building lzo and gunzip for the SPL 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" Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- lib/Kconfig | 17 ++++++++++++++++- lib/Makefile | 6 +++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Kconfig b/lib/Kconfig index fe337ac..7617006 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -175,7 +175,22 @@ config LZMA config LZO bool "Enable LZO decompression support" help - This enables support for LZO compression algorithm.r + This enables support for LZO compression algorithm. + +config SPL_LZO + bool "Enable LZO decompression support in SPL" + help + This enables support for LZO compression algorithm in the SPL. + +config SPL_GZIP + bool "Enable GZIP decompression support in SPL" + select SPL_ZLIB + help + This enables support for GZIP compression algorithm in the SPL. + +config SPL_ZLIB + bool + endmenu config ERRNO_STR diff --git a/lib/Makefile b/lib/Makefile index 2eef1eb..767983c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -4,14 +4,15 @@ # # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_$(SPL_)ZLIB) += zlib/ +obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o +obj-$(CONFIG_$(SPL_)LZO) += lzo/ ifndef CONFIG_SPL_BUILD obj-$(CONFIG_EFI) += efi/ obj-$(CONFIG_EFI_LOADER) += efi_loader/ obj-$(CONFIG_LZMA) += lzma/ -obj-$(CONFIG_LZO) += lzo/ -obj-$(CONFIG_ZLIB) += zlib/ obj-$(CONFIG_BZIP2) += bzip2/ obj-$(CONFIG_TIZEN) += tizen/ obj-$(CONFIG_FIT) += libfdt/ @@ -26,7 +27,6 @@ obj-y += crc16.o obj-$(CONFIG_ERRNO_STR) += errno_str.o obj-$(CONFIG_FIT) += fdtdec_common.o obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o -obj-$(CONFIG_GZIP) += gunzip.o obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o obj-y += initcall.o From patchwork Tue Sep 12 14:45:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812899 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="KYcbg83m"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs78c5w7Hz9s4s for ; Wed, 13 Sep 2017 00:53:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 97D92C21FAF; Tue, 12 Sep 2017 14:51:09 +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=RCVD_IN_DNSWL_NONE, 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 4F419C2221F; Tue, 12 Sep 2017 14:46:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 86B09C2221D; Tue, 12 Sep 2017 14:45:56 +0000 (UTC) Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by lists.denx.de (Postfix) with ESMTPS id 2C17EC2209D for ; Tue, 12 Sep 2017 14:45:53 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjnNF005319; Tue, 12 Sep 2017 09:45:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227549; bh=+YuV7uJ9zloa7MSJUdyV1OYiGcfKCohwl7WKrcgKQwU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=KYcbg83ml/OPERgJQ3/5mYaMLVVsqYbekKQTf0OliCZhvW3v0mEuWJhKCWv+ijK/a 5MPa57nXN7uoGn3vyNRZ4s4XTBHhrO93JugEcykxwhdtK3/7mmqAQkGGQGkwMRQpvC wnPh60Ditn7xsTcvxchjSSmsku7qpNj3YjqqMwbo= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjnYY025905; Tue, 12 Sep 2017 09:45:49 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:48 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:49 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjm8l003045; Tue, 12 Sep 2017 09:45:48 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:37 +0200 Message-ID: <1505227539-17560-9-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 08/10] fdtdec: sort include files 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" Sort include files in accordance to U-Boot coding style. Signed-off-by: Jean-Jacques Hiblot --- lib/fdtdec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 630e040..ee398d1 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -4,17 +4,17 @@ */ #ifndef USE_HOSTCC +#include #include #include #include +#include #include -#include -#include -#include #include -#include -#include +#include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; From patchwork Tue Sep 12 14:45:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812895 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="nDyHROPr"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs74n4S6lz9sNV for ; Wed, 13 Sep 2017 00:50:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 58F1CC22235; Tue, 12 Sep 2017 14:48: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=RCVD_IN_DNSWL_NONE, 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 80637C221E3; Tue, 12 Sep 2017 14:46:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BEE6EC22124; Tue, 12 Sep 2017 14:45:57 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id 88B1AC220D3 for ; Tue, 12 Sep 2017 14:45:53 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjoPv024419; Tue, 12 Sep 2017 09:45:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227550; bh=ZdpkmYWqbvnmM8dGq4kiOhRUO/anp7r3XpoDtfZ5Mzk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nDyHROPr/BJOE13vTBHQZye9/jOcSD9wmw39ga73lvUQPbToHydFx7Nk/ItkAS9fp 1KTkLk1U0bXw+5QbXbxXMwr/nliaR5AmCJn6woqO2lGOL5CdebIzEM7VElZVX627lG qHfsDhYV0pvJq+TZD9+GuQxPPBs588a0fAn5vkRk= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjoFe012598; Tue, 12 Sep 2017 09:45:50 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:50 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:50 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjnDi025478; Tue, 12 Sep 2017 09:45:49 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:38 +0200 Message-ID: <1505227539-17560-10-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 09/10] spl: dm: Make it possible for the SPL to pick its own DTB from a FIT 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" u-boot can be embedded within a FIT image with multiple DTBs. It then selects at run-time which one is best suited for the platform. Use the same principle here for the SPL: put the DTBs in a FIT image, compress it (LZO, GZIP, or no compression) and append it at the end of the SPL. Signed-off-by: Jean-Jacques Hiblot --- doc/README.multi-dtb-fit | 56 ++++++++++++++++++++++++++++-- dts/Kconfig | 83 +++++++++++++++++++++++++++++++++++++++++++++ lib/fdtdec.c | 88 +++++++++++++++++++++++++++++++++++++++++++----- scripts/Makefile.spl | 35 ++++++++++++++++++- 4 files changed, 249 insertions(+), 13 deletions(-) diff --git a/doc/README.multi-dtb-fit b/doc/README.multi-dtb-fit index 0d4f068..6cc4965 100644 --- a/doc/README.multi-dtb-fit +++ b/doc/README.multi-dtb-fit @@ -1,8 +1,11 @@ -MULTI DTB FIT +MULTI DTB FIT and SPL_MULTI_DTB_FIT -The purpose of this feature is to enable u-boot to select its DTB from a FIT -appended at the end of the binary. +The purpose of this feature is to enable U-Boot or the SPL to select its DTB +from a FIT appended at the end of the binary. +It comes in two flavors: U-Boot (CONFIG_MULTI_DTB_FIT) and SPL +(CONFIG_SPL_MULTI_DTB_FIT). +U-Boot flavor: Usually the DTB is selected by the SPL and passed down to U-Boot. But some platforms don't use the SPL. In this case MULTI_DTB_FIT can used to provide U-Boot with a choice of DTBs. @@ -13,3 +16,50 @@ the FIT. The selection is done using board_fit_config_name_match() (same as what the SPL uses to select the DTB for U-Boot). The selection happens during fdtdec_setup() which is called during before relocation by board_init_f(). + +SPL flavor: +the SPL uses only a small subset of the DTB and it usually depends more +on the SOC than on the board. So it's usually fine to include a DTB in the +SPL that doesn't exactly match the board. There are howerver some cases +where it's not possible. In the later case, in order to support multiple +boards (or board revisions) with the same SPL binary, SPL_MULTI_DTB_FIT +can be used. +The relevant DTBs are packed into a FIT. This FIT is automatically generated +at the end of the compilation, compressed and appended to u-boot-spl.bin, so +that SPL can locate it and select the correct DTB from inside the FIT. +CONFIG_SPL__OF_LIST is used to list the relevant DTBs. +The compression stage is optional but reduces the impact on the size of the +SPL. LZO and GZIP compressions are supported. By default, the area where the +FIT is uncompressed is dynamicaly allocated but this behaviour can be changed +for platforms that don't provide a HEAP big enough to contain the uncompressed +FIT. +The SPL uses board_fit_config_name_match() to find the correct DTB within the +FIT (same as what the SPL uses to select the DTB for U-Boot). +Uncompression and selection stages happen in fdtdec_setup() which is called +during the early initialization stage of the SPL (spl_early_init() or +spl_init()) + +Impacts and performances (SPL flavor): +The impact of this option is relatively small. Here are some numbers measured +for a TI DRA72 platform: + + +----------+------------+-----------+------------+ + | size | size delta | SPL boot | boot time | + | (bytes) | (bytes) | time (s) | delta (s) | ++---------------------------+----------+------------+-----------+------------+ +| 1 DTB | | | | | ++---------------------------+----------+------------+-----------+------------+ +| reference | 125305 | 0 | 1.389 | 0 | +| LZO (dynamic allocation) | 125391 | 86 | 1.381 | -0.008 | ++---------------------------+----------+------------+-----------+------------+ +| 4 DTBs (DRA7, DRA71, | | | | | +| DRA72, DRA72 revC) | | | | | ++---------------------------+----------+------------+-----------+------------+ +| LZO (dynamic allocation) | 125991 | 686 | 1.39 | 0.001 | +| LZO (user defined area) | 125927 | 622 | 1.403 | 0.014 | +| GZIP (user defined area) | 133880 | 8575 | 1.421 | 0.032 | +| No compression (in place) | 137472 | 12167 | 1.412 | 0.023 | ++---------------------------+----------+------------+-----------+------------+ + +Note: SPL boot time is the time elapsed between the 'reset' command is entered +and the time when the first U-Boot (not SPL) version string is displayed. diff --git a/dts/Kconfig b/dts/Kconfig index 31cbc1f..979f14f 100644 --- a/dts/Kconfig +++ b/dts/Kconfig @@ -126,6 +126,89 @@ config MULTI_DTB_FIT the correct DTB to be used. Use this if you need to support multiple DTBs but don't use the SPL. + +config SPL_MULTI_DTB_FIT + depends on SPL_LOAD_FIT && SPL_OF_CONTROL && !SPL_OF_PLATDATA + bool "support embedding several DTBs in a FIT image for the SPL" + help + This option provides the SPL with the ability to select its own + DTB at runtime from an appended FIT image containing several DTBs. + This allows using the same SPL binary on multiple platforms. + The primary purpose is to handle different versions of + the same platform without tweaking the platform code if the + differences can be expressed in the DTBs (common examples are: bus + capabilities, pad configurations). + +config SPL_OF_LIST + string "List of device tree files to include for DT control in SPL" + depends on SPL_MULTI_DTB_FIT + default OF_LIST + help + This option specifies a list of device tree files to use for DT + control in the SPL. These will be packaged into a FIT. At run-time, + the SPL will select the correct DT to use by examining the + hardware (e.g. reading a board ID value). This is a list of + device tree files (without the directory or .dtb suffix) + separated by . + +choice + prompt "SPL OF LIST compression" + depends on SPL_MULTI_DTB_FIT + default SPL_MULTI_DTB_FIT_LZO + +config SPL_MULTI_DTB_FIT_LZO + bool "LZO" + depends on SYS_MALLOC_F + select SPL_LZO + help + Compress the FIT image containing the DTBs available for the SPL + using LZO compression. (requires lzop on host). + +config SPL_MULTI_DTB_FIT_GZIP + bool "GZIP" + depends on SYS_MALLOC_F + select SPL_GZIP + help + Compress the FIT image containing the DTBs available for the SPL + using GZIP compression. (requires gzip on host) + +config SPL_MULTI_DTB_FIT_NO_COMPRESSION + bool "No compression" + help + Do not compress the FIT image containing the DTBs available for the SPL. + Use this options only if LZO is not available and the DTBs are very small. +endchoice + +choice + prompt "location of uncompressed DTBs " + depends on (SPL_MULTI_DTB_FIT_GZIP || SPL_MULTI_DTB_FIT_LZO) + +config SPL_MULTI_DTB_FIT_DYN_ALLOC + bool "Dynamically allocate the memory" + depends on SYS_MALLOC_F + default y + +config SPL_MULTI_DTB_FIT_USER_DEFINED_AREA + bool "user-defined location" +endchoice + +config SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ + hex "Size of memory reserved to uncompress the DTBs" + depends on (SPL_MULTI_DTB_FIT_GZIP || SPL_MULTI_DTB_FIT_LZO) + default 0x8000 + help + This is the size of this area where the DTBs are uncompressed. + If this area is dynamically allocated, make sure that + SPL_SYS_MALLOC_F_LEN is big enough to contain it. + +config SPL_MULTI_DTB_FIT_USER_DEF_ADDR + hex "Address of memory where dtbs are uncompressed" + depends on SPL_MULTI_DTB_FIT_USER_DEFINED_AREA + help + the FIT image containing the DTBs is uncompressed in an area defined + at compilation time. This is the address of this area. It must be + aligned on 2-byte boundary. + config OF_SPL_REMOVE_PROPS string "List of device tree properties to drop for SPL" depends on SPL_OF_CONTROL diff --git a/lib/fdtdec.c b/lib/fdtdec.c index ee398d1..b7261bd 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -1203,9 +1205,66 @@ int fdtdec_setup_memory_banksize(void) } #endif +#if CONFIG_IS_ENABLED(MULTI_DTB_FIT) +# if CONFIG_IS_ENABLED(MULTI_DTB_FIT_GZIP) ||\ + CONFIG_IS_ENABLED(MULTI_DTB_FIT_LZO) +static int uncompress_blob(const void *src, ulong sz_src, void **dstp) +{ + size_t sz_out = CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ; + ulong sz_in = sz_src; + void *dst; + int rc; + + if (CONFIG_IS_ENABLED(GZIP)) + if (gzip_parse_header(src, sz_in) < 0) + return -1; + if (CONFIG_IS_ENABLED(LZO)) + if (!lzop_is_valid_header(src)) + return -EBADMSG; + + if (CONFIG_IS_ENABLED(MULTI_DTB_FIT_DYN_ALLOC)) { + dst = malloc(sz_out); + if (!dst) { + puts("uncompress_blob: Unable to allocate memory\n"); + return -ENOMEM; + } + } else { +# if CONFIG_IS_ENABLED(MULTI_DTB_FIT_USER_DEFINED_AREA) + dst = (void *)CONFIG_VAL(MULTI_DTB_FIT_USER_DEF_ADDR); +# else + return -ENOTSUPP; +# endif + } + + if (CONFIG_IS_ENABLED(GZIP)) + rc = gunzip(dst, sz_out, (u8 *)src, &sz_in); + else if (CONFIG_IS_ENABLED(LZO)) + rc = lzop_decompress(src, sz_in, dst, &sz_out); + + if (rc < 0) { + /* not a valid compressed blob */ + puts("uncompress_blob: Unable to uncompress\n"); + if (CONFIG_IS_ENABLED(MULTI_DTB_FIT_DYN_ALLOC)) + free(dst); + return -EBADMSG; + } + *dstp = dst; + return 0; +} +# else +static int uncompress_blob(const void *src, ulong sz_src, void **dstp) +{ + return -ENOTSUPP; +} +# endif +#endif + int fdtdec_setup(void) { #if CONFIG_IS_ENABLED(OF_CONTROL) +# if CONFIG_IS_ENABLED(MULTI_DTB_FIT) + void *fdt_blob; +# endif # ifdef CONFIG_OF_EMBED /* Get a pointer to the FDT */ gd->fdt_blob = __dtb_dt_begin; @@ -1216,15 +1275,6 @@ int fdtdec_setup(void) gd->fdt_blob = (ulong *)&_image_binary_end; else gd->fdt_blob = (ulong *)&__bss_end; - -# elif defined CONFIG_MULTI_DTB_FIT - gd->fdt_blob = locate_dtb_in_fit(&_end); - - if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) { - puts("Failed to find proper dtb in embedded FIT Image\n"); - return -1; - } - # else /* FDT is at end of image */ gd->fdt_blob = (ulong *)&_end; @@ -1243,7 +1293,27 @@ int fdtdec_setup(void) gd->fdt_blob = (void *)env_get_ulong("fdtcontroladdr", 16, (uintptr_t)gd->fdt_blob); # endif + +# if CONFIG_IS_ENABLED(MULTI_DTB_FIT) + /* + *try and uncompress the blob. + * Unfortunately there is no way to know how big the input blob really + * is. So let us set the maximum input size arbitrarily high. 16MB + * ought to be more than enough for packed DTBs. + */ + if (uncompress_blob(gd->fdt_blob, 0x1000000, &fdt_blob) == 0) + gd->fdt_blob = fdt_blob; + + /* + * Check if blob is a FIT images containings DTBs. + * If so, pick the most relevant + */ + fdt_blob = locate_dtb_in_fit(gd->fdt_blob); + if (fdt_blob) + gd->fdt_blob = fdt_blob; +# endif #endif + return fdtdec_prepare_fdt(); } diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index dd8065d..18bd091 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -209,10 +209,21 @@ cmd_cat = cat $(filter-out $(PHONY), $^) > $@ quiet_cmd_copy = COPY $@ cmd_copy = cp $< $@ +ifneq ($(CONFIG_SPL_MULTI_DTB_FIT),y) +FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).dtb +else ifeq ($(CONFIG_SPL_MULTI_DTB_FIT_LZO),y) +FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.lzo +else ifeq ($(CONFIG_SPL_MULTI_DTB_FIT_GZIP),y) +FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.gz +else +FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit +endif + + ifeq ($(CONFIG_$(SPL_TPL_)OF_CONTROL)$(CONFIG_OF_SEPARATE)$(CONFIG_$(SPL_TPL_)OF_PLATDATA),yy) $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \ $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \ - $(obj)/$(SPL_BIN).dtb FORCE + $(FINAL_DTB_CONTAINER) FORCE $(call if_changed,cat) $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE @@ -382,6 +393,28 @@ checkdtoc: tools PHONY += FORCE FORCE: +PHONY += dtbs +dtbs: + $(Q)$(MAKE) $(build)=dts dtbs + # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) + +SHRUNK_ARCH_DTB = $(patsubst %,$(obj)/dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST))) +.SECONDEXPANSION: +$(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@) + $(call if_changed,fdtgrep) + +MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ + -n "Multi DTB fit image for $(SPL_BIN)" -E \ + $(patsubst %,-b %,$(SHRUNK_ARCH_DTB)) + +$(obj)/$(SPL_BIN).multidtb.fit: /dev/null $(SHRUNK_ARCH_DTB) FORCE + $(call if_changed,mkimage) + +$(obj)/$(SPL_BIN).multidtb.fit.gz: $(obj)/$(SPL_BIN).multidtb.fit + @gzip -kf9 $< > $@ + +$(obj)/$(SPL_BIN).multidtb.fit.lzo: $(obj)/$(SPL_BIN).multidtb.fit + @lzop -f9 $< > $@ From patchwork Tue Sep 12 14:45:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 812898 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="m1rQpsOm"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xs77x3l8sz9s4s for ; Wed, 13 Sep 2017 00:53:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 37FD6C2222F; Tue, 12 Sep 2017 14:51:25 +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=RCVD_IN_DNSWL_NONE, 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 328D0C221A4; Tue, 12 Sep 2017 14:48:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D3576C221A4; Tue, 12 Sep 2017 14:46:37 +0000 (UTC) Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by lists.denx.de (Postfix) with ESMTPS id C24B0C220A9 for ; Tue, 12 Sep 2017 14:46:33 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v8CEjuMw020790; Tue, 12 Sep 2017 09:45:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1505227556; bh=dC+/7RXLfnKZ1S/lRhK+mp7DRnU7otESrBknGc7e7EU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=m1rQpsOmN7vhz6ixZY6v8Njmy6wMi23yD0D8W8YFmo1fhoIOI47VnYgz7ElKw/rC9 XN/lxWiL/L3RCb1ryglxdRR9exEcgO9ClSj6TEPigdl3dMzLqZGzgMphCcF+habf/A /ZoTc86eL+AZBHsWWo73LvmONainQTlr+Z0kvJPg= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjpG8025938; Tue, 12 Sep 2017 09:45:51 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 12 Sep 2017 09:45:51 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 12 Sep 2017 09:45:51 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v8CEjoma015674; Tue, 12 Sep 2017 09:45:51 -0500 From: Jean-Jacques Hiblot To: , , , Date: Tue, 12 Sep 2017 16:45:39 +0200 Message-ID: <1505227539-17560-11-git-send-email-jjhiblot@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> References: <1505227539-17560-1-git-send-email-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v5 10/10] omap: detect board before spl_early_init() 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" In order to be able to select the right DTB, we need to have identified the board before spl_early_init() is called. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini Reviewed-by: Simon Glass --- arch/arm/mach-omap2/hwinit-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/hwinit-common.c b/arch/arm/mach-omap2/hwinit-common.c index 7324d52..56890a0 100644 --- a/arch/arm/mach-omap2/hwinit-common.c +++ b/arch/arm/mach-omap2/hwinit-common.c @@ -165,9 +165,11 @@ void early_system_init(void) * to prevent overwrites. */ save_omap_boot_params(); - spl_early_init(); #endif do_board_detect(); +#ifdef CONFIG_SPL_BUILD + spl_early_init(); +#endif vcores_init(); #ifdef CONFIG_DEBUG_UART_OMAP debug_uart_init();