mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 14:41:31 +00:00
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>
This commit is contained in:
parent
f351eb0f18
commit
23869bf80b
2 changed files with 9 additions and 7 deletions
14
tools/env/fw_env.c
vendored
14
tools/env/fw_env.c
vendored
|
@ -1246,9 +1246,10 @@ static int parse_config ()
|
||||||
strcpy (DEVNAME (0), DEVICE1_NAME);
|
strcpy (DEVNAME (0), DEVICE1_NAME);
|
||||||
DEVOFFSET (0) = DEVICE1_OFFSET;
|
DEVOFFSET (0) = DEVICE1_OFFSET;
|
||||||
ENVSIZE (0) = ENV1_SIZE;
|
ENVSIZE (0) = ENV1_SIZE;
|
||||||
/* Default values are: erase-size=env-size, #sectors=1 */
|
/* Default values are: erase-size=env-size */
|
||||||
DEVESIZE (0) = ENVSIZE (0);
|
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
|
#ifdef DEVICE1_ESIZE
|
||||||
DEVESIZE (0) = DEVICE1_ESIZE;
|
DEVESIZE (0) = DEVICE1_ESIZE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1260,9 +1261,10 @@ static int parse_config ()
|
||||||
strcpy (DEVNAME (1), DEVICE2_NAME);
|
strcpy (DEVNAME (1), DEVICE2_NAME);
|
||||||
DEVOFFSET (1) = DEVICE2_OFFSET;
|
DEVOFFSET (1) = DEVICE2_OFFSET;
|
||||||
ENVSIZE (1) = ENV2_SIZE;
|
ENVSIZE (1) = ENV2_SIZE;
|
||||||
/* Default values are: erase-size=env-size, #sectors=1 */
|
/* Default values are: erase-size=env-size */
|
||||||
DEVESIZE (1) = ENVSIZE (1);
|
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
|
#ifdef DEVICE2_ESIZE
|
||||||
DEVESIZE (1) = DEVICE2_ESIZE;
|
DEVESIZE (1) = DEVICE2_ESIZE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1320,8 +1322,8 @@ static int get_config (char *fname)
|
||||||
DEVESIZE(i) = ENVSIZE(i);
|
DEVESIZE(i) = ENVSIZE(i);
|
||||||
|
|
||||||
if (rc < 5)
|
if (rc < 5)
|
||||||
/* Default - 1 sector */
|
/* Assume enough env sectors to cover the environment */
|
||||||
ENVSECTORS (i) = 1;
|
ENVSECTORS (i) = (ENVSIZE(i) + DEVESIZE(i) - 1) / DEVESIZE(i);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
2
tools/env/fw_env.config
vendored
2
tools/env/fw_env.config
vendored
|
@ -1,7 +1,7 @@
|
||||||
# Configuration file for fw_(printenv/setenv) utility.
|
# Configuration file for fw_(printenv/setenv) utility.
|
||||||
# Up to two entries are valid, in this case the redundant
|
# Up to two entries are valid, in this case the redundant
|
||||||
# environment sector is assumed present.
|
# environment sector is assumed present.
|
||||||
# Notice, that the "Number of sectors" is ignored on NOR and SPI-dataflash.
|
# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash.
|
||||||
# Futhermore, if the Flash sector size is ommitted, this value is assumed to
|
# Futhermore, if the Flash sector size is ommitted, this value is assumed to
|
||||||
# be the same as the Environment size, which is valid for NOR and SPI-dataflash
|
# be the same as the Environment size, which is valid for NOR and SPI-dataflash
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue