Skip to contentSkip to conversation

imx: rom api: fix image offset computation

PATCH Superseded Sébastien Szymanski 2 participants 2 messages May 12, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 imx: rom api: fix image offset computation

According to the table 6-25 "Primary image offset and IVT offset details", in the IMX8MNRM, the ROM expects the following image offset:

SD: 32KB
eMMC: 0 if image is in boot partion and 32KB if it is on user partition
NAND: 0
FlexSPI: 4KB
SPI: 0

On eMMC, it is more likely that U-Boot is on the boot partion, so rework the offset computation by handling the two specific cases (SD and FlexSPI).

---
 arch/arm/mach-imx/spl_imx_romapi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-imx/spl_imx_romapi.c +4 -2
index 5dc0f7174e..1e9d7bd9ab 100644
@@ -84,10 +84,12 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 	       image_offset, pagesize, offset);
 
 	if (((rom_bt_dev >> 16) & 0xff) ==  BT_DEV_TYPE_FLEXSPINOR)
-		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512;
+		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x1000;
+	else if (((rom_bt_dev >> 16) & 0xff) ==  BT_DEV_TYPE_SD)
+		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;
 	else
 		offset = image_offset +
-			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;
+			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512;
 
 	size = ALIGN(sizeof(struct image_header), pagesize);
 	ret = g_rom_api->download_image((u8 *)header, offset, size,
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/1 imx: rom api: fix image offset computation

Quoted 9 lines · S??bastien Szymanski

According to the table 6-25 "Primary image offset and IVT offset details", in the IMX8MNRM, the ROM expects the following image offset:

SD: 32KB
eMMC: 0 if image is in boot partion and 32KB if it is on user partition
NAND: 0
FlexSPI: 4KB
SPI: 0

Quoted 3 lines

On eMMC, it is more likely that U-Boot is on the boot partion, so rework the offset computation by handling the two specific cases (SD and FlexSPI).

Likely, but not really. I have a product where it's on the eMMC but not in a boot partition. If this gets committed, should I sent a diff to revert it? :-) I'm not (yet?) using that code, but shouldn't there be a way to see if we are on a boot partition or not?

Best regards,
Patrick

Quoted 27 lines
---
 arch/arm/mach-imx/spl_imx_romapi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm/mach-imx/spl_imx_romapi.c +4 -2
index 5dc0f7174e..1e9d7bd9ab 100644
@@ -84,10 +84,12 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 	       image_offset, pagesize, offset);
 
 	if (((rom_bt_dev >> 16) & 0xff) ==  BT_DEV_TYPE_FLEXSPINOR)
-		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512;
+		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x1000;
+	else if (((rom_bt_dev >> 16) & 0xff) ==  BT_DEV_TYPE_SD)
+		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;
 	else
 		offset = image_offset +
-			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;
+			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512;
 
 	size = ALIGN(sizeof(struct image_header), pagesize);
 	ret = g_rom_api->download_image((u8 *)header, offset, size,
Signature · 1 line
2.26.2