* [PATCH 0/3] mmc: fsl_esdhc_spl: Fix booting P2020 from SD card
@ 2022-04-02 22:16 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
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Pali Rohár @ 2022-04-02 22:16 UTC (permalink / raw)
To: Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
This patch series contains fixes which makes SPL running on P2020 board
to load proper U-Boot from SD card with non-default or non-common
configuration. Tested on P2020 based board.
Pali Rohár (3):
mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of
MBR/DBR
mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size
mmc: fsl_esdhc_spl: Call mmc_init() before booting from SD card
drivers/mmc/fsl_esdhc_spl.c | 44 +++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 12 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of MBR/DBR
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 ` Pali Rohár
2022-04-22 12:06 ` Jaehoon Chung
2022-04-02 22:17 ` [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size Pali Rohár
2022-04-02 22:17 ` [PATCH 3/3] mmc: fsl_esdhc_spl: Call mmc_init() before booting from SD card Pali Rohár
2 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2022-04-02 22:16 UTC (permalink / raw)
To: Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
Pre-PBL BootROMs (MPC8536E, MPC8569E, P2020, P1011, P1012, P1013, P1020,
P1021, P1022) require custom BOOT signature on sector 0 and MBR/DBR
signature is not required at all.
So add check for BOOT signature and remove check for MBR/DBR.
This allows U-Boot SPL to load proper U-Boot on pre-PBL BootROMs platforms
also from SD cards which do not have MBR/DBR signature on sector 0.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
drivers/mmc/fsl_esdhc_spl.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc_spl.c b/drivers/mmc/fsl_esdhc_spl.c
index bee76572ac6c..109f558dcad3 100644
--- a/drivers/mmc/fsl_esdhc_spl.c
+++ b/drivers/mmc/fsl_esdhc_spl.c
@@ -14,6 +14,8 @@
* on SDCard, so we must read the MBR to get the start address and code
* length of the u-boot image, then calculate the address of the env.
*/
+#define ESDHC_BOOT_SIGNATURE_OFF 0x40
+#define ESDHC_BOOT_SIGNATURE 0x424f4f54
#define ESDHC_BOOT_IMAGE_SIZE 0x48
#define ESDHC_BOOT_IMAGE_ADDR 0x50
#define MBRDBR_BOOT_SIG_55 0x1fe
@@ -61,6 +63,9 @@ void __noreturn mmc_boot(void)
uchar *tmp_buf;
u32 blklen;
uchar val;
+#ifndef CONFIG_SPL_FSL_PBL
+ u32 val32;
+#endif
uint i, byte_num;
#endif
u32 offset, code_len;
@@ -94,16 +99,34 @@ void __noreturn mmc_boot(void)
hang();
}
+#ifdef CONFIG_SPL_FSL_PBL
val = *(tmp_buf + MBRDBR_BOOT_SIG_55);
if (0x55 != val) {
- puts("spl: mmc signature is not valid!!\n");
+ puts("spl: mmc MBR/DBR signature is not valid!!\n");
hang();
}
val = *(tmp_buf + MBRDBR_BOOT_SIG_AA);
if (0xAA != val) {
- puts("spl: mmc signature is not valid!!\n");
+ puts("spl: mmc MBR/DBR signature is not valid!!\n");
hang();
}
+#else
+ /*
+ * Booting from On-Chip ROM (eSDHC or eSPI), Document Number: AN3659, Rev. 2, 06/2012.
+ * Pre-PBL BootROMs (MPC8536E, MPC8569E, P2020, P1011, P1012, P1013, P1020, P1021, P1022)
+ * require custom BOOT signature on sector 0 and MBR/DBR signature is not required at all.
+ */
+ byte_num = 4;
+ val32 = 0;
+ for (i = 0; i < byte_num; i++) {
+ val = *(tmp_buf + ESDHC_BOOT_SIGNATURE_OFF + i);
+ val32 = (val32 << 8) + val;
+ }
+ if (val32 != ESDHC_BOOT_SIGNATURE) {
+ puts("spl: mmc BOOT signature is not valid!!\n");
+ hang();
+ }
+#endif
byte_num = 4;
offset = 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size
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-02 22:17 ` Pali Rohár
2022-04-22 12:07 ` 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
2 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2022-04-02 22:17 UTC (permalink / raw)
To: Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] mmc: fsl_esdhc_spl: Call mmc_init() before booting from SD card
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-02 22:17 ` [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size Pali Rohár
@ 2022-04-02 22:17 ` Pali Rohár
2022-04-22 12:07 ` Jaehoon Chung
2 siblings, 1 reply; 7+ messages in thread
From: Pali Rohár @ 2022-04-02 22:17 UTC (permalink / raw)
To: Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
If env is stored on SD card then U-Boot SPL automatically calls mmc_init()
before it is going to load proper U-Boot from SD card.
If env is not stored on SD card then U-Boot SPL fails to read proper U-Boot
from SD card due to missing mmc_init() call.
So add missing mmc_init() call into fsl_esdhc_spl's mmc_boot() function.
It fixes booting from SD card on P2020 boards without env support in SPL.
mmc_init() returns early if card was already initialized, so there is no
issue with calling this function more times.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
drivers/mmc/fsl_esdhc_spl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/mmc/fsl_esdhc_spl.c b/drivers/mmc/fsl_esdhc_spl.c
index b87597a88e1d..0146a231b221 100644
--- a/drivers/mmc/fsl_esdhc_spl.c
+++ b/drivers/mmc/fsl_esdhc_spl.c
@@ -77,6 +77,11 @@ void __noreturn mmc_boot(void)
hang();
}
+ if (mmc_init(mmc)) {
+ puts("spl: mmc device init failed!\n");
+ hang();
+ }
+
#ifdef CONFIG_FSL_CORENET
offset = CONFIG_SYS_MMC_U_BOOT_OFFS;
#else
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of MBR/DBR
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
0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2022-04-22 12:06 UTC (permalink / raw)
To: Pali Rohár, Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
On 4/3/22 07:16, Pali Rohár wrote:
> Pre-PBL BootROMs (MPC8536E, MPC8569E, P2020, P1011, P1012, P1013, P1020,
> P1021, P1022) require custom BOOT signature on sector 0 and MBR/DBR
> signature is not required at all.
>
> So add check for BOOT signature and remove check for MBR/DBR.
>
> This allows U-Boot SPL to load proper U-Boot on pre-PBL BootROMs platforms
> also from SD cards which do not have MBR/DBR signature on sector 0.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
> ---
> drivers/mmc/fsl_esdhc_spl.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/fsl_esdhc_spl.c b/drivers/mmc/fsl_esdhc_spl.c
> index bee76572ac6c..109f558dcad3 100644
> --- a/drivers/mmc/fsl_esdhc_spl.c
> +++ b/drivers/mmc/fsl_esdhc_spl.c
> @@ -14,6 +14,8 @@
> * on SDCard, so we must read the MBR to get the start address and code
> * length of the u-boot image, then calculate the address of the env.
> */
> +#define ESDHC_BOOT_SIGNATURE_OFF 0x40
> +#define ESDHC_BOOT_SIGNATURE 0x424f4f54
> #define ESDHC_BOOT_IMAGE_SIZE 0x48
> #define ESDHC_BOOT_IMAGE_ADDR 0x50
> #define MBRDBR_BOOT_SIG_55 0x1fe
> @@ -61,6 +63,9 @@ void __noreturn mmc_boot(void)
> uchar *tmp_buf;
> u32 blklen;
> uchar val;
> +#ifndef CONFIG_SPL_FSL_PBL
> + u32 val32;
> +#endif
> uint i, byte_num;
> #endif
> u32 offset, code_len;
> @@ -94,16 +99,34 @@ void __noreturn mmc_boot(void)
> hang();
> }
>
> +#ifdef CONFIG_SPL_FSL_PBL
> val = *(tmp_buf + MBRDBR_BOOT_SIG_55);
> if (0x55 != val) {
> - puts("spl: mmc signature is not valid!!\n");
> + puts("spl: mmc MBR/DBR signature is not valid!!\n");
> hang();
> }
> val = *(tmp_buf + MBRDBR_BOOT_SIG_AA);
> if (0xAA != val) {
> - puts("spl: mmc signature is not valid!!\n");
> + puts("spl: mmc MBR/DBR signature is not valid!!\n");
> hang();
> }
> +#else
> + /*
> + * Booting from On-Chip ROM (eSDHC or eSPI), Document Number: AN3659, Rev. 2, 06/2012.
> + * Pre-PBL BootROMs (MPC8536E, MPC8569E, P2020, P1011, P1012, P1013, P1020, P1021, P1022)
> + * require custom BOOT signature on sector 0 and MBR/DBR signature is not required at all.
> + */
> + byte_num = 4;
> + val32 = 0;
> + for (i = 0; i < byte_num; i++) {
> + val = *(tmp_buf + ESDHC_BOOT_SIGNATURE_OFF + i);
> + val32 = (val32 << 8) + val;
> + }
> + if (val32 != ESDHC_BOOT_SIGNATURE) {
> + puts("spl: mmc BOOT signature is not valid!!\n");
> + hang();
> + }
> +#endif
>
> byte_num = 4;
> offset = 0;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size
2022-04-02 22:17 ` [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size Pali Rohár
@ 2022-04-22 12:07 ` Jaehoon Chung
0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2022-04-22 12:07 UTC (permalink / raw)
To: Pali Rohár, Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
On 4/3/22 07:17, Pali Rohár wrote:
> 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: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
> ---
> 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,
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] mmc: fsl_esdhc_spl: Call mmc_init() before booting from SD card
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
0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2022-04-22 12:07 UTC (permalink / raw)
To: Pali Rohár, Priyanka Jain, Peng Fan, Jaehoon Chung; +Cc: u-boot
On 4/3/22 07:17, Pali Rohár wrote:
> If env is stored on SD card then U-Boot SPL automatically calls mmc_init()
> before it is going to load proper U-Boot from SD card.
>
> If env is not stored on SD card then U-Boot SPL fails to read proper U-Boot
> from SD card due to missing mmc_init() call.
>
> So add missing mmc_init() call into fsl_esdhc_spl's mmc_boot() function.
> It fixes booting from SD card on P2020 boards without env support in SPL.
>
> mmc_init() returns early if card was already initialized, so there is no
> issue with calling this function more times.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
> ---
> drivers/mmc/fsl_esdhc_spl.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mmc/fsl_esdhc_spl.c b/drivers/mmc/fsl_esdhc_spl.c
> index b87597a88e1d..0146a231b221 100644
> --- a/drivers/mmc/fsl_esdhc_spl.c
> +++ b/drivers/mmc/fsl_esdhc_spl.c
> @@ -77,6 +77,11 @@ void __noreturn mmc_boot(void)
> hang();
> }
>
> + if (mmc_init(mmc)) {
> + puts("spl: mmc device init failed!\n");
> + hang();
> + }
> +
> #ifdef CONFIG_FSL_CORENET
> offset = CONFIG_SYS_MMC_U_BOOT_OFFS;
> #else
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-22 12:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/3] mmc: fsl_esdhc_spl: pre-PBL: fix determining U-Boot size Pali Rohár
2022-04-22 12:07 ` 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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.