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 46AF7C43334 for ; Mon, 20 Jun 2022 15:35:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D58381F8B; Mon, 20 Jun 2022 17:35:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="TYwweNgC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D87D281F4E; Mon, 20 Jun 2022 17:35:15 +0200 (CEST) Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) (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 EF8E682068 for ; Mon, 20 Jun 2022 17:35:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf33.google.com with SMTP id g18so8869107qvn.2 for ; Mon, 20 Jun 2022 08:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4W7BuVAtnFPadI/Swc//Rs6b+WNgdUKddpUYPuseG8M=; b=TYwweNgC9/shUtgZbjT0x3PBzyx8I4LFA3Hzkf/MCTOz5S0ZgGfBnw2bZGs0RsmKkC Wxs6Olw3x2pRu90bdHEWryEvpLumPtp5sOMoktnpEfFKPKM3nw63hXu8nXIrMSDFS7s4 CYKn0CdWTnXpJIjKa5Ev5tjegOWvvaFVY8kzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4W7BuVAtnFPadI/Swc//Rs6b+WNgdUKddpUYPuseG8M=; b=TyH4hc101YB1rchEVQIDu8hk3oOlK96tOcMZZe7z1iLH74ES0xOnB6IdvwEvK/3+zI kbBEPVTBRcIobUYlnVvB2409RbBXZ3WeHU9y5NQ0i5q1ZtaiPAXJucSNzptNoHLYUolB JpH9U7+7fXM+6lHhcBnh3p7TrjalhDGA0g5mojmOd3H7a6rC0bHnwMc57Tq+47qgs+T0 XCBCnIcoGKJxp3iEE9LIZuKDU4g+xyzgsosFaJpKIqCmD0HTd+Gv8tV7VgRENdPcA0vV eTm9rzt/3ba+DiThsBN9fsS83YIlRnVJanVZMCwm/LzwIRhEQWCAkdYUctaF2PlaI+qB UXGw== X-Gm-Message-State: AJIora/h736saxudNRanJMoQ5KRua7RXaaxTQ+CqntHeEgAXM5dXQZXu n0cTKjDzc8JBxs+Pjatmmp9Y5w== X-Google-Smtp-Source: AGRyM1vSKJO1IVbcKG2vqSnomKtr4hQ7zI0nqkOt/Y3U4QV5dEKQncJyy0Sv9+Npglzt4dZPg02xSw== X-Received: by 2002:ac8:57c9:0:b0:304:fd1b:df4e with SMTP id w9-20020ac857c9000000b00304fd1bdf4emr20247164qta.512.1655739306414; Mon, 20 Jun 2022 08:35:06 -0700 (PDT) Received: from bill-the-cat (cpe-65-184-195-139.ec.res.rr.com. [65.184.195.139]) by smtp.gmail.com with ESMTPSA id dz18-20020a05620a2b9200b006a71729a139sm11298907qkb.44.2022.06.20.08.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 08:35:05 -0700 (PDT) Date: Mon, 20 Jun 2022 11:35:03 -0400 From: Tom Rini To: Holger Brunck Cc: Aleksandar Gerasimovski , Francis Laniel , "u-boot@lists.denx.de" , Marek Behun , Michael Nazzareno Trimarchi , Simon Glass , Wolfgang Denk , Harald Seiler , Heiko Schocher Subject: Re: [RFC PATCH v4 28/28] board: keymile: common: Use environment to store IVM_* variables. Message-ID: <20220620153503.GN2484912@bill-the-cat> References: <20220616223158.9225-1-francis.laniel@amarulasolutions.com> <20220616223158.9225-29-francis.laniel@amarulasolutions.com> <20220617144821.GY2484912@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w6/GShUg0RkggT2p" Content-Disposition: inline In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett 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 --w6/GShUg0RkggT2p Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 20, 2022 at 03:27:34PM +0000, Holger Brunck wrote: > Hi Francis, >=20 > > On Fri, Jun 17, 2022 at 12:31:58AM +0200, Francis Laniel wrote: > >=20 > > > These boards used set_local_var() to store some variables as local sh= ell. > > > They then used get_local_var() to retrieve the variables values. > > > > > > Instead of using local shell variables, they should use environment > > > ones (like a majority of board). > > > So, this patch converts using local variables to environment ones. > > > >=20 > why do we need to change that? It is intended that we use this hush varia= ble > infrastructure from u-boot (common/hush.c) for our IVM data and not the > standard env. We read the IVM at boot time and store these values in > RAM. It is not intended to store them permanently in the flash or wherever > the environment is saved. Especially in our case we have some boards where > the environment is in a i2c EEPROM and we don't want to write down to > the EEPROM each time when the board is starting. So, the whole series is about updating hush to bring in a new baseline version of the shell, from busybox. > > > Signed-off-by: Francis Laniel > > > --- > > > board/keymile/common/common.c | 8 ++++---- > > > board/keymile/common/ivm.c | 9 +-------- > > > 2 files changed, 5 insertions(+), 12 deletions(-) > > > > > > diff --git a/board/keymile/common/common.c > > > b/board/keymile/common/common.c index 3999f48719..72939af36e 100644 > > > --- a/board/keymile/common/common.c > > > +++ b/board/keymile/common/common.c > > > @@ -219,7 +219,7 @@ static int do_setboardid(struct cmd_tbl *cmdtp, i= nt > > flag, int argc, > > > unsigned char buf[32]; > > > char *p; > > > > > > - p =3D get_local_var("IVM_BoardId"); > > > + p =3D env_get("IVM_BoardId"); > > > if (!p) { > > > printf("can't get the IVM_Boardid\n"); > > > return 1; > > > @@ -228,7 +228,7 @@ static int do_setboardid(struct cmd_tbl *cmdtp, i= nt > > flag, int argc, > > > env_set("boardid", (char *)buf); > > > printf("set boardid=3D%s\n", buf); > > > > > > - p =3D get_local_var("IVM_HWKey"); > > > + p =3D env_get("IVM_HWKey"); > > > if (!p) { > > > printf("can't get the IVM_HWKey\n"); > > > return 1; > > > @@ -272,14 +272,14 @@ static int do_checkboardidhwk(struct cmd_tbl > > *cmdtp, int flag, int argc, > > > * first read out the real inventory values, these values are > > > * already stored in the local hush variables > > > */ > > > - p =3D get_local_var("IVM_BoardId"); > > > + p =3D env_get("IVM_BoardId"); > > > if (!p) { > > > printf("can't get the IVM_Boardid\n"); > > > return 1; > > > } > > > rc =3D strict_strtoul(p, 16, &ivmbid); > > > > > > - p =3D get_local_var("IVM_HWKey"); > > > + p =3D env_get("IVM_HWKey"); > > > if (!p) { > > > printf("can't get the IVM_HWKey\n"); > > > return 1; > > > diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c > > > index 67db0c50f4..e266d7ce81 100644 > > > --- a/board/keymile/common/ivm.c > > > +++ b/board/keymile/common/ivm.c > > > @@ -44,14 +44,7 @@ static int ivm_calc_crc(unsigned char *buf, int > > > len) > > > > > > static int ivm_set_value(char *name, char *value) { > > > - char tempbuf[256]; > > > - > > > - if (value) { > > > - sprintf(tempbuf, "%s=3D%s", name, value); > > > - return set_local_var(tempbuf, 0); > > > - } > > > - unset_local_var(name); > > > - return 0; > > > + return env_set(name, value); >=20 > this means we are now writing always down to the permanent > environment or? And this I would really like to avoid in our case. Note that "env_set" does not force a save of the running environment. These variables will be exposed to the CLI run-time, which I am not sure if they are today, so if the user then does "saveenv" they will be written. That I think would be a functional difference. --=20 Tom --w6/GShUg0RkggT2p Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmKwk58ACgkQFHw5/5Y0 tyy56gv9Ffb8rDtz0WZJ3Iaz72oZBNvNFsXKtr5iAt8RNa9WaDQ44o+UPOvQW6lV YJ2deZnEHk6o2gchG31bcPlDmMHxL9d3SqS7USl28xzY+9I8f10dEp5xASHkmenK bkbXzEZxe6OQF3NdTnottoBlIlFyatYyud0JAi2ytZ6uhLuTSi/MY/H24F7AeSNT /kW2Ytj2ZGMMiyZDWq1HjO4aYh7xIAscS/Xp7Z6Vocuro+JNhlpATo7HE+bsfSGn OTZlmzqRtoF8vG6gHESPLEjLlJ7Fery786Yy73EYsrQyvJkHVFrxd+JIbhxI25vk ebFdPmzCT6z6SU6GBiW1kOoUiEy+ZRdxuhkBytwVgGbWbwBcGaH6PGRHFC9HKJRN k/hl6GyL2TxmRLLQVRsM8Lj5Brpj32tlOUEpSlP1cf/uxH9VpkRTY/RnRopkAFnM hmzm4salSZfv+wCxSgw6BOd5NEXYseuhv8TGaPsbAzPdmUBnvQYepa9bjyGYIx99 pDTsDmFc =91EK -----END PGP SIGNATURE----- --w6/GShUg0RkggT2p--