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 D6C5BECAAD3 for ; Wed, 14 Sep 2022 09:18:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 369BE84607; Wed, 14 Sep 2022 11:18:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.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=foss.st.com header.i=@foss.st.com header.b="4KJxRGBc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EFCF884AE7; Wed, 14 Sep 2022 11:18:06 +0200 (CEST) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 4C65B84180 for ; Wed, 14 Sep 2022 11:18:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=5256cc2314=patrick.delaunay@foss.st.com Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28E94PPp008939; Wed, 14 Sep 2022 11:18:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : references : in-reply-to : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=selector1; bh=YYXsjS4wbEzxVBDeFrzc4P9NunHsNPGPDg/LDiqRe38=; b=4KJxRGBcVS0nqHhafa0uECOR1wfj9Ws2CEIBYKu7ufGh8MamxC43oRKVQWleoBWtpM9+ QYTyjUfudRtjo4RFreC5UYcvTC9ajnd4A79inLHp2zCRVoSN+hDVbzSRNxwl+iMBWemU 75VRVcbp091Ia3XtEjEGrf1sRHGhPEU3i4fAe0p7MB8XT8qbKoyPtZsec09HPhQBf4hu 26GCjhlHVXWc8qZ/vAeLCXwekmKFeZd2z1M6IhxCTZct7BcJMzzHMo9zTHuncThGcxUx C2naeUAIDUP3U1NMEftit0qz/FiKa9MWbuJzRYi7IAFcopqs+n2lv4VyY+kKkq/NWKU9 ig== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3jjxxam7j3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 11:18:00 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6CC28100034; Wed, 14 Sep 2022 11:17:59 +0200 (CEST) Received: from Webmail-eu.st.com (eqndag1node6.st.com [10.75.129.135]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5F361217B7E; Wed, 14 Sep 2022 11:17:59 +0200 (CEST) Received: from LMECWL0930 (10.75.127.51) by EQNDAG1NODE6.st.com (10.75.129.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.31; Wed, 14 Sep 2022 11:17:26 +0200 From: To: 'Quentin Schulz' , 'Kever Yang' , 'Quentin Schulz' CC: , , , , References: <20220722160655.3904213-1-foss+uboot@0leil.net> <20220722160655.3904213-8-foss+uboot@0leil.net> <252a1ebe-ba21-adca-bdb7-9aff5560db7f@rock-chips.com> <1804479d-02ef-ee05-1d4b-f56eac6a1250@theobroma-systems.com> <873d5eaa-b0ee-ae55-143b-8ddb340b2fbf@rock-chips.com> <4feb827e-3932-c8d6-120e-5465ad92eac2@theobroma-systems.com> In-Reply-To: <4feb827e-3932-c8d6-120e-5465ad92eac2@theobroma-systems.com> Subject: RE: [PATCH 07/12] rockchip: puma-rk3399: load environment from same medium as one used to load U-Boot proper Date: Wed, 14 Sep 2022 11:17:26 +0200 Message-ID: <000f01d8c81a$cecb1430$6c613c90$@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: fr Thread-Index: AQIX8p61x16sPMEYLcllioum/KY+fAIlTCQwAX48KOUBXKUWGQJUIB4XAhDX416tFSS9kA== msip_labels: MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_Enabled=true; MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_SetDate=2022-09-14T09:17:25Z; MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_Method=Standard; MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_Name=23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0; MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_SiteId=75e027c9-20d5-47d5-b82f-77d7cd041e8f; MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_ActionId=04631a22-cc35-44cd-b633-ded1a9219aef; MSIP_Label_23add6c0-cfdb-4bb9-b90f-bf23b83aa6c0_ContentBits=2 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To EQNDAG1NODE6.st.com (10.75.129.135) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-14_03,2022-09-14_01,2022-06-22_01 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 Hi, ST Restricted > -----Original Message----- > From: U-Boot On Behalf Of Quentin = Schulz > Sent: mardi 6 septembre 2022 11:23 > To: Kever Yang ; Quentin Schulz > > Cc: sjg@chromium.org; philipp.tomsich@vrull.eu; klaus.goger@theobroma- > systems.com; knaerzche@gmail.com; u-boot@lists.denx.de > Subject: Re: [PATCH 07/12] rockchip: puma-rk3399: load environment = from same > medium as one used to load U-Boot proper >=20 > Hi Kever, >=20 > On 9/4/22 13:49, Kever Yang wrote: > > Hi Quentin, > > > > The Kconfig from env/Kconfig > > > > config ENV_IS_NOWHERE > > bool "Environment is not stored" > > default y if !ENV_IS_IN_EEPROM && !ENV_IS_IN_EXT4 && \ > > !ENV_IS_IN_FAT && !ENV_IS_IN_FLASH && \ > > !ENV_IS_IN_MMC && !ENV_IS_IN_NAND && \ > > !ENV_IS_IN_NVRAM && !ENV_IS_IN_ONENAND && \ > > !ENV_IS_IN_REMOTE && !ENV_IS_IN_SPI_FLASH && \ > > !ENV_IS_IN_UBI > > > > I think the logic is the env parameter is stored on some kind of > > storage, or NOWHERE. > > >=20 > It's *default* to yes if none is defined. It's not a requirement. >=20 > > And what you want to do is to load from the same medium as SPL boot > > device(location of U-Boot proper), > > > > this could not be NOWHERE. > > >=20 > This can be nowhere in case the proper config option is not selected. > E.g. we're booting from SPI-NOR but the ENV_IS_IN_SPI_FLASH is not = set. > How does one handle this scenario? Since we don't want fallbacks, it = needs to be > "nowhere". What you're suggesting is to let the user run a broken = build and have it > cryptically crash with the following error: >=20 > initcall sequence 00000000002866c0 failed at call 0000000000256b34 = (err=3D-19) >=20 > Instead, I suggest to more gracefully error out at runtime by letting = the user know > that the option is not compiled in but U-Boot is still usable. >=20 > If you have another way to forbid fallbacks but not crash U-Boot in = case the option > is not selected, let me know. > For information : It is exactly that I do to stm32mp15 platform See board/st/stm32mp1/stm32mp1.c::env_get_location() ENV_IS_NOWHERE =3D use the default environment, embedded in U-Boot and = env It is the fallback if environment not activated ENV_IS_IN_* for the = boot device, even it is not the case by default in stm32mp15_defconfig. And it is why , I change Kconfig to allow activation of any ENV_IS_IN_* = and ENV_IS_NOWHERE Patrick =20 > Cheers, > Quentin > > > > Thanks, > > > > - Kever > > > > On 2022/9/1 21:13, Quentin Schulz wrote: > >> Hi Kever > >> > >> On 9/1/22 15:03, Kever Yang wrote: > >>> Hi Quentin, > >>> > >>> On 2022/7/23 00:06, Quentin Schulz wrote: > >>>> From: Quentin Schulz > >>>> > >>>> Chances are when one boots U-Boot proper from a given storage > >>>> medium, they want the same medium to be used to load and store = the > environment. > >>>> > >>>> This basically allows to have completely separate U-Boot > >>>> (TPL/SPL/U-Boot > >>>> proper/environment) per storage medium which is convenient when > >>>> working with recovery from SD-Card as one would just need to = insert > >>>> a properly configured SD-Card into the device to have access to > >>>> their whole debug setup. > >>>> > >>>> No fallback mechanism is provided as to not dirty other storage > >>>> medium environment by mistake. However, since > >>>> arch_env_get_location() is called by env_init() which is part of > >>>> the pre-relocation process, a valid, non-ENVL_UNKNOWN, value = shall > >>>> be returned otherwise the relocation fails with the following > >>>> message: > >>>> initcall sequence 00000000002866c0 failed at call = 0000000000256b34 > >>>> (err=3D-19) > >>>> > >>>> This valid, non-ENVL_UNKNOWN, value is ENVL_NOWHERE which > requires > >>>> to always select CONFIG_ENV_IS_NOWHERE otherwise this work-around > >>>> does not work. > >>>> > >>>> Cc: Quentin Schulz > >>>> Signed-off-by: Quentin Schulz > >>>> > >>>> --- > >>>> > >>>> Depends on > >>>> = https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__lore.kernel.or > >>>> = g_u-2Dboot_20220715151552.953654-2D1-2Dfoss-2Buboot-400leil.net_&d=3D > >>>> > DwIDaQ&c=3D_sEr5x9kUWhuk4_nFwjJtA&r=3DLYjLexDn7rXIzVmkNPvw5ymA1XTSq > HGq8 > >>>> yBP6m6qZZ4njZguQhZhkI_- > 172IIy1t&m=3DTZndtGz1ePTd2Il6YcEjqzo9oXv73RCWH > >>>> > IRVSiFVsnp2OzyCJEDzZ2KPz56AcWdn&s=3DwgEMbr3EjeCtvcWU_UoXqNOwQula > VN-0Q > >>>> b2yL2ysaOs&e=3D > >>>> = https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__lore.kernel.or > >>>> = g_u-2Dboot_20220715151552.953654-2D2-2Dfoss-2Buboot-400leil.net_&d=3D > >>>> > DwIDaQ&c=3D_sEr5x9kUWhuk4_nFwjJtA&r=3DLYjLexDn7rXIzVmkNPvw5ymA1XTSq > HGq8 > >>>> yBP6m6qZZ4njZguQhZhkI_- > 172IIy1t&m=3DTZndtGz1ePTd2Il6YcEjqzo9oXv73RCWH > >>>> > IRVSiFVsnp2OzyCJEDzZ2KPz56AcWdn&s=3DPKwYBMB7r8ekIPV1ZG7xkj7vF60YN > FlYX > >>>> QRrvaVgJR8&e=3D > >>>> .../puma_rk3399/puma-rk3399.c | 37 > >>>> +++++++++++++++++++ > >>>> configs/puma-rk3399_defconfig | 1 + > >>>> 2 files changed, 38 insertions(+) > >>>> > >>>> diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c > >>>> b/board/theobroma-systems/puma_rk3399/puma-rk3399.c > >>>> index 5e5e58c88e..7ef4bac24b 100644 > >>>> --- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c > >>>> +++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c > >>>> @@ -6,6 +6,7 @@ > >>>> #include > >>>> #include > >>>> #include > >>>> +#include > >>>> #include > >>>> #include > >>>> #include > >>>> @@ -135,6 +136,42 @@ int mmc_get_env_dev(void) > >>>> return CONFIG_SYS_MMC_ENV_DEV; > >>>> } > >>>> +#if !IS_ENABLED(CONFIG_ENV_IS_NOWHERE) > >>>> +#error Please enable CONFIG_ENV_IS_NOWHERE #endif > >>>> + > >>>> +enum env_location arch_env_get_location(enum env_operation op, = int > >>>> prio) > >>>> +{ > >>>> + const char *boot_device =3D > >>>> + ofnode_read_chosen_string("u-boot,spl-boot-device"); > >>>> + > >>>> + if (prio > 0) > >>>> + return ENVL_UNKNOWN; > >>>> + > >>>> + if (!boot_device) { > >>>> + debug("%s: /chosen/u-boot,spl-boot-device not set\n", > >>>> + __func__); > >>>> + return ENVL_NOWHERE; > >>>> + } > >>>> + > >>>> + debug("%s: booted from %s\n", __func__, boot_device); > >>>> + > >>>> + if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) && > >>>> + !strcmp(boot_device, "/spi@ff1d0000/flash@0")) > >>>> + return ENVL_SPI_FLASH; > >>>> + > >>>> + if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC) && > >>>> + (!strcmp(boot_device, "/mmc@fe320000") || > >>>> + !strcmp(boot_device, "/mmc@fe330000"))) > >>>> + return ENVL_MMC; > >>>> + > >>>> + printf("%s: No environment available: booted from %s but = U-Boot " > >>>> + "config does not allow loading environment from it.", > >>>> + __func__, boot_device); > >>>> + > >>>> + return ENVL_NOWHERE; > >>>> +} > >>>> + > >>>> int misc_init_r(void) > >>>> { > >>>> const u32 cpuid_offset =3D 0x7; diff --git > >>>> a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig > >>>> index 87d7e4f57c..e218532d70 100644 > >>>> --- a/configs/puma-rk3399_defconfig > >>>> +++ b/configs/puma-rk3399_defconfig > >>>> @@ -44,6 +44,7 @@ CONFIG_SPL_OF_CONTROL=3Dy > >>>> CONFIG_OF_LIVE=3Dy > >>>> CONFIG_OF_SPL_REMOVE_PROPS=3D"interrupt-parent assigned-clocks > >>>> assigned-clock-rates assigned-clock-parents" > >>>> CONFIG_ENV_OVERWRITE=3Dy > >>>> +CONFIG_ENV_IS_NOWHERE=3Dy > >>> > >>> This option is conflict with CONFIG_ENV_IS_IN_MMC, please check > >>> again where should be this board get the env. > >>> > >> > >> I created the defconfig with make savedefconfig, so if you're = talking > >> about KConfig conflict, that is incorrect, there is no conflict. > >> > >> If you're talking about something else, please clarify because I > >> don't see the issue right now. > >> > >> Cheers, > >> Quentin