diff mbox series

[v2,1/1] imx: rom api: fix image offset computation

Message ID 20200513140228.8552-1-sebastien.szymanski@armadeus.com
State Accepted
Commit 1f63ee656698724bcdc4e711b4ccd267f6bf64ab
Delegated to: Stefano Babic
Headers show
Series [v2,1/1] imx: rom api: fix image offset computation | expand

Commit Message

Sébastien Szymanski May 13, 2020, 2:02 p.m. UTC
When not booting from FlexSPI, the offset computation is:

offset = image_offset + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;

When booting from SD card or eMMC user partition, image_offset is
0x8000. It is useless to add and remove 0x8000.
When booting from other device, image_offset is 0 so this computation is wrong.

Simplfy this computation to work on all booting devices.

Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
---

Changes from v2:
 * Previous version was wrong.

 arch/arm/mach-imx/spl_imx_romapi.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Stefano Babic June 8, 2020, 5:22 p.m. UTC | #1
> When not booting from FlexSPI, the offset computation is:
> offset = image_offset + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;
> When booting from SD card or eMMC user partition, image_offset is
> 0x8000. It is useless to add and remove 0x8000.
> When booting from other device, image_offset is 0 so this computation is wrong.
> Simplfy this computation to work on all booting devices.
> Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
Ye Li June 9, 2020, 4:03 a.m. UTC | #2
Hi Sébastien,

> -----Original Message-----
> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of
> sbabic@denx.de
> Sent: 2020年6月9日 1:22
> To: Sébastien Szymanski <sebastien.szymanski@armadeus.com>; u-
> boot@lists.denx.de
> Subject: [EXT] [PATCH v2 1/1] imx: rom api: fix image offset computation
> 
> Caution: EXT Email
> 
> > When not booting from FlexSPI, the offset computation is:
> > offset = image_offset +
> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512
> > - 0x8000; When booting from SD card or eMMC user partition,
> > image_offset is 0x8000. It is useless to add and remove 0x8000.
> > When booting from other device, image_offset is 0 so this computation is
> wrong.
> > Simplfy this computation to work on all booting devices.
> > Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
> Applied to u-boot-imx, master, thanks !

I just notice this patch. Can you elaborate the problem you met? 
Because from my view, your change is wrong.
1. Removing the image_offset will break secondary (redundant) boot support for sd and emmc.
2. When booting from emmc boot partition, the image_offset is 0. But the flash.bin
generated by mkimage with imximage-8mp-lpddr4.cfg is for sd. It expects to be burn at 32KB offset.
The fit offset 0x60000 has already included the 32KB offset.  So when you burn this flash.bin
to emmc boot partition at offset 0, the fit offset should subtract the 32KB (0x60000 - 0x8000).

Best regards,
Ye Li
> 
> Best regards,
> Stefano Babic
> 
> --
> ==========================================================
> ===========
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
> ==========================================================
> ===========
Sébastien Szymanski June 9, 2020, 8:31 a.m. UTC | #3
Hi,

On 6/9/20 6:03 AM, Ye Li wrote:
> Hi Sébastien,
> 
>> -----Original Message-----
>> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of
>> sbabic@denx.de
>> Sent: 2020年6月9日 1:22
>> To: Sébastien Szymanski <sebastien.szymanski@armadeus.com>; u-
>> boot@lists.denx.de
>> Subject: [EXT] [PATCH v2 1/1] imx: rom api: fix image offset computation
>>
>> Caution: EXT Email
>>
>>> When not booting from FlexSPI, the offset computation is:
>>> offset = image_offset +
>> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512
>>> - 0x8000; When booting from SD card or eMMC user partition,
>>> image_offset is 0x8000. It is useless to add and remove 0x8000.
>>> When booting from other device, image_offset is 0 so this computation is
>> wrong.
>>> Simplfy this computation to work on all booting devices.
>>> Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
>> Applied to u-boot-imx, master, thanks !
> 
> I just notice this patch. Can you elaborate the problem you met? 
> Because from my view, your change is wrong.
> 1. Removing the image_offset will break secondary (redundant) boot support for sd and emmc.
> 2. When booting from emmc boot partition, the image_offset is 0. But the flash.bin
> generated by mkimage with imximage-8mp-lpddr4.cfg is for sd. It expects to be burn at 32KB offset.
> The fit offset 0x60000 has already included the 32KB offset.  So when you burn this flash.bin
> to emmc boot partition at offset 0, the fit offset should subtract the 32KB (0x60000 - 0x8000).

You are right !
When I tried, I used a .cfg file without SECOND_LOADER and flashed
proper U-Boot "by hand" at offset 0x60000 which is wrong.

Stefano, can you drop my patch please ?

Sorry :/

Regards,

> 
> Best regards,
> Ye Li
>>
>> Best regards,
>> Stefano Babic
>>
>> --
>> ==========================================================
>> ===========
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
>> ==========================================================
>> ===========
Stefano Babic June 9, 2020, 9:19 a.m. UTC | #4
On 09.06.20 10:31, Sébastien Szymanski wrote:
> Hi,
> 
> On 6/9/20 6:03 AM, Ye Li wrote:
>> Hi Sébastien,
>>
>>> -----Original Message-----
>>> From: U-Boot <u-boot-bounces@lists.denx.de> On Behalf Of
>>> sbabic@denx.de
>>> Sent: 2020年6月9日 1:22
>>> To: Sébastien Szymanski <sebastien.szymanski@armadeus.com>; u-
>>> boot@lists.denx.de
>>> Subject: [EXT] [PATCH v2 1/1] imx: rom api: fix image offset computation
>>>
>>> Caution: EXT Email
>>>
>>>> When not booting from FlexSPI, the offset computation is:
>>>> offset = image_offset +
>>> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512
>>>> - 0x8000; When booting from SD card or eMMC user partition,
>>>> image_offset is 0x8000. It is useless to add and remove 0x8000.
>>>> When booting from other device, image_offset is 0 so this computation is
>>> wrong.
>>>> Simplfy this computation to work on all booting devices.
>>>> Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
>>> Applied to u-boot-imx, master, thanks !
>>
>> I just notice this patch. Can you elaborate the problem you met? 
>> Because from my view, your change is wrong.
>> 1. Removing the image_offset will break secondary (redundant) boot support for sd and emmc.
>> 2. When booting from emmc boot partition, the image_offset is 0. But the flash.bin
>> generated by mkimage with imximage-8mp-lpddr4.cfg is for sd. It expects to be burn at 32KB offset.
>> The fit offset 0x60000 has already included the 32KB offset.  So when you burn this flash.bin
>> to emmc boot partition at offset 0, the fit offset should subtract the 32KB (0x60000 - 0x8000).
> 
> You are right !
> When I tried, I used a .cfg file without SECOND_LOADER and flashed
> proper U-Boot "by hand" at offset 0x60000 which is wrong.
> 
> Stefano, can you drop my patch please ?

I revert it immediately - thanks Ye to have checked this before I send
my PR.

Stefano

> 
> Sorry :/
> 
> Regards,
> 
>>
>> Best regards,
>> Ye Li
>>>
>>> Best regards,
>>> Stefano Babic
>>>
>>> --
>>> ==========================================================
>>> ===========
>>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>>> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
>>> ==========================================================
>>> ===========
> 
>
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c
index 5dc0f7174e..78dd005e7f 100644
--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -83,12 +83,7 @@  static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 	printf("image offset 0x%x, pagesize 0x%x, ivt offset 0x%x\n",
 	       image_offset, pagesize, offset);
 
-	if (((rom_bt_dev >> 16) & 0xff) ==  BT_DEV_TYPE_FLEXSPINOR)
-		offset = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512;
-	else
-		offset = image_offset +
-			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000;
-
+	offset = 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,
 					((uintptr_t)header) ^ offset ^ size);