diff options
author | Dustin Byford <dustin@cumulusnetworks.com> | 2014-03-06 20:48:22 -0800 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2014-03-12 17:04:28 -0400 |
commit | 23869bf80b68af9ef1802b9e556f4fd0e9e57fe5 (patch) | |
tree | 332dbcaf3f807b17eb378a68c317c4db2362fa84 /tools/env/fw_env.c | |
parent | f351eb0f18e7fe16c32bcc7951dca559fdd21ecf (diff) | |
download | u-boot-imx-23869bf80b68af9ef1802b9e556f4fd0e9e57fe5.zip u-boot-imx-23869bf80b68af9ef1802b9e556f4fd0e9e57fe5.tar.gz u-boot-imx-23869bf80b68af9ef1802b9e556f4fd0e9e57fe5.tar.bz2 |
fw_env: calculate default number of env sectors
The assumed number of environment sectors (always 1) leads to an
incorrect top_of_range calculation in fw.env.c when a flash device has
an erase block size smaller than the environment data size (number of
environment sectors > 1).
This change updates the default number of environment sectors to at
least cover the size of the environment.
Also corrected a false statement about the number of sectors column in
fw_env.config.
Signed-off-by: Dustin Byford <dustin@cumulusnetworks.com>
Diffstat (limited to 'tools/env/fw_env.c')
-rw-r--r-- | tools/env/fw_env.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index 577ce2d..649db04 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -1246,9 +1246,10 @@ static int parse_config () strcpy (DEVNAME (0), DEVICE1_NAME); DEVOFFSET (0) = DEVICE1_OFFSET; ENVSIZE (0) = ENV1_SIZE; - /* Default values are: erase-size=env-size, #sectors=1 */ + /* Default values are: erase-size=env-size */ DEVESIZE (0) = ENVSIZE (0); - ENVSECTORS (0) = 1; + /* #sectors=env-size/erase-size (rounded up) */ + ENVSECTORS (0) = (ENVSIZE(0) + DEVESIZE(0) - 1) / DEVESIZE(0); #ifdef DEVICE1_ESIZE DEVESIZE (0) = DEVICE1_ESIZE; #endif @@ -1260,9 +1261,10 @@ static int parse_config () strcpy (DEVNAME (1), DEVICE2_NAME); DEVOFFSET (1) = DEVICE2_OFFSET; ENVSIZE (1) = ENV2_SIZE; - /* Default values are: erase-size=env-size, #sectors=1 */ + /* Default values are: erase-size=env-size */ DEVESIZE (1) = ENVSIZE (1); - ENVSECTORS (1) = 1; + /* #sectors=env-size/erase-size (rounded up) */ + ENVSECTORS (1) = (ENVSIZE(1) + DEVESIZE(1) - 1) / DEVESIZE(1); #ifdef DEVICE2_ESIZE DEVESIZE (1) = DEVICE2_ESIZE; #endif @@ -1320,8 +1322,8 @@ static int get_config (char *fname) DEVESIZE(i) = ENVSIZE(i); if (rc < 5) - /* Default - 1 sector */ - ENVSECTORS (i) = 1; + /* Assume enough env sectors to cover the environment */ + ENVSECTORS (i) = (ENVSIZE(i) + DEVESIZE(i) - 1) / DEVESIZE(i); i++; } |