Crash in env_relocate_spec() of env_mmc.c
PATCH 1/1 Crash in env_relocate_spec() of env_mmc.c
mmc_initialize is not called at the startup if the relocation takes place and the environment is stored into a MMC card.
--- arch/arm/lib/board.c | 10 +++++----- common/env_mmc.c | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-)
arch/arm/lib/board.c +5 -5
@@ -775,6 +775,11 @@ void board_init_r (gd_t *id, ulong dest_addr)nand_init ();/* go init the NAND */ #endif +#ifdef CONFIG_GENERIC_MMC +puts ("MMC: " ); +mmc_initialize (bd); +#endif +#if defined(CONFIG_CMD_ONENAND )onenand_init ();#endif
@@ -854,11 +859,6 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr);board_late_init ();#endif -#ifdef CONFIG_GENERIC_MMC -puts ("MMC: " ); -mmc_initialize (gd->bd); -#endif -#ifdef CONFIG_BITBANGMII bb_miiphy_init ();#endif
common/env_mmc.c +5 -6
@@ -130,24 +130,23 @@ void env_relocate_spec(void) {#if !defined(ENV_IS_EMBEDDED )struct mmc *mmc =find_mmc_device (CONFIG_SYS_MMC_ENV_DEV ); +char buf[CONFIG_ENV_SIZE ];if (init_mmc_for_env (mmc))return ; -if (read_env (mmc,CONFIG_ENV_SIZE ,CONFIG_ENV_OFFSET , env_ptr)) -return use_default (); - -if (crc32 (0 , env_ptr->data,ENV_SIZE ) != env_ptr->crc) +if (read_env (mmc,CONFIG_ENV_SIZE ,CONFIG_ENV_OFFSET , buf))return use_default (); gd->env_valid =1 ; + +env_import (buf,1 );#endif }#if !defined(ENV_IS_EMBEDDED )static void use_default () { -puts ("*** Warning - bad CRC or MMC, using default environment\n\n" ); -set_default_env (); +set_default_env ("*** Warning - bad CRC or MMC, using default environment\n\n" ); }#endif
Signature · 1 line
1.6.3.3
PATCH 1/1 Crash in env_relocate_spec() of env_mmc.c
Hello.
Quoted 5 lines · Stefano Babic
mmc_initializeis not called at the startup if the relocation takes place and the environment is stored into a MMC card.Signed-off-by Stefano Babic<[email protected]>
[...]
arch/arm/lib/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 780
Quoted 11 lines
arch/arm/lib/board.c +3
-0@@ -775,6 +775,11 @@ void board_init_r (gd_t *id, ulong dest_addr)nand_init ();/* go init the NAND */ #endif +#ifdef CONFIG_GENERIC_MMC +puts ("MMC: " ); +mmc_initialize (bd);
This wouldn't pass checkpatch.pl. Spaces before ( are not allowed.
WBR, Sergei
PATCH 1/1 Crash in env_relocate_spec() of env_mmc.c
Quoted 2 lines · Sergei Shtylyov
Hello.
Hello Sergei,
Quoted 1 line
This wouldn't pass checkpatch.pl. Spaces before ( are not allowed.
Agree, thanks. I will wait until Steve's feedback to understand if the problem is really solved.
Best regards,
Stefano
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 Crash in env_relocate_spec() of env_mmc.c
In reply to Stefano BabicQuoted 35 lines · Stefano Babic
mmc_initializeis not called at the startup if the relocation takes place and the environment is stored into a MMC card.Signed-off-by Stefano Babic <[email protected]>---
?arch/arm/lib/board.c | ? 10 +++++----- ?common/env_mmc.c ? ? | ? 11 +++++------
?2 files changed, 10 insertions(+), 11 deletions(-)arch/arm/lib/board.c +0
-0@@ -775,6 +775,11 @@ void board_init_r (gd_t *id, ulong dest_addr)? ? ? ?nand_init(); ? ? ? ? ? ?/* go init the NAND */ ?#endif
arch/arm/lib/board.c +5
-0+#ifdef CONFIG_GENERIC_MMC + ? ? ? puts ("MMC: ? "); + ? ? ? mmc_initialize (bd); +#endif +?#if
defined(CONFIG_CMD_ONENAND)
? ? ? ?onenand_init();
?#endifarch/arm/lib/board.c +0
-0@@ -854,11 +859,6 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr); ? ? ? ?board_late_init ();?#endif
arch/arm/lib/board.c +0
-5-#ifdef CONFIG_GENERIC_MMC - ? ? ? puts ("MMC: ? "); - ? ? ? mmc_initialize (gd->bd); -#endif -
Quoted 3 lines
?#ifdef
CONFIG_BITBANGMII
? ? ? ?bb_miiphy_init();
?#endif
I think it might make more sense to put the MMC ifdef after the onenand code so that it doesn't split the nand/onenand grouping. Otherwise it matches what I did.
Quoted 9 lines
common/env_mmc.c +1
-0@@ -130,24 +130,23 @@ void env_relocate_spec(void) ?{ ?#if !defined(ENV_IS_EMBEDDED) ? ? ? ?struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); + ? ? ? char buf[CONFIG_ENV_SIZE];
common/env_mmc.c void env_relocate_spec(void) · line 139
Quoted 10 lines
common/env_mmc.c +1
-4? ? ? ?if (init_mmc_for_env(mmc)) ? ? ? ? ? ? ? ?return; - ? ? ? if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, env_ptr)) - ? ? ? ? ? ? ? return use_default(); - - ? ? ? if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc) + ? ? ? if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) ? ? ? ? ? ? ? ?return use_default();
This is a void function and shouldn't have a return value. I fixed this in my version.
common/env_mmc.c void env_relocate_spec(void) · line 140
Quoted 2 lines
common/env_mmc.c +0
-0? ? ? ?gd->env_valid = 1;
I removed this in my version, probably an error to do that though :-)
Quoted 11 lines
common/env_mmc.c +2
-0+ + ? ? ? env_import(buf, 1);?#endif
?}?#if !defined(ENV_IS_EMBEDDED)
?static voiduse_default()
?{
- ? ? ? puts ("*** Warning - bad CRC or MMC, using default environment\n\n");
- ? ? ?set_default_env();
+ ? ? ?set_default_env("*** Warning - bad CRC or MMC, using default environment\n\n");
I previously submitted a patch to fix this and Wolfgang sent an email saying that it had been applied.
Quoted 6 lines
?}
?#endif
--
1.6.3.3
I'll revise my patch to add the missing gd->env_valid = 1; and re-test.
Steve
PATCH 1/1 Crash in env_relocate_spec() of env_mmc.c
Quoted 87 lines · Steve Sakoman
Quoted 35 lines · Stefano Babic
mmc_initializeis not called at the startup if the relocation takes place and the environment is stored into a MMC card.Signed-off-by Stefano Babic <[email protected]>---
?arch/arm/lib/board.c | ? 10 +++++----- ?common/env_mmc.c ? ? | ? 11 +++++------
?2 files changed, 10 insertions(+), 11 deletions(-)arch/arm/lib/board.c +0
-0@@ -775,6 +775,11 @@ void board_init_r (gd_t *id, ulong dest_addr)? ? ? ?nand_init(); ? ? ? ? ? ?/* go init the NAND */ ?#endif
arch/arm/lib/board.c +5
-0+#ifdef CONFIG_GENERIC_MMC + ? ? ? puts ("MMC: ? "); + ? ? ? mmc_initialize (bd); +#endif +?#if
defined(CONFIG_CMD_ONENAND)
? ? ? ?onenand_init();
?#endifarch/arm/lib/board.c +0
-0@@ -854,11 +859,6 @@ extern void davinci_eth_set_mac_addr (const u_int8_t *addr); ? ? ? ?board_late_init ();?#endif
arch/arm/lib/board.c +0
-5-#ifdef CONFIG_GENERIC_MMC - ? ? ? puts ("MMC: ? "); - ? ? ? mmc_initialize (gd->bd); -#endif -Quoted 3 lines
?#ifdef
CONFIG_BITBANGMII
? ? ? ?bb_miiphy_init();
?#endifI think it might make more sense to put the MMC ifdef after the onenand code so that it doesn't split the nand/onenand grouping. Otherwise it matches what I did.
Quoted 9 lines
common/env_mmc.c +1
-0@@ -130,24 +130,23 @@ void env_relocate_spec(void) ?{ ?#if !defined(ENV_IS_EMBEDDED) ? ? ? ?struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); + ? ? ? char buf[CONFIG_ENV_SIZE];common/env_mmc.c void env_relocate_spec(void) · line 139
Quoted 10 lines
common/env_mmc.c +1
-4? ? ? ?if (init_mmc_for_env(mmc)) ? ? ? ? ? ? ? ?return; - ? ? ? if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, env_ptr)) - ? ? ? ? ? ? ? return use_default(); - - ? ? ? if (crc32(0, env_ptr->data, ENV_SIZE) != env_ptr->crc) + ? ? ? if (read_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) ? ? ? ? ? ? ? ?return use_default();This is a void function and shouldn't have a return value. ?I fixed this in my version.
common/env_mmc.c void env_relocate_spec(void) · line 140
Quoted 2 lines
common/env_mmc.c +0
-0? ? ? ?gd->env_valid = 1;I removed this in my version, probably an error to do that though :-)
Quoted 11 lines
common/env_mmc.c +2
-0+ + ? ? ? env_import(buf, 1);?#endif
?}?#if !defined(ENV_IS_EMBEDDED)
?static voiduse_default()
?{
- ? ? ? puts ("*** Warning - bad CRC or MMC, using default environment\n\n");
- ? ? ?set_default_env();
+ ? ? ?set_default_env("*** Warning - bad CRC or MMC, using default environment\n\n");I previously submitted a patch to fix this and Wolfgang sent an email saying that it had been applied.
Quoted 8 lines
Quoted 6 lines
?}
?#endif
--
1.6.3.3I'll revise my patch to add the missing
gd->env_valid= 1; and re-test.
Hmm . . . looking at env_nand.c I see that it doesn't do gd->env_valid = 1 either, which is probably why I removed it last night.
Any idea whether it is actually required? Seems to work fine without it!
Steve
PATCH 1/1 Crash in env_relocate_spec() of env_mmc.c
Quoted 6 lines · Steve Sakoman
Quoted 1 line
I'll revise my patch to add the missing
gd->env_valid= 1; and re-test.Hmm . . . looking at
env_nand.cI see that it doesn't dogd->env_valid= 1 either, which is probably why I removed it last night.Any idea whether it is actually required? Seems to work fine without it!
I have understood, it is not required if we call env_import and we require to verify the checksum.
Stefano
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 Crash in env_relocate_spec() of env_mmc.c
Quoted 11 lines · Stefano Babic
Quoted 6 lines · Steve Sakoman
Quoted 1 line
I'll revise my patch to add the missing
gd->env_valid= 1; and re-test.Hmm . . . looking at
env_nand.cI see that it doesn't dogd->env_valid= 1 either, which is probably why I removed it last night.Any idea whether it is actually required? ?Seems to work fine without it!
I have understood, it is not required if we call
env_importand we require to verify the checksum.
OK, thanks!
Would you like me to submit the patch or would you like to revise & resubmit?
Steve
PATCH 1/1 Crash in env_relocate_spec() of env_mmc.c
Quoted 7 lines · Steve Sakoman
Quoted 6 lines · Stefano Babic
Quoted 4 lines · Steve Sakoman
Quoted 1 line
I'll revise my patch to add the missing
gd->env_valid= 1; and re-test.Hmm . . . looking at
env_nand.cI see that it doesn't dogd->env_valid= 1 either, which is probably why I removed it last night.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Any idea whether it is actually required? Seems to work fine without it!
I have understood, it is not required if we call
env_importand we require to verify the checksum.OK, thanks!
Would you like me to submit the patch or would you like to revise & resubmit?
No problem at all - you can submit your patch, as it seems to me more complete as mine.
Stefano
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 Crash in env_relocate_spec() of env_mmc.c
In reply to Steve SakomanQuoted 5 lines · Steve Sakoman
Quoted 4 lines · Stefano Babic
mmc_initializeis not called at the startup if the relocation takes place and the environment is stored into a MMC card.
Hallo Steve,
Quoted 3 lines
I think it might make more sense to put the MMC ifdef after the onenand code so that it doesn't split the nand/onenand grouping. Otherwise it matches what I did.
Yes, it makes more sens - and I do not see any problem to move it
Quoted 3 lines
This is a void function and shouldn't have a return value. I fixed this in my version.
Agree.
Quoted 4 lines
Quoted 2 lines
gd->env_valid = 1;I removed this in my version, probably an error to do that though :-)
Or probably not...env_valid should signalize if the checksum is correct, and now the checksum is verified by the env_import function, as I have understood.
Quoted 2 lines
I previously submitted a patch to fix this and Wolfgang sent an email saying that it had been applied.
Ah, ok, I have missed it ;-)
Quoted 1 line
I'll revise my patch to add the missing
gd->env_valid= 1; and re-test.
Ok, thanks
Stefano
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 =====================================================================