[{"id":3065178,"web_url":"http://patchwork.ozlabs.org/comment/3065178/","msgid":"<CAJaLiFzbRxoO4GyXHQsV3Q2nQxBAWa7eevY5L_R1E1u4rAq9VQ@mail.gmail.com>","list_archive_url":null,"date":"2023-02-25T03:58:37","subject":"Re: [PATCH RFC u-boot-mvebu 57/59] arm: mvebu: Define\n env_sf_get_env_addr() also for Proper U-Boot","submitter":{"id":74035,"url":"http://patchwork.ozlabs.org/api/people/74035/","name":"Tony Dinh","email":"mibodhi@gmail.com"},"content":"Hi Pali,\n\nOn Tue, Feb 21, 2023 at 12:22 PM Pali Rohár <pali@kernel.org> wrote:\n>\n> Proper U-Boot moves SPI0 CS0 Flash mapping from 0xD4000000 to 0xF4000000\n> and change its size from 64 MB to 8 MB. Definitions are already in\n> MBUS_SPI_BASE/MBUS_SPI_SIZE macros. So define these macros also for SPL\n> build, use them in env_sf_get_env_addr() function and move this function\n> from spl.c to cpu.c to be available in Proper U-Boot too.\n\nInteresting! So would it  affect the board that has a 4MB SPI flash ?\nI know there is a bug somewhere, because I need to set both\nCONFIG_ENV_OFFSET and CONFIG_ENV_ADDR. One or the other is not enough.\n\nI'm debugging an error that seemingly has something to do with the SPI\nenvs area: how u-boot set envs and recalculate checksum, and Linux\nfw_setenv() seems to not be doing the same thing. This is on a 4MB SPI\nmx25l3205d flash (Thecus N2350 board).\n\nIt might also have something to do with a SPI flash being set to some\nprotected  blocks (in the Status Register upon boot).\n\nThanks,\nTony\n\n>\n> Signed-off-by: Pali Rohár <pali@kernel.org>\n> ---\n>  arch/arm/mach-mvebu/cpu.c              |  9 +++++++++\n>  arch/arm/mach-mvebu/include/mach/cpu.h |  5 +++++\n>  arch/arm/mach-mvebu/spl.c              | 13 -------------\n>  3 files changed, 14 insertions(+), 13 deletions(-)\n>\n> diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c\n> index c5089a91c747..97154aaa2a7e 100644\n> --- a/arch/arm/mach-mvebu/cpu.c\n> +++ b/arch/arm/mach-mvebu/cpu.c\n> @@ -35,6 +35,15 @@ static const struct mbus_win windows[] = {\n>  #endif\n>  };\n>\n> +/* SPI0 CS0 Flash of size MBUS_SPI_SIZE is mapped to address MBUS_SPI_BASE */\n> +#if CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \\\n> +    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= MBUS_SPI_SIZE\n> +void *env_sf_get_env_addr(void)\n> +{\n> +       return (void *)MBUS_SPI_BASE + CONFIG_ENV_OFFSET;\n> +}\n> +#endif\n> +\n>  void lowlevel_init(void)\n>  {\n>         /*\n> diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h\n> index c17c2440f1b1..906a8737a401 100644\n> --- a/arch/arm/mach-mvebu/include/mach/cpu.h\n> +++ b/arch/arm/mach-mvebu/include/mach/cpu.h\n> @@ -71,8 +71,13 @@ enum cpu_attrib {\n>  #define MBUS_PCI_MEM_SIZE      ((MBUS_PCI_MAX_PORTS * 128) << 20)\n>  #define MBUS_PCI_IO_BASE       0xF1100000\n>  #define MBUS_PCI_IO_SIZE       ((MBUS_PCI_MAX_PORTS * 64) << 10)\n> +#ifdef CONFIG_SPL_BUILD\n> +#define MBUS_SPI_BASE          0xD4000000\n> +#define MBUS_SPI_SIZE          (64 << 20)\n> +#else\n>  #define MBUS_SPI_BASE          0xF4000000\n>  #define MBUS_SPI_SIZE          (8 << 20)\n> +#endif\n>  #define MBUS_DFX_BASE          0xF6000000\n>  #define MBUS_DFX_SIZE          (1 << 20)\n>  #define MBUS_BOOTROM_BASE      0xF8000000\n> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c\n> index 02528e025d8c..6b8c72a71dab 100644\n> --- a/arch/arm/mach-mvebu/spl.c\n> +++ b/arch/arm/mach-mvebu/spl.c\n> @@ -308,19 +308,6 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,\n>         hang();\n>  }\n>\n> -/*\n> - * SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM.\n> - * Proper U-Boot removes this direct mapping. So it is available only in SPL.\n> - */\n> -#if defined(CONFIG_SPL_ENV_IS_IN_SPI_FLASH) && \\\n> -    CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \\\n> -    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= 64*1024*1024\n> -void *env_sf_get_env_addr(void)\n> -{\n> -       return (void *)0xD4000000 + CONFIG_ENV_OFFSET;\n> -}\n> -#endif\n> -\n>  void board_init_f(ulong dummy)\n>  {\n>         int ret;\n> --\n> 2.20.1\n>","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)","legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20210112 header.b=i4lLr2gA;\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.b=\"i4lLr2gA\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com","phobos.denx.de;\n spf=pass smtp.mailfrom=mibodhi@gmail.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4PNtL62SYBz240k\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 25 Feb 2023 14:59:08 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 5BE6280ADF;\n\tSat, 25 Feb 2023 04:58:58 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id AD06485B11; Sat, 25 Feb 2023 04:58:55 +0100 (CET)","from mail-qk1-x735.google.com (mail-qk1-x735.google.com\n [IPv6:2607:f8b0:4864:20::735])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 7A01580ADF\n for <u-boot@lists.denx.de>; Sat, 25 Feb 2023 04:58:50 +0100 (CET)","by mail-qk1-x735.google.com with SMTP id h17so358687qka.11\n for <u-boot@lists.denx.de>; Fri, 24 Feb 2023 19:58:50 -0800 (PST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE,\n SPF_PASS autolearn=ham autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:from:to:cc:subject:date\n :message-id:reply-to;\n bh=yz2GAYpSuz8HhqQ0I58ECaLgIGiiPvv+ZhIAouFrgfM=;\n b=i4lLr2gAxNO7xCO68/w4SRNvnTwqBHaBOUW2X8ML3GvRTw0UZBUzdh+7yJQj5l9i1z\n ML3IqNK/MnjqzWERWF9yBmokS847DZhE1x8gKf/ekBxayxmkyzWz7xsjcVTS02iMyzV+\n 9YelnX84usnhtudc6H5ERuVPV2E0GqdYygFShaM6SSostOO8LRDM2XZW7kV8zV1j+tXW\n +2XvI7WlsRlQ7EdcgOcX2wuM80wljiPVAi3xqeWfoOytJv4Z64zo+dYqEH4ZJwjGOJSp\n YnLNtDhhVzSH86NqPjd8rvkj7iYvkMUL0kwffJ+VrAHJHf2uX/ICFN4ILX9u60/tKi3X\n dAqA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=yz2GAYpSuz8HhqQ0I58ECaLgIGiiPvv+ZhIAouFrgfM=;\n b=HqaPsqdS4otEHx5DCu3dUw6N48edoJ2B2seC57WcucFwDWNmYTbSjJxWqvY7SFuU7Z\n eqr7Za4T9lue/xrfq4SGEjFOUc3cjKDszovJQ3GaGFjvCO0ZGwtYHSi05aLlCvK7pS2j\n oauizRly40tRGMgOFql0VGzPCXdWcx5AMWM6bq11RESpOF0X/q49U2ujhGSr3OI3ytuM\n baaNXpL7Z3Qb8RVbtaYu39rRyTC6pUwrv4s3BzyJpXbqleP6us3Ibuu2loHdlVtNnS1t\n sKBVs4PDN399Z+psdXm4MICN0+rMr+2actbZnqKlTVJZpAWsWGMZqje2//72iJ9Cuiw+\n Jhmg==","X-Gm-Message-State":"AO0yUKW0cqnoyXnOLrjrLzcxREtJM6GyvmxBNZdrekIgqdfIiWRI8IXv\n Gg+jfQJhax2Q6b6eAK3ElgtCkqH5cLHvgRpp3P8=","X-Google-Smtp-Source":"\n AK7set/NSnH54JCaS3ZNtoymtErIe4aEE4lZ2uhuRjCUWSpy4t8Zh/qlPWYeNDoUgo6Biruj/goTAGtuGSBHeQtRGvc=","X-Received":"by 2002:a05:620a:46a2:b0:72b:25b4:565f with SMTP id\n bq34-20020a05620a46a200b0072b25b4565fmr759626qkb.5.1677297528886; Fri, 24 Feb\n 2023 19:58:48 -0800 (PST)","MIME-Version":"1.0","References":"<20230221201925.9644-1-pali@kernel.org>\n <20230221201925.9644-58-pali@kernel.org>","In-Reply-To":"<20230221201925.9644-58-pali@kernel.org>","From":"Tony Dinh <mibodhi@gmail.com>","Date":"Fri, 24 Feb 2023 19:58:37 -0800","Message-ID":"\n <CAJaLiFzbRxoO4GyXHQsV3Q2nQxBAWa7eevY5L_R1E1u4rAq9VQ@mail.gmail.com>","Subject":"Re: [PATCH RFC u-boot-mvebu 57/59] arm: mvebu: Define\n env_sf_get_env_addr() also for Proper U-Boot","To":"=?utf-8?q?Pali_Roh=C3=A1r?= <pali@kernel.org>","Cc":"u-boot@lists.denx.de, Stefan Roese <sr@denx.de>,\n Josua Mayer <josua@solid-run.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.6 at phobos.denx.de","X-Virus-Status":"Clean"}},{"id":3065360,"web_url":"http://patchwork.ozlabs.org/comment/3065360/","msgid":"<20230225211325.hj3z22y2gbajhclb@pali>","list_archive_url":null,"date":"2023-02-25T21:13:25","subject":"Re: [PATCH RFC u-boot-mvebu 57/59] arm: mvebu: Define\n env_sf_get_env_addr() also for Proper U-Boot","submitter":{"id":78810,"url":"http://patchwork.ozlabs.org/api/people/78810/","name":"Pali Rohár","email":"pali@kernel.org"},"content":"On Friday 24 February 2023 19:58:37 Tony Dinh wrote:\n> Hi Pali,\n> \n> On Tue, Feb 21, 2023 at 12:22 PM Pali Rohár <pali@kernel.org> wrote:\n> >\n> > Proper U-Boot moves SPI0 CS0 Flash mapping from 0xD4000000 to 0xF4000000\n> > and change its size from 64 MB to 8 MB. Definitions are already in\n> > MBUS_SPI_BASE/MBUS_SPI_SIZE macros. So define these macros also for SPL\n> > build, use them in env_sf_get_env_addr() function and move this function\n> > from spl.c to cpu.c to be available in Proper U-Boot too.\n> \n> Interesting! So would it  affect the board that has a 4MB SPI flash ?\n\nThis change just allows to use read-only SPI0 CS0 Flash mapping in the\nenv code in proper u-boot. If there is a board code which requires\naccess to env from proper u-boot before relocation happens then this\nchange allows it. But only if env is stored in the first 8MB of SPI0\nflash.\n\nNote that after relocation u-boot uses full-feature SPI driver for\naccessing flash memory, by coping its content to RAM during read.\n\nSo any access to env after relocation should not be affected by this\nchange.\n\nIIRC only Omnia board for now uses this feature (for configuring\nserdes based on env settings) and for now only in SPL.\n\n> I know there is a bug somewhere, because I need to set both\n> CONFIG_ENV_OFFSET and CONFIG_ENV_ADDR. One or the other is not enough.\n\nI am not sure for what is _ADDR needed (I am only on mobile for now, so\nI cannot check it)\n\n> I'm debugging an error that seemingly has something to do with the SPI\n> envs area: how u-boot set envs and recalculate checksum, and Linux\n> fw_setenv() seems to not be doing the same thing. This is on a 4MB SPI\n> mx25l3205d flash (Thecus N2350 board).\n\nMaybe you have set wrong env size or wrong flash erase block size?\n\n> It might also have something to do with a SPI flash being set to some\n> protected  blocks (in the Status Register upon boot).\n> \n> Thanks,\n> Tony\n> \n> >\n> > Signed-off-by: Pali Rohár <pali@kernel.org>\n> > ---\n> >  arch/arm/mach-mvebu/cpu.c              |  9 +++++++++\n> >  arch/arm/mach-mvebu/include/mach/cpu.h |  5 +++++\n> >  arch/arm/mach-mvebu/spl.c              | 13 -------------\n> >  3 files changed, 14 insertions(+), 13 deletions(-)\n> >\n> > diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c\n> > index c5089a91c747..97154aaa2a7e 100644\n> > --- a/arch/arm/mach-mvebu/cpu.c\n> > +++ b/arch/arm/mach-mvebu/cpu.c\n> > @@ -35,6 +35,15 @@ static const struct mbus_win windows[] = {\n> >  #endif\n> >  };\n> >\n> > +/* SPI0 CS0 Flash of size MBUS_SPI_SIZE is mapped to address MBUS_SPI_BASE */\n> > +#if CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \\\n> > +    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= MBUS_SPI_SIZE\n> > +void *env_sf_get_env_addr(void)\n> > +{\n> > +       return (void *)MBUS_SPI_BASE + CONFIG_ENV_OFFSET;\n> > +}\n> > +#endif\n> > +\n> >  void lowlevel_init(void)\n> >  {\n> >         /*\n> > diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h\n> > index c17c2440f1b1..906a8737a401 100644\n> > --- a/arch/arm/mach-mvebu/include/mach/cpu.h\n> > +++ b/arch/arm/mach-mvebu/include/mach/cpu.h\n> > @@ -71,8 +71,13 @@ enum cpu_attrib {\n> >  #define MBUS_PCI_MEM_SIZE      ((MBUS_PCI_MAX_PORTS * 128) << 20)\n> >  #define MBUS_PCI_IO_BASE       0xF1100000\n> >  #define MBUS_PCI_IO_SIZE       ((MBUS_PCI_MAX_PORTS * 64) << 10)\n> > +#ifdef CONFIG_SPL_BUILD\n> > +#define MBUS_SPI_BASE          0xD4000000\n> > +#define MBUS_SPI_SIZE          (64 << 20)\n> > +#else\n> >  #define MBUS_SPI_BASE          0xF4000000\n> >  #define MBUS_SPI_SIZE          (8 << 20)\n> > +#endif\n> >  #define MBUS_DFX_BASE          0xF6000000\n> >  #define MBUS_DFX_SIZE          (1 << 20)\n> >  #define MBUS_BOOTROM_BASE      0xF8000000\n> > diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c\n> > index 02528e025d8c..6b8c72a71dab 100644\n> > --- a/arch/arm/mach-mvebu/spl.c\n> > +++ b/arch/arm/mach-mvebu/spl.c\n> > @@ -308,19 +308,6 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,\n> >         hang();\n> >  }\n> >\n> > -/*\n> > - * SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM.\n> > - * Proper U-Boot removes this direct mapping. So it is available only in SPL.\n> > - */\n> > -#if defined(CONFIG_SPL_ENV_IS_IN_SPI_FLASH) && \\\n> > -    CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \\\n> > -    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= 64*1024*1024\n> > -void *env_sf_get_env_addr(void)\n> > -{\n> > -       return (void *)0xD4000000 + CONFIG_ENV_OFFSET;\n> > -}\n> > -#endif\n> > -\n> >  void board_init_f(ulong dummy)\n> >  {\n> >         int ret;\n> > --\n> > 2.20.1\n> >","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)","legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=SJGNboje;\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=kernel.org","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.b=\"SJGNboje\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=kernel.org","phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4PPKHx3zgrz23hX\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Feb 2023 08:13:47 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id AC3C285843;\n\tSat, 25 Feb 2023 22:13:34 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id 67D3385B6C; Sat, 25 Feb 2023 22:13:33 +0100 (CET)","from dfw.source.kernel.org (dfw.source.kernel.org\n [IPv6:2604:1380:4641:c500::1])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 9934B85927\n for <u-boot@lists.denx.de>; Sat, 25 Feb 2023 22:13:30 +0100 (CET)","from smtp.kernel.org (relay.kernel.org [52.25.139.140])\n (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n (No client certificate requested)\n by dfw.source.kernel.org (Postfix) with ESMTPS id E7ED360B71;\n Sat, 25 Feb 2023 21:13:28 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 054C5C433D2;\n Sat, 25 Feb 2023 21:13:28 +0000 (UTC)","by pali.im (Postfix)\n id 1DC1D709; Sat, 25 Feb 2023 22:13:25 +0100 (CET)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,\n SPF_PASS autolearn=ham autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1677359608;\n bh=SBw+jyCHtd6iGdL6CqHJP6r85MoKCcsw+G/vxX3XfDg=;\n h=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n b=SJGNbojee+Z7TLW/BqLCqUPg7TdhqdJeEzLzB3CH3Vc5BKIUFnoq1IVy9wkypuLTJ\n 1SMMkQ7l0CNnlyI3vsMCd217tp/dF9lp+hZJBgOR6OZHnVRg2sgg0ZIEQIfwMeulwM\n BysIDJ22SFKjBKboUUA1zt6H/o0T33g8ugHyIJrMP45nh+TgO6UHt6xLjvooZvUTbW\n ykQ9kId059eAHTnap35jIzfxmaPnxBaA7OIFKpqtUFbjqqNvlk6hQaDaTMSRWfWllY\n 6flsSr09QdeK/Y+af76Y6veUgNKQUKUkgxxVpLh4X2GX+5g5GH7F9CL9v0iZzpDnlD\n z+N5g4gWCJGuw==","Date":"Sat, 25 Feb 2023 22:13:25 +0100","From":"Pali =?utf-8?b?Um9ow6Fy?= <pali@kernel.org>","To":"Tony Dinh <mibodhi@gmail.com>","Cc":"u-boot@lists.denx.de, Stefan Roese <sr@denx.de>,\n Josua Mayer <josua@solid-run.com>","Subject":"Re: [PATCH RFC u-boot-mvebu 57/59] arm: mvebu: Define\n env_sf_get_env_addr() also for Proper U-Boot","Message-ID":"<20230225211325.hj3z22y2gbajhclb@pali>","References":"<20230221201925.9644-1-pali@kernel.org>\n <20230221201925.9644-58-pali@kernel.org>\n <CAJaLiFzbRxoO4GyXHQsV3Q2nQxBAWa7eevY5L_R1E1u4rAq9VQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"\n <CAJaLiFzbRxoO4GyXHQsV3Q2nQxBAWa7eevY5L_R1E1u4rAq9VQ@mail.gmail.com>","User-Agent":"NeoMutt/20180716","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.6 at phobos.denx.de","X-Virus-Status":"Clean"}},{"id":3065370,"web_url":"http://patchwork.ozlabs.org/comment/3065370/","msgid":"<CAJaLiFybFwAaEbUa=GuyKi6inHTT64DXKdPwv25m2Vg+dLy9eQ@mail.gmail.com>","list_archive_url":null,"date":"2023-02-25T22:37:27","subject":"Re: [PATCH RFC u-boot-mvebu 57/59] arm: mvebu: Define\n env_sf_get_env_addr() also for Proper U-Boot","submitter":{"id":74035,"url":"http://patchwork.ozlabs.org/api/people/74035/","name":"Tony Dinh","email":"mibodhi@gmail.com"},"content":"Hi Pali,\n\nOn Sat, Feb 25, 2023 at 1:13 PM Pali Rohár <pali@kernel.org> wrote:\n>\n> On Friday 24 February 2023 19:58:37 Tony Dinh wrote:\n> > Hi Pali,\n> >\n> > On Tue, Feb 21, 2023 at 12:22 PM Pali Rohár <pali@kernel.org> wrote:\n> > >\n> > > Proper U-Boot moves SPI0 CS0 Flash mapping from 0xD4000000 to 0xF4000000\n> > > and change its size from 64 MB to 8 MB. Definitions are already in\n> > > MBUS_SPI_BASE/MBUS_SPI_SIZE macros. So define these macros also for SPL\n> > > build, use them in env_sf_get_env_addr() function and move this function\n> > > from spl.c to cpu.c to be available in Proper U-Boot too.\n> >\n> > Interesting! So would it  affect the board that has a 4MB SPI flash ?\n>\n> This change just allows to use read-only SPI0 CS0 Flash mapping in the\n> env code in proper u-boot. If there is a board code which requires\n> access to env from proper u-boot before relocation happens then this\n> change allows it. But only if env is stored in the first 8MB of SPI0\n> flash.\n>\n> Note that after relocation u-boot uses full-feature SPI driver for\n> accessing flash memory, by coping its content to RAM during read.\n>\n> So any access to env after relocation should not be affected by this\n> change.\n>\n> IIRC only Omnia board for now uses this feature (for configuring\n> serdes based on env settings) and for now only in SPL.\n>\n> > I know there is a bug somewhere, because I need to set both\n> > CONFIG_ENV_OFFSET and CONFIG_ENV_ADDR. One or the other is not enough.\n>\n> I am not sure for what is _ADDR needed (I am only on mobile for now, so\n> I cannot check it)\n>\n> > I'm debugging an error that seemingly has something to do with the SPI\n> > envs area: how u-boot set envs and recalculate checksum, and Linux\n> > fw_setenv() seems to not be doing the same thing. This is on a 4MB SPI\n> > mx25l3205d flash (Thecus N2350 board).\n>\n> Maybe you have set wrong env size or wrong flash erase block size?\n\nI've double checked that in u-boot and Linux to make sure both use\n64KB env size and 4K sector, and at the same location!  I was guessing\nthat the block protection is causing a problem, so I also had a patch\nfor the flash chip mx25l3205d to unprotect all blocks too (currently\nu-boot spi-nor does not do that for the Macronix flash). But that\nstill doesn't help :) I think I might try moving the envs to a\ndifferent location to see if it helps.\n\nThanks,\nTony\n\n>\n> > It might also have something to do with a SPI flash being set to some\n> > protected  blocks (in the Status Register upon boot).\n> >\n> > Thanks,\n> > Tony\n> >\n> > >\n> > > Signed-off-by: Pali Rohár <pali@kernel.org>\n> > > ---\n> > >  arch/arm/mach-mvebu/cpu.c              |  9 +++++++++\n> > >  arch/arm/mach-mvebu/include/mach/cpu.h |  5 +++++\n> > >  arch/arm/mach-mvebu/spl.c              | 13 -------------\n> > >  3 files changed, 14 insertions(+), 13 deletions(-)\n> > >\n> > > diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c\n> > > index c5089a91c747..97154aaa2a7e 100644\n> > > --- a/arch/arm/mach-mvebu/cpu.c\n> > > +++ b/arch/arm/mach-mvebu/cpu.c\n> > > @@ -35,6 +35,15 @@ static const struct mbus_win windows[] = {\n> > >  #endif\n> > >  };\n> > >\n> > > +/* SPI0 CS0 Flash of size MBUS_SPI_SIZE is mapped to address MBUS_SPI_BASE */\n> > > +#if CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \\\n> > > +    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= MBUS_SPI_SIZE\n> > > +void *env_sf_get_env_addr(void)\n> > > +{\n> > > +       return (void *)MBUS_SPI_BASE + CONFIG_ENV_OFFSET;\n> > > +}\n> > > +#endif\n> > > +\n> > >  void lowlevel_init(void)\n> > >  {\n> > >         /*\n> > > diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h\n> > > index c17c2440f1b1..906a8737a401 100644\n> > > --- a/arch/arm/mach-mvebu/include/mach/cpu.h\n> > > +++ b/arch/arm/mach-mvebu/include/mach/cpu.h\n> > > @@ -71,8 +71,13 @@ enum cpu_attrib {\n> > >  #define MBUS_PCI_MEM_SIZE      ((MBUS_PCI_MAX_PORTS * 128) << 20)\n> > >  #define MBUS_PCI_IO_BASE       0xF1100000\n> > >  #define MBUS_PCI_IO_SIZE       ((MBUS_PCI_MAX_PORTS * 64) << 10)\n> > > +#ifdef CONFIG_SPL_BUILD\n> > > +#define MBUS_SPI_BASE          0xD4000000\n> > > +#define MBUS_SPI_SIZE          (64 << 20)\n> > > +#else\n> > >  #define MBUS_SPI_BASE          0xF4000000\n> > >  #define MBUS_SPI_SIZE          (8 << 20)\n> > > +#endif\n> > >  #define MBUS_DFX_BASE          0xF6000000\n> > >  #define MBUS_DFX_SIZE          (1 << 20)\n> > >  #define MBUS_BOOTROM_BASE      0xF8000000\n> > > diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c\n> > > index 02528e025d8c..6b8c72a71dab 100644\n> > > --- a/arch/arm/mach-mvebu/spl.c\n> > > +++ b/arch/arm/mach-mvebu/spl.c\n> > > @@ -308,19 +308,6 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,\n> > >         hang();\n> > >  }\n> > >\n> > > -/*\n> > > - * SPI0 CS0 Flash is mapped to address range 0xD4000000 - 0xD7FFFFFF by BootROM.\n> > > - * Proper U-Boot removes this direct mapping. So it is available only in SPL.\n> > > - */\n> > > -#if defined(CONFIG_SPL_ENV_IS_IN_SPI_FLASH) && \\\n> > > -    CONFIG_ENV_SPI_BUS == 0 && CONFIG_ENV_SPI_CS == 0 && \\\n> > > -    CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE <= 64*1024*1024\n> > > -void *env_sf_get_env_addr(void)\n> > > -{\n> > > -       return (void *)0xD4000000 + CONFIG_ENV_OFFSET;\n> > > -}\n> > > -#endif\n> > > -\n> > >  void board_init_f(ulong dummy)\n> > >  {\n> > >         int ret;\n> > > --\n> > > 2.20.1\n> > >","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)","legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20210112 header.b=hi1Pgon5;\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.b=\"hi1Pgon5\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=gmail.com","phobos.denx.de;\n spf=pass smtp.mailfrom=mibodhi@gmail.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (P-384))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4PPM8r4czMz2466\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Feb 2023 09:37:48 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 639FB8559B;\n\tSat, 25 Feb 2023 23:37:44 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id E779984227; Sat, 25 Feb 2023 23:37:42 +0100 (CET)","from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com\n [IPv6:2607:f8b0:4864:20::e2a])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 2686C858A8\n for <u-boot@lists.denx.de>; Sat, 25 Feb 2023 23:37:40 +0100 (CET)","by mail-vs1-xe2a.google.com with SMTP id df20so5318538vsb.3\n for <u-boot@lists.denx.de>; Sat, 25 Feb 2023 14:37:40 -0800 (PST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE,\n SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:from:to:cc:subject:date\n :message-id:reply-to;\n bh=ugB4PZ5VpqyWllFg64S/O4R8if8njwQXHkrNKQDtCiA=;\n b=hi1Pgon5Nj/Ipbjx1+M8GxBuYpijyx9dfuGp0rIHnMsLDkB+Gey46bzVgZqa6Xz+4A\n ZRWrMXzqoBI0xmewh3oH5ugo+Fc7sZoRTT29o4tj0z9NBIpLm57PYwf5f3yiv9jUpbv4\n 3jJTwsXaU6mT5EzWVw7FvpELpj+v832Dj+PxbJ1A9ihlH/KJOiXm9ocp1jGOszO9eQB8\n l0NSn0fEulfzc7PR0qur7xQXtdPTRywqf1ZULH/Lt6fZeWhiLKOw+pO+G3S6agU1jyDn\n sCflxpvR3koKJxAMnu6GwnP/L/dbkX0JVKXO5nvQDcwg4VrvukD63MeG1nS2qc7OhsSA\n F9yA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=content-transfer-encoding:cc:to:subject:message-id:date:from\n :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=ugB4PZ5VpqyWllFg64S/O4R8if8njwQXHkrNKQDtCiA=;\n b=zgHNrjeqiqYARD06V/d7Xww7L7Avw+ybHqguj9Nv7lGvmtwG865MtRMhOV7+GXTaqj\n WL0nf6aTT5dvk4oqcZDPWdCfLEGEL7akWXI36+vgzMHk05beT8HoXRulbrFN8M/oyMvV\n f+P7aShB8P4g5Eu8oGu7qWy70ZsLwauRnZ0taA+mV68J41q1bIIi3aOi6zKR1c6tfTNo\n a3bOkwYGMja2g6t+in17Vo9Aai0/3uZ+oy1Lv3TITjK5TiO7x4XyF1oDqIO7iWR39fWl\n BGuH2mxGsxd57yV8777Xs0D2psq2I3bz4pNNAaxH8vnPqmkaI3Ql8P0t2wPZ7POirLob\n Zmxg==","X-Gm-Message-State":"AO0yUKXv355QTh3FT4TVg9MufxndhQ6xmEAiGwHsym4jxrvR073kmksM\n Ala07AQHZGeZ2n6Ou51D/kr/ZtPmrFae9cSM+Yk=","X-Google-Smtp-Source":"\n AK7set+NGmYRAgA0nu9fBKDve24+Ku5TgIMLsmRIAq7vnclE0nhx06XAzllnGzNCWFXo93fyipdcCSHR7Cu58yeYIno=","X-Received":"by 2002:a05:6102:34f2:b0:412:2f2a:c3ae with SMTP id\n bi18-20020a05610234f200b004122f2ac3aemr5152618vsb.2.1677364658719; Sat, 25\n Feb 2023 14:37:38 -0800 (PST)","MIME-Version":"1.0","References":"<20230221201925.9644-1-pali@kernel.org>\n <20230221201925.9644-58-pali@kernel.org>\n <CAJaLiFzbRxoO4GyXHQsV3Q2nQxBAWa7eevY5L_R1E1u4rAq9VQ@mail.gmail.com>\n <20230225211325.hj3z22y2gbajhclb@pali>","In-Reply-To":"<20230225211325.hj3z22y2gbajhclb@pali>","From":"Tony Dinh <mibodhi@gmail.com>","Date":"Sat, 25 Feb 2023 14:37:27 -0800","Message-ID":"\n <CAJaLiFybFwAaEbUa=GuyKi6inHTT64DXKdPwv25m2Vg+dLy9eQ@mail.gmail.com>","Subject":"Re: [PATCH RFC u-boot-mvebu 57/59] arm: mvebu: Define\n env_sf_get_env_addr() also for Proper U-Boot","To":"=?utf-8?q?Pali_Roh=C3=A1r?= <pali@kernel.org>","Cc":"u-boot@lists.denx.de, Stefan Roese <sr@denx.de>,\n Josua Mayer <josua@solid-run.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.6 at phobos.denx.de","X-Virus-Status":"Clean"}}]