From patchwork Tue May 12 09:44:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245644 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Tue, 12 May 2020 17:44:00 +0800 Subject: [PATCH 1/5] spl: romapi: Fix issue for stream mode with secure boot enabled In-Reply-To: <20200512094404.16534-1-peng.fan@nxp.com> References: <20200512094404.16534-1-peng.fan@nxp.com> Message-ID: <20200512094404.16534-2-peng.fan@nxp.com> When download image through ROM API for stream mode (USB, eMMC fastboot). We uses tricky way to get the total image size: The spl_load_simple_fit is called but the data reading is invalid, so the image data is not really downloaded. We should not call HAB authenticate in this tricky way. Otherwise it will alway fail. This patch skip the authentication only for this tricky using. Signed-off-by: Peng Fan --- arch/arm/mach-imx/spl_imx_romapi.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index 5dc0f7174e..1a695ea837 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -13,6 +13,8 @@ DECLARE_GLOBAL_DATA_PTR; +static bool fit_skip_processing = false; + static int is_boot_from_stream_device(u32 boot) { u32 interface; @@ -245,10 +247,14 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, } } + fit_skip_processing = true; + total = get_fit_image_size(pfit); total += 3; total &= ~0x3; + fit_skip_processing = false; + imagesize = total - (p - pfit); imagesize += pagesize - 1; @@ -269,6 +275,11 @@ static int spl_romapi_load_image_stream(struct spl_image_info *spl_image, return spl_load_simple_fit(spl_image, &load, (ulong)pfit, pfit); } +bool spl_load_simple_fit_skip_processing(void) +{ + return fit_skip_processing; +} + int board_return_to_bootrom(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { From patchwork Tue May 12 09:44:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245645 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Tue, 12 May 2020 17:44:01 +0800 Subject: [PATCH 2/5] spl: romapi: avoid copy data when get fit image size In-Reply-To: <20200512094404.16534-1-peng.fan@nxp.com> References: <20200512094404.16534-1-peng.fan@nxp.com> Message-ID: <20200512094404.16534-3-peng.fan@nxp.com> No need to copy data when only need to get fit image size. Signed-off-by: Peng Fan --- arch/arm/mach-imx/spl_imx_romapi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index 1a695ea837..d753d0207c 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -124,14 +124,14 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector, ulong count, void *buf) { - memcpy(buf, (void *)(sector), count); - if (load->priv) { ulong *p = (ulong *)load->priv; ulong total = sector + count; if (total > *p) *p = total; + } else { + memcpy(buf, (void *)(sector), count); } return count; From patchwork Tue May 12 09:44:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245646 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Tue, 12 May 2020 17:44:02 +0800 Subject: [PATCH 3/5] spl: imx: Change USB boot device type In-Reply-To: <20200512094404.16534-1-peng.fan@nxp.com> References: <20200512094404.16534-1-peng.fan@nxp.com> Message-ID: <20200512094404.16534-4-peng.fan@nxp.com> From: Ye Li The SPL SDP is configured as BOOT_DEVICE_BOARD, so when booting from USB, change its type to BOOT_DEVICE_BOARD, so we can use SDP. Signed-off-by: Ye Li Signed-off-by: Peng Fan --- arch/arm/mach-imx/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index fd3fa04600..585a5e8bae 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -171,7 +171,7 @@ u32 spl_boot_device(void) case SPI_NOR_BOOT: return BOOT_DEVICE_SPI; case USB_BOOT: - return BOOT_DEVICE_USB; + return BOOT_DEVICE_BOARD; default: return BOOT_DEVICE_NONE; } From patchwork Tue May 12 09:44:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245647 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Tue, 12 May 2020 17:44:03 +0800 Subject: [PATCH 4/5] spl: imx8m: add QSPI boot dev In-Reply-To: <20200512094404.16534-1-peng.fan@nxp.com> References: <20200512094404.16534-1-peng.fan@nxp.com> Message-ID: <20200512094404.16534-5-peng.fan@nxp.com> When boot type could not be detected from rom sw info, read sbmr1 to detect, here we only use it to detect FLEXSPI boot, because ROM not update it in rom sw info. Signed-off-by: Peng Fan --- arch/arm/mach-imx/cpu.c | 6 ++++-- arch/arm/mach-imx/spl.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c index 515c1fea40..5305ad9761 100644 --- a/arch/arm/mach-imx/cpu.c +++ b/arch/arm/mach-imx/cpu.c @@ -434,12 +434,14 @@ enum boot_device get_boot_device(void) case BOOT_TYPE_SPINOR: boot_dev = SPI_NOR_BOOT; break; -#ifdef CONFIG_IMX8M case BOOT_TYPE_USB: boot_dev = USB_BOOT; break; -#endif default: +#ifdef CONFIG_IMX8M + if (((readl(SRC_BASE_ADDR + 0x58) & 0x00007FFF) >> 12) == 0x4) + boot_dev = QSPI_BOOT; +#endif break; } diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c index 585a5e8bae..12cb85c2ab 100644 --- a/arch/arm/mach-imx/spl.c +++ b/arch/arm/mach-imx/spl.c @@ -170,6 +170,8 @@ u32 spl_boot_device(void) return BOOT_DEVICE_NAND; case SPI_NOR_BOOT: return BOOT_DEVICE_SPI; + case QSPI_BOOT: + return BOOT_DEVICE_NOR; case USB_BOOT: return BOOT_DEVICE_BOARD; default: From patchwork Tue May 12 09:44:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 245648 List-Id: U-Boot discussion From: peng.fan at nxp.com (Peng Fan) Date: Tue, 12 May 2020 17:44:04 +0800 Subject: [PATCH 5/5] spl: fit: remove useless CONFIG_IMX_HAB In-Reply-To: <20200512094404.16534-1-peng.fan@nxp.com> References: <20200512094404.16534-1-peng.fan@nxp.com> Message-ID: <20200512094404.16534-6-peng.fan@nxp.com> No need to guard code with CONFIG_IMX_HAB, there is already a weak function. Signed-off-by: Peng Fan --- common/spl/spl_fit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index c51e4beb1c..3e5648b4eb 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -677,9 +677,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, spl_image->flags |= SPL_FIT_FOUND; -#ifdef CONFIG_IMX_HAB board_spl_fit_post_load((ulong)fit, size); -#endif return 0; }