public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Priyanka Jain <priyanka.jain@nxp.com>,
	Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>
Cc: u-boot@lists.denx.de
Subject: [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size
Date: Sun,  3 Apr 2022 00:17:00 +0200	[thread overview]
Message-ID: <20220402221701.18498-3-pali@kernel.org> (raw)
In-Reply-To: <20220402221701.18498-1-pali@kernel.org>

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>
---
 drivers/mmc/fsl_esdhc_spl.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc_spl.c b/drivers/mmc/fsl_esdhc_spl.c
index 109f558dcad3..b87597a88e1d 100644
--- a/drivers/mmc/fsl_esdhc_spl.c
+++ b/drivers/mmc/fsl_esdhc_spl.c
@@ -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,
-- 
2.20.1


  parent reply	other threads:[~2022-04-02 22:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-02 22:16 [PATCH 0/3] mmc: fsl_esdhc_spl: Fix booting P2020 from SD card Pali Rohár
2022-04-02 22:16 ` [PATCH 1/3] mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of MBR/DBR Pali Rohár
2022-04-22 12:06   ` Jaehoon Chung
2022-04-02 22:17 ` Pali Rohár [this message]
2022-04-22 12:07   ` [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size Jaehoon Chung
2022-04-02 22:17 ` [PATCH 3/3] mmc: fsl_esdhc_spl: Call mmc_init() before booting from SD card Pali Rohár
2022-04-22 12:07   ` Jaehoon Chung

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220402221701.18498-3-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=jh80.chung@samsung.com \
    --cc=peng.fan@nxp.com \
    --cc=priyanka.jain@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox