From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C9FFC433F5 for ; Sat, 2 Apr 2022 22:17:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A2AF83986; Sun, 3 Apr 2022 00:17:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="To154ymt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5743983986; Sun, 3 Apr 2022 00:17:21 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B88AE8395A for ; Sun, 3 Apr 2022 00:17:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6FCBE60A2A; Sat, 2 Apr 2022 22:17:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC806C340F3; Sat, 2 Apr 2022 22:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648937836; bh=O24u464c08TLGEq1DedeusJZR9cY7pPCX1RnI3FAsOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=To154ymtCLvQoguljDwc+CaoODOdb+HKOPeNdllzEj8MDUNmT6QOkNpD0G5lwke3Z pq2BOlG3chFQHuKzLfTGPU7mue1A+bujco48GviLG/nxeMLqQu9B41IL3Ge1jEIY2p CakrN2r9DU0zEpYna1wzZV4KLrSb6/dEW1tATFx+eOeUHbN5Fnh+4lBP74KP0V/IW2 jgfKXEscLOjlWLoYNMt3xGYSHrGsgqQjvSZBKh2ygFfWM10hJM3QVA6oh/kgpI+FOF YMqyhaNhLN7rwQ8O2lJw5UTB5MZPiaz4LqGULOFBQXpuvGCMGe9aVpaFbkZQFjrL4O BHVKF1Eywja0g== Received: by pali.im (Postfix) id 0F7B5FE8; Sun, 3 Apr 2022 00:17:14 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Priyanka Jain , Peng Fan , Jaehoon Chung Cc: u-boot@lists.denx.de Subject: [PATCH 1/3] mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of MBR/DBR Date: Sun, 3 Apr 2022 00:16:59 +0200 Message-Id: <20220402221701.18498-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220402221701.18498-1-pali@kernel.org> References: <20220402221701.18498-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 --- 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