[PATCH 0/5] spl: imx: update and fix

avoid copy data twice Fix stream mode for secure boot Update boot dev Drop useless node
Peng Fan (4): spl: romapi: Fix issue for stream mode with secure boot enabled spl: romapi: avoid copy data when get fit image size spl: imx8m: add QSPI boot dev spl: fit: remove useless CONFIG_IMX_HAB
Ye Li (1): spl: imx: Change USB boot device type
arch/arm/mach-imx/cpu.c | 6 ++++-- arch/arm/mach-imx/spl.c | 4 +++- arch/arm/mach-imx/spl_imx_romapi.c | 15 +++++++++++++-- common/spl/spl_fit.c | 2 -- 4 files changed, 20 insertions(+), 7 deletions(-)

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 peng.fan@nxp.com --- 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) {

No need to copy data when only need to get fit image size.
Signed-off-by: Peng Fan peng.fan@nxp.com --- 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;

Subject: [PATCH 2/5] spl: romapi: avoid copy data when get fit image size
Drop this patch, this is wrong.
Regards, Peng.
No need to copy data when only need to get fit image size.
Signed-off-by: Peng Fan peng.fan@nxp.com
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;
-- 2.16.4

From: Ye Li ye.li@nxp.com
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 ye.li@nxp.com Signed-off-by: Peng Fan peng.fan@nxp.com --- 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; }

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 peng.fan@nxp.com --- 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:

No need to guard code with CONFIG_IMX_HAB, there is already a weak function.
Signed-off-by: Peng Fan peng.fan@nxp.com --- 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; }

Subject: [PATCH 0/5] spl: imx: update and fix
Push button fast, wrong version. will post v2 after fix.
avoid copy data twice Fix stream mode for secure boot Update boot dev Drop useless node
Peng Fan (4): spl: romapi: Fix issue for stream mode with secure boot enabled spl: romapi: avoid copy data when get fit image size spl: imx8m: add QSPI boot dev spl: fit: remove useless CONFIG_IMX_HAB
Ye Li (1): spl: imx: Change USB boot device type
arch/arm/mach-imx/cpu.c | 6 ++++-- arch/arm/mach-imx/spl.c | 4 +++- arch/arm/mach-imx/spl_imx_romapi.c | 15 +++++++++++++-- common/spl/spl_fit.c | 2 -- 4 files changed, 20 insertions(+), 7 deletions(-)
-- 2.16.4
participants (1)
-
Peng Fan