Change CFG_ENV_SIZE to CFG_ENV_SECT_SIZE for SPI sector erase
PATCH 1/1 Change CFG_ENV_SIZE to CFG_ENV_SECT_SIZE for SPI sector erase
From: TsiChung Liew <[email protected]>
The CFG_ENV_SIZE is not suitable used for SPI flash erase sector size.
--- common/env_sf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
common/env_sf.c +1 -1
@@ -69,7 +69,7 @@ int saveenv(void) }puts ("Erasing SPI flash..." ); -if (spi_flash_erase (env_flash,CFG_ENV_OFFSET ,CFG_ENV_SIZE )) +if (spi_flash_erase (env_flash,CFG_ENV_OFFSET ,CFG_ENV_SECT_SIZE ))return 1 ;puts ("Writing to SPI flash..." );
Signature · 1 line
1.5.6.4
PATCH 1/1 Change CFG_ENV_SIZE to CFG_ENV_SECT_SIZE for SPI sector erase
Dear Tsi-Chung Liew,
Quoted 15 lines · In message <[email protected]>…
From: TsiChung Liew <[email protected]>
The
CFG_ENV_SIZEis not suitable used for SPI flash erase sector size.Signed-off-by TsiChung Liew <[email protected]>--- common/env_sf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)common/env_sf.c +0
-0
common/env_sf.c int saveenv(void) · line 72
Quoted 5 lines
common/env_sf.c +1
-1@@ -69,7 +69,7 @@ int saveenv(void) }puts ("Erasing SPI flash..." ); -if (spi_flash_erase (env_flash,CFG_ENV_OFFSET ,CFG_ENV_SIZE )) +if (spi_flash_erase (env_flash,CFG_ENV_OFFSET ,CFG_ENV_SECT_SIZE ))
Is it always guaranteed that CFG_ENV_SIZE <= CFG_ENV_SECT_SIZE ?
Otherwise several sectors might need to be erased...
Best regards,
Wolfgang Denk
Signature · 4 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: [email protected] Due to lack of disk space, this fortune database has been discontinued.
PATCH 1/1 Change CFG_ENV_SIZE to CFG_ENV_SECT_SIZE for SPI sector erase
Wolfgang,
You're right. Can't ignore the chance that CFG_ENV_SIZE might be
larger than CFG_ENV_SECT_SIZE, although both are defined in platform configuration file.
I will send out the patch again with condition check.
[/snip]
u32 sector = 1;
...
if (CFG_ENV_SIZE > CFG_ENV_SECT_SIZE) {
sector = CFG_ENV_SIZE / CFG_ENV_SECT_SIZE;
if (CFG_ENV_SIZE % CFG_ENV_SECT_SIZE)
sector++;
}
if (spi_flash_erase(env_flash, CFG_ENV_OFFSET, sector *
CFG_ENV_SECT_SIZE))
...
if (spi_flash_write(env_flash, CFG_ENV_OFFSET, CFG_ENV_SIZE,
env_ptr))
...Regards,
TsiChung
-----Original Message-----
From: [email protected] [mailto:wd at denx.de]
Sent: Tuesday, August 12, 2008 3:05 PM
To: Liew Tsi Chung
Cc: U-Boot; Rigby John
Subject: Re: [PATCH] Change CFG_ENV_SIZE to CFG_ENV_SECT_SIZE for SPI sector erase
Dear Tsi-Chung Liew,
In message <[email protected]> you
Quoted 14 lines · wrote:
From: TsiChung Liew <[email protected]>
The
CFG_ENV_SIZEis not suitable used for SPI flash erase sector size.Signed-off-by TsiChung Liew <[email protected]>--- common/env_sf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)common/env_sf.c index d641a9a..0a0626e renamed from common/env_sf.c +0
-0100644
common/env_sf.c int saveenv(void) · line 72
Quoted 5 lines
common/env_sf.c +1
-1@@ -69,7 +69,7 @@ int saveenv(void) }puts ("Erasing SPI flash..." ); -if (spi_flash_erase (env_flash,CFG_ENV_OFFSET ,CFG_ENV_SIZE )) + if (spi_flash_erase(env_flash, CFG_ENV_OFFSET,
CFG_ENV_SECT_SIZE))
Is it always guaranteed that CFG_ENV_SIZE <= CFG_ENV_SECT_SIZE ?
Otherwise several sectors might need to be erased...
Best regards,
Wolfgang Denk
Signature · 4 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: [email protected] Due to lack of disk space, this fortune database has been discontinued.