U-boot Archive mirror
 help / color / mirror / Atom feed
From: jasper@fancydomain.eu
To: u-boot@lists.denx.de
Cc: joe.hershberger@ni.com, Jasper Orschulko <jasper@fancydomain.eu>,
	Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
Subject: [PATCH] env: Invert gd->env_valid for env_mmc_save
Date: Fri, 10 May 2024 13:38:34 +0200	[thread overview]
Message-ID: <20240510113834.826783-1-jasper@fancydomain.eu> (raw)

From: Jasper Orschulko <jasper@fancydomain.eu>

The A/B update strategy of the env's has a gap in the first 2 calls of saveenv.
The env's are stored twice on the first memory area if:
gd->env_valid == ENV_INVALID.

u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(1)... OK
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(1)... OK  <-- !!!
u-boot=> saveenv
Saving Environment to MMC... Writing to redundant MMC(1)... OK
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(1)... OK

Signed-off-by: Michael Glembotzki <Michael.Glembotzki@iris-sensing.com>
Signed-off-by: Jasper Orschulko <jasper@fancydomain.eu>
---
 env/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/mmc.c b/env/mmc.c
index 7afb733e890..2bef30c973c 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -299,7 +299,7 @@ static int env_mmc_save(void)
 	ret = 0;
 
 	if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT))
-		gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
+		gd->env_valid = gd->env_valid == ENV_VALID ? ENV_REDUND : ENV_VALID;
 
 fini:
 	fini_mmc_for_env(mmc);
-- 
2.45.0


             reply	other threads:[~2024-05-10 12:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 11:38 jasper [this message]
2024-05-17 18:51 ` [PATCH] env: Invert gd->env_valid for env_mmc_save Tom Rini
2024-05-20 10:43   ` Jasper Orschulko
2024-05-21  8:16     ` AW: " Michael Glembotzki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240510113834.826783-1-jasper@fancydomain.eu \
    --to=jasper@fancydomain.eu \
    --cc=Michael.Glembotzki@iris-sensing.com \
    --cc=joe.hershberger@ni.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).