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 46D97ECAAD8 for ; Tue, 20 Sep 2022 12:55:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C42E84C8D; Tue, 20 Sep 2022 14:55:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=reject dis=none) header.from=brun.one Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=brun.one header.i=@brun.one header.b="Pg80fRPD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0058B84A59; Tue, 20 Sep 2022 00:56:04 +0200 (CEST) Received: from mx.dolansoft.org (s2.dolansoft.org [212.51.146.245]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9BE9084A0D for ; Tue, 20 Sep 2022 00:56:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=brun.one Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=lorenz@brun.one DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=brun.one; s=s1; h=Sender:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=eC9F5iIzbnwGfDfl7m8/YtqPlNsL0n9ewTYH5NWO7TA=; b=P g80fRPDr1ODewHT5MvmoY8Z0gAZ/wuzZXcRpit4aaN/boPWUY50aV/vo/BnC+EHbnKbgdVhlreAs7 eMmwQPWS+ExJHTCqwLnrbK6QxsnMH/hMH3ZfFQmrySfN2v/+J4nPKNI/Gjz22hbKXxEbLsdhpFjIV p+arVw5tpb1nYSqhIY8xy9GLKnwaPNHEHexBn7By1/0kflZygcMsyYXFa1kxjzyWe4YZb0OV4DOOn e5RBibHWmMbr30djX9fhQlB5hFdkm1ys/kM6ZAAHx+q3x75nGPlflIkAMX1F3Ap3nIj2axLYUWNcb O8TA84oc38D+/OrqluvIsRvKf179PCsnQ==; Received: from [212.51.153.89] (helo=blacklava.cluster.local) by mx.dolansoft.org with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oaPgF-000cTR-CB; Mon, 19 Sep 2022 22:55:59 +0000 From: Lorenz Brun To: u-boot@lists.denx.de Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, kever.yang@rock-chips.com Subject: [PATCH] rkspi: only enable padding quirk on SoCs which need it Date: Tue, 20 Sep 2022 00:55:54 +0200 Message-Id: <20220919225554.1012657-1-lorenz@brun.one> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 20 Sep 2022 14:55:32 +0200 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.6 at phobos.denx.de X-Virus-Status: Clean The workaround for the Mask ROM bug in a lot of Rockchip SoCs is applied unconditionally, but at least on the RK3328 it is not needed and causes a boot failure if applied. Make a new column in the SoC feature description and skip the workaround if the SoC doesn't need it. Signed-off-by: Lorenz Brun --- tools/rkcommon.c | 35 ++++++++++++++++++++++------------- tools/rkcommon.h | 9 +++++++++ tools/rkspi.c | 6 ++++++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 0db45c2d41..4b4de24f21 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -118,22 +118,24 @@ struct spl_info { const uint32_t spl_size; const bool spl_rc4; const uint32_t header_ver; + const bool has_spi_halfblock_quirk; }; +// Note: has_spi_halfblock_quirk is not certain on all SoCs. static struct spl_info spl_infos[] = { - { "px30", "RK33", 0x2800, false, RK_HEADER_V1 }, - { "rk3036", "RK30", 0x1000, false, RK_HEADER_V1 }, - { "rk3066", "RK30", 0x8000 - 0x800, true, RK_HEADER_V1 }, - { "rk3128", "RK31", 0x1800, false, RK_HEADER_V1 }, - { "rk3188", "RK31", 0x8000 - 0x800, true, RK_HEADER_V1 }, - { "rk322x", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3288", "RK32", 0x8000, false, RK_HEADER_V1 }, - { "rk3308", "RK33", 0x40000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3328", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 }, - { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 }, - { "rk3568", "RK35", 0x14000 - 0x1000, false, RK_HEADER_V2 }, + { "px30", "RK33", 0x2800, false, RK_HEADER_V1, true}, + { "rk3036", "RK30", 0x1000, false, RK_HEADER_V1, true }, + { "rk3066", "RK30", 0x8000 - 0x800, true, RK_HEADER_V1, true }, + { "rk3128", "RK31", 0x1800, false, RK_HEADER_V1, true }, + { "rk3188", "RK31", 0x8000 - 0x800, true, RK_HEADER_V1, true }, + { "rk322x", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1, true }, + { "rk3288", "RK32", 0x8000, false, RK_HEADER_V1, true }, + { "rk3308", "RK33", 0x40000 - 0x1000, false, RK_HEADER_V1, true }, + { "rk3328", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1, false }, + { "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1, true }, + { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1, true }, + { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1, true }, + { "rk3568", "RK35", 0x14000 - 0x1000, false, RK_HEADER_V2, true }, }; /** @@ -282,6 +284,13 @@ bool rkcommon_is_header_v2(struct image_tool_params *params) return (info->header_ver == RK_HEADER_V2); } +bool rkcommon_has_spi_halfblock_quirk(struct image_tool_params *params) +{ + struct spl_info *info = rkcommon_get_spl_info(params->imagename); + + return info->has_spi_halfblock_quirk; +} + static void do_sha256_hash(uint8_t *buf, uint32_t size, uint8_t *out) { sha256_context ctx; diff --git a/tools/rkcommon.h b/tools/rkcommon.h index 49b6df3185..7b0c036dac 100644 --- a/tools/rkcommon.h +++ b/tools/rkcommon.h @@ -41,6 +41,15 @@ const char *rkcommon_get_spl_hdr(struct image_tool_params *params); */ int rkcommon_get_spl_size(struct image_tool_params *params); + +/** + * rkcommon_has_spi_halfblock_quirk checks if the SoC MaskROM has the SPI block + * loading quirk. + * SoCs with this quirk load the initial TPL/SPL incorrectly and need each 4K + * block of it to be split into two 2K blocks with the upper half padded. + */ +bool rkcommon_has_spi_halfblock_quirk(struct image_tool_params *params); + /** * rkcommon_set_header() - set up the header for a Rockchip boot image * diff --git a/tools/rkspi.c b/tools/rkspi.c index f2530f7bde..b6f75fae1b 100644 --- a/tools/rkspi.c +++ b/tools/rkspi.c @@ -26,6 +26,9 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd, rkcommon_set_header(buf, sbuf, ifd, params); + if(!rkcommon_has_spi_halfblock_quirk(params)) + return; + /* * Spread the image out so we only use the first 2KB of each 4KB * region. This is a feature of the SPI format required by the Rockchip @@ -62,6 +65,9 @@ static int rkspi_vrec_header(struct image_tool_params *params, { rkcommon_vrec_header(params, tparams); + if(!rkcommon_has_spi_halfblock_quirk(params)) + return 0; + /* * Converting to the SPI format (i.e. splitting each 4K page into two * 2K subpages and then padding these 2K pages up to take a complete -- 2.37.2