]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size
authorPali Rohár <pali@kernel.org>
Sat, 2 Apr 2022 22:17:00 +0000 (00:17 +0200)
committerPriyanka Jain <priyanka.jain@nxp.com>
Tue, 26 Apr 2022 11:48:39 +0000 (17:18 +0530)
In pre-PBL header is stored size of code which BootROM copies from SD card
to L2/SRAM. This size has upper limit of L2 cache size. In most cases this
is size of U-Boot SPL or size of L2 cache.

Therefore this size in pre-PBL header cannot be used for determining size
of proper U-Boot.

So always use CONFIG_SYS_MMC_U_BOOT_SIZE for determining size of proper
U-Boot which stored on SD card.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
drivers/mmc/fsl_esdhc_spl.c

index 109f558dcad3f48c4da235f6485bd0532460fe8f..b87597a88e1d7ab792f9021123faa3b3f0e81398 100644 (file)
@@ -79,7 +79,6 @@ void __noreturn mmc_boot(void)
 
 #ifdef CONFIG_FSL_CORENET
        offset = CONFIG_SYS_MMC_U_BOOT_OFFS;
-       code_len = CONFIG_SYS_MMC_U_BOOT_SIZE;
 #else
        blklen = mmc->read_bl_len;
        tmp_buf = malloc(blklen);
@@ -135,18 +134,11 @@ void __noreturn mmc_boot(void)
                offset = (offset << 8) + val;
        }
        offset += CONFIG_SYS_MMC_U_BOOT_OFFS;
-       /* Get the code size from offset 0x48 */
-       byte_num = 4;
-       code_len = 0;
-       for (i = 0; i < byte_num; i++) {
-               val = *(tmp_buf + ESDHC_BOOT_IMAGE_SIZE + i);
-               code_len = (code_len << 8) + val;
-       }
-       code_len -= CONFIG_SYS_MMC_U_BOOT_OFFS;
+#endif
        /*
        * Load U-Boot image from mmc into RAM
        */
-#endif
+       code_len = CONFIG_SYS_MMC_U_BOOT_SIZE;
        blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len;
        blk_cnt = ALIGN(code_len, mmc->read_bl_len) / mmc->read_bl_len;
        err = mmc->block_dev.block_read(&mmc->block_dev, blk_start, blk_cnt,