public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@gmail.com>
To: "Pali Rohár" <pali@kernel.org>,
	"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: Re: [PATCH 1/3] mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of MBR/DBR
Date: Fri, 22 Apr 2022 21:06:46 +0900	[thread overview]
Message-ID: <e2e20c8b-b0f8-41ca-8af3-da73ce6a1829@gmail.com> (raw)
In-Reply-To: <20220402221701.18498-2-pali@kernel.org>



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;

  reply	other threads:[~2022-04-22 12:06 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 [this message]
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

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=e2e20c8b-b0f8-41ca-8af3-da73ce6a1829@gmail.com \
    --to=jh80.chung@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=pali@kernel.org \
    --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