env_sf - Do not free flash environment on successful read
PATCH 1/1 env_sf - Do not free flash environment on successful read
In env_relocate_spec(), env_flash is freed and set to NULL if CONFIG_ENV_OFFSET_REDUND is undefined. This leads to an "Environment SPI flash not initialized" error when performing a saveenv.
br,
Oliver
common/env_sf.c +3 -0
@@ -384,7 +384,10 @@ void env_relocate_spec(void) ret =env_import (buf,1 );if (ret) + { gd->env_valid =1 ; +return ; + } out:spi_flash_free (env_flash); env_flash =NULL ;
PATCH 1/1 env_sf - Do not free flash environment on successful read
Dear Oliver Dillinger,
Quoted 7 lines · In message <[email protected]> you wrote:
In
env_relocate_spec(),env_flashis freed and set to NULL ifCONFIG_ENV_OFFSET_REDUNDis undefined. This leads to an "Environment SPI flash not initialized" error when performing a saveenv.br,
Oliver
Please read http://www.denx.de/wiki/U-Boot/Patches
common/env_sf.c void env_relocate_spec(void) · line 387
Quoted 9 lines
common/env_sf.c +1
-0@@ -384,7 +384,10 @@ void env_relocate_spec(void) ret =env_import (buf,1 );if (ret) + {
Incorrect brace style.
common/env_sf.c void env_relocate_spec(void) · line 389
Quoted 2 lines
common/env_sf.c +1
-0gd->env_valid =1 ; +return ;
Your patch is white-space corrupted.
Also, this patch is not correct. It is OK to call spi_flash_free() here.
The bug is in saveenv() for the non-redundant case. The function has not been dapted to the new environment code, at all; for example, it fails to actually export the internally stored environment [there is no call to hexport()].
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "I think they're going to take all this money that we spend now on war and death --" "And make them spend it on life." -- Edith Keeler and Kirk, "The City on the Edge of Forever", stardate unknown.
PATCH 1/1 env_sf - Do not free flash environment on successful read
Quoted 2 lines · Wolfgang Denk
Dear Oliver Dillinger,
Hi Wolfgang,
Quoted 8 lines
Also, this patch is not correct. It is OK to call
spi_flash_free()here.The bug is in
saveenv()for the non-redundant case. The function has not been dapted to the new environment code, at all; for example, it fails to actually export the internally stored environment [there is no call tohexport()].
You mean there are several bugs here....if spi_flash_free() is correct, then spi_flash_probe must be called inside the saveenv function, in case env_flash is not set (so it is called only once).
And IMHO spi_flash_free() should be called for the redundant case, too (why is it different from the non-redundant case?).
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH 1/1 env_sf - Do not free flash environment on successful read
Dear Stefano Babic,
Quoted 6 lines · In message <[email protected]> you wrote:
You mean there are several bugs here....if
spi_flash_free()is correct, thenspi_flash_probemust be called inside the saveenv function, in caseenv_flashis not set (so it is called only once).
And IMHOspi_flash_free()should be called for the redundant case, too (why is it different from the non-redundant case?).
Right. There are quite a number of different bugs in that code, and potential for cleanup / optimization - ther eis probably no need to have two different versions of the saveenv() function when only a few lines are different.
The submitted patch would not help, though, as only the old environment would be written back.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Anyone who knows history, particularly the history of Europe, will, I think, recognize that the domination of education or of government by any one particular religious faith is never a happy arrangement for the people. - Eleanor Roosevelt