Message ID | 20230704061607.20798-1-ashok.reddy.soma@amd.com |
---|---|
State | Accepted |
Commit | 4dc5e26242101f9090209e659e60422634c8bbcf |
Delegated to: | Tom Rini |
Headers | show |
Series | env: Fix default environment saving issue | expand |
On Tue, 4 Jul 2023 at 07:16, Ashok Reddy Soma <ashok.reddy.soma@amd.com> wrote: > > When CONFIG_SYS_REDUNDAND_ENVIRONMENT is enabled, by default env is > getting saved to redundant environment irrespective of primary env is > present or not. > > It means even if primary and redundant environment are not present, by > default, env is getting stored to redundant environment. Even if primary > env is present, it is choosing to store in redudndant env. > > Ideally it should look for primary env and choose to store in primary env > if it is present. If both primary and redundant env are not present then > it should save in to primary env area. > > Fix the issue by making env_valid = ENV_INVALID when both the > environments are not present. > > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com> > --- > > env/common.c | 1 + > 1 file changed, 1 insertion(+) > Reviewed-by: Simon Glass <sjg@chromium.org> Can a test be added for this? > diff --git a/env/common.c b/env/common.c > index 8beb8e6aa4..0ecdb248a0 100644 > --- a/env/common.c > +++ b/env/common.c > @@ -353,6 +353,7 @@ int env_check_redund(const char *buf1, int buf1_read_fail, > tmp_env2->crc; > > if (!crc1_ok && !crc2_ok) { > + gd->env_valid = ENV_INVALID; > return -ENOMSG; /* needed for env_load() */ > } else if (crc1_ok && !crc2_ok) { > gd->env_valid = ENV_VALID; > -- > 2.17.1 >
On 7/4/23 08:16, Ashok Reddy Soma wrote: > When CONFIG_SYS_REDUNDAND_ENVIRONMENT is enabled, by default env is > getting saved to redundant environment irrespective of primary env is > present or not. > > It means even if primary and redundant environment are not present, by > default, env is getting stored to redundant environment. Even if primary > env is present, it is choosing to store in redudndant env. > > Ideally it should look for primary env and choose to store in primary env > if it is present. If both primary and redundant env are not present then > it should save in to primary env area. > > Fix the issue by making env_valid = ENV_INVALID when both the > environments are not present. > > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com> > --- > > env/common.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/env/common.c b/env/common.c > index 8beb8e6aa4..0ecdb248a0 100644 > --- a/env/common.c > +++ b/env/common.c > @@ -353,6 +353,7 @@ int env_check_redund(const char *buf1, int buf1_read_fail, > tmp_env2->crc; > > if (!crc1_ok && !crc2_ok) { > + gd->env_valid = ENV_INVALID; > return -ENOMSG; /* needed for env_load() */ > } else if (crc1_ok && !crc2_ok) { > gd->env_valid = ENV_VALID; Applied. M
On Tue, Jul 04, 2023 at 12:16:07AM -0600, Ashok Reddy Soma wrote: > When CONFIG_SYS_REDUNDAND_ENVIRONMENT is enabled, by default env is > getting saved to redundant environment irrespective of primary env is > present or not. > > It means even if primary and redundant environment are not present, by > default, env is getting stored to redundant environment. Even if primary > env is present, it is choosing to store in redudndant env. > > Ideally it should look for primary env and choose to store in primary env > if it is present. If both primary and redundant env are not present then > it should save in to primary env area. > > Fix the issue by making env_valid = ENV_INVALID when both the > environments are not present. > > Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com> > Reviewed-by: Simon Glass <sjg@chromium.org> Applied to u-boot/master, thanks!
diff --git a/env/common.c b/env/common.c index 8beb8e6aa4..0ecdb248a0 100644 --- a/env/common.c +++ b/env/common.c @@ -353,6 +353,7 @@ int env_check_redund(const char *buf1, int buf1_read_fail, tmp_env2->crc; if (!crc1_ok && !crc2_ok) { + gd->env_valid = ENV_INVALID; return -ENOMSG; /* needed for env_load() */ } else if (crc1_ok && !crc2_ok) { gd->env_valid = ENV_VALID;
When CONFIG_SYS_REDUNDAND_ENVIRONMENT is enabled, by default env is getting saved to redundant environment irrespective of primary env is present or not. It means even if primary and redundant environment are not present, by default, env is getting stored to redundant environment. Even if primary env is present, it is choosing to store in redudndant env. Ideally it should look for primary env and choose to store in primary env if it is present. If both primary and redundant env are not present then it should save in to primary env area. Fix the issue by making env_valid = ENV_INVALID when both the environments are not present. Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@amd.com> --- env/common.c | 1 + 1 file changed, 1 insertion(+)