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 BF98BC433F5 for ; Fri, 22 Apr 2022 12:06:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FB8A83D58; Fri, 22 Apr 2022 14:06:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="FHBBp9RM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E82BD83D66; Fri, 22 Apr 2022 14:06:54 +0200 (CEST) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AAAA983CF3 for ; Fri, 22 Apr 2022 14:06:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jh80.chung@gmail.com Received: by mail-pl1-x629.google.com with SMTP id c23so10438492plo.0 for ; Fri, 22 Apr 2022 05:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=mcAz7W3Mot95QK5L5vqcKSFjAjLgGtnn9eBzp5eUjbQ=; b=FHBBp9RMRyxJDqUpweEjT26OvY+cz5iRHcPp/6YywCq/KpwXjnfs8i/pZuVmY9R2lW zWXni28CYEVy0cMBMMCwD+xTKsHcGznDiW/lqhXG4uiZtGeKRO8g/4r66ZqyxC9fhTu0 mRjQVnGI1sCictqeRlVavEDZ0uXbG7XlDjhNOlgzSCUFq3LkLLZZygvU6baqkh7TvlVI XbQsBZGEQKUU4kOkCNVcuJr3HuG1+SYWR7Y99NpsZq+3rF7PhLZiNYgvb9FNJ/Bl2JwJ G1SGjpL+mMNnBey2wpETIWRLxNnEJbhDb9o2rXIshNNNGjlA4KCfdOW9e0+InX149NkH UtpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=mcAz7W3Mot95QK5L5vqcKSFjAjLgGtnn9eBzp5eUjbQ=; b=pDAUdqDAhlZ+MP6KwVAsYVWRLTbMN2KnGfoSeLv+qOMBUdmA3tQc4sv7FWvARjdyym OPTrbaSjrryDoePjoiX/w8YNABMCRPnXEGhJs2Q2Kx3hbaSEFKp4HlrHX7ef1EbChjHB J8zRxSokk8ROIDZrqs1r3Ws+UTzD1uVOITeD3aYer+WiDA1hAtnJwc64prSi316Sdw/E SxyI8D/dBe/2lotH181FPsBd0V8rRgiGkBzMo6H4zc+D5UEiygPxEwm7ryg12c586YtQ uV6RJnT4SowUrNq/sIhuC3PPHZEENm3XwKMKj4BSqVlkr+GpyPnll9b9L+n1xNyA7sAv 4d+w== X-Gm-Message-State: AOAM530nJdPVL7cz9nnOiNoYOT4wK78Jcg761IV2jC6K2qO2MoR/p+lH agxPT3RFrMqgsfStyqfFuJg= X-Google-Smtp-Source: ABdhPJxffadEKL1J1nQRL9zAVLXIQimXMoDy9NFcsnBBuUOpz7z71OCR9V4lYLzziwt2bNWeFzjhqA== X-Received: by 2002:a17:90b:2691:b0:1d2:72b9:b9b with SMTP id pl17-20020a17090b269100b001d272b90b9bmr5162864pjb.80.1650629210086; Fri, 22 Apr 2022 05:06:50 -0700 (PDT) Received: from [192.168.0.19] ([183.99.112.216]) by smtp.gmail.com with ESMTPSA id u2-20020a17090ae00200b001cd4989ff56sm5859544pjy.29.2022.04.22.05.06.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Apr 2022 05:06:48 -0700 (PDT) Message-ID: Date: Fri, 22 Apr 2022 21:06:46 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 1/3] mmc: fsl_esdhc_spl: pre-PBL: check for BOOT signature instead of MBR/DBR Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Priyanka Jain , Peng Fan , Jaehoon Chung Cc: u-boot@lists.denx.de References: <20220402221701.18498-1-pali@kernel.org> <20220402221701.18498-2-pali@kernel.org> From: Jaehoon Chung In-Reply-To: <20220402221701.18498-2-pali@kernel.org> 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 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 Reviewed-by: Jaehoon Chung 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;