Skip to contentSkip to conversation

spl: imx: update and fix

PATCH New Peng Fan 1 participant 8 messages May 12, 2020

Subsystems (3)
lore
Share & tools
lore

Peng Fan

author
#0 lore raw

cover 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(-)
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 1/5 spl: romapi: Fix issue for stream mode with secure boot enabled

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.

---
 arch/arm/mach-imx/spl_imx_romapi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/mach-imx/spl_imx_romapi.c +11 -0
index 5dc0f7174e..1a695ea837 100644
@@ -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)
 {
Signature · 1 line
2.16.4
author
#2 lore raw

PATCH 2/5 spl: romapi: avoid copy data when get fit image size

In reply to Peng Fan

No need to copy data when only need to get fit image size.

---
 arch/arm/mach-imx/spl_imx_romapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-imx/spl_imx_romapi.c +2 -2
index 1a695ea837..d753d0207c 100644
@@ -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;
Signature · 1 line
2.16.4
author
#3 lore raw

PATCH 2/5 spl: romapi: avoid copy data when get fit image size

Quoted 2 lines

Subject: [PATCH 2/5] spl: romapi: avoid copy data when get fit image size

Drop this patch, this is wrong.

Regards,
Peng.

Quoted 32 lines

No need to copy data when only need to get fit image size.

---
 arch/arm/mach-imx/spl_imx_romapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-imx/spl_imx_romapi.c +0 -0
index 1a695ea837..d753d0207c 100644
@@ -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,

arch/arm/mach-imx/spl_imx_romapi.c +2 -3
 			       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

author
#4 lore raw

PATCH 3/5 spl: imx: Change USB boot device type

In reply to Peng Fan

From: Ye Li <[email protected]>

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.

---
 arch/arm/mach-imx/spl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-imx/spl.c +1 -1
index fd3fa04600..585a5e8bae 100644
@@ -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;
 	}
Signature · 1 line
2.16.4
author
#5 lore raw

PATCH 4/5 spl: imx8m: add QSPI boot dev

In reply to Peng Fan

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.

---
 arch/arm/mach-imx/cpu.c | 6 ++++--
 arch/arm/mach-imx/spl.c | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/mach-imx/cpu.c +4 -2
index 515c1fea40..5305ad9761 100644
@@ -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;
 	}
 
arch/arm/mach-imx/spl.c +2 -0
index 585a5e8bae..12cb85c2ab 100644
@@ -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:
Signature · 1 line
2.16.4
author
#6 lore raw

PATCH 5/5 spl: fit: remove useless CONFIG_IMX_HAB

In reply to Peng Fan

No need to guard code with CONFIG_IMX_HAB, there is already a weak function.

---
 common/spl/spl_fit.c | 2 --
 1 file changed, 2 deletions(-)
common/spl/spl_fit.c +0 -2
index c51e4beb1c..3e5648b4eb 100644
@@ -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;
 }
Signature · 1 line
2.16.4
author
#7 lore raw

cover spl: imx: update and fix

In reply to Peng Fan
Quoted 1 line

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

Push button fast, wrong version. will post v2 after fix.

Quoted 23 lines

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