mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-25 14:56:03 +00:00
fw_env: autodetect NAND erase size and env sectors
As already done for NOR chips, if device ESIZE and ENVSECTORS static configurations are both zero, then autodetect them at runtime. Cc: Joe Hershberger <joe.hershberger@ni.com> cc: Stefan Agner <stefan@agner.ch> cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: Anthony Loiseau <anthony.loiseau@allcircuits.com>
This commit is contained in:
parent
9e3003f79d
commit
d73a664186
2 changed files with 12 additions and 2 deletions
3
tools/env/README
vendored
3
tools/env/README
vendored
|
@ -58,6 +58,9 @@ DEVICEx_ENVSECTORS defines the number of sectors that may be used for
|
||||||
this environment instance. On NAND this is used to limit the range
|
this environment instance. On NAND this is used to limit the range
|
||||||
within which bad blocks are skipped, on NOR it is not used.
|
within which bad blocks are skipped, on NOR it is not used.
|
||||||
|
|
||||||
|
If DEVICEx_ESIZE and DEVICEx_ENVSECTORS are both zero, then a runtime
|
||||||
|
detection is attempted for NOR and NAND mtd types.
|
||||||
|
|
||||||
To prevent losing changes to the environment and to prevent confusing the MTD
|
To prevent losing changes to the environment and to prevent confusing the MTD
|
||||||
drivers, a lock file at /run/fw_printenv.lock is used to serialize access
|
drivers, a lock file at /run/fw_printenv.lock is used to serialize access
|
||||||
to the environment.
|
to the environment.
|
||||||
|
|
9
tools/env/fw_env.c
vendored
9
tools/env/fw_env.c
vendored
|
@ -1652,8 +1652,15 @@ static int check_device_config(int dev)
|
||||||
}
|
}
|
||||||
DEVTYPE(dev) = mtdinfo.type;
|
DEVTYPE(dev) = mtdinfo.type;
|
||||||
if (DEVESIZE(dev) == 0 && ENVSECTORS(dev) == 0 &&
|
if (DEVESIZE(dev) == 0 && ENVSECTORS(dev) == 0 &&
|
||||||
mtdinfo.type == MTD_NORFLASH)
|
mtdinfo.erasesize > 0) {
|
||||||
|
if (mtdinfo.type == MTD_NORFLASH)
|
||||||
DEVESIZE(dev) = mtdinfo.erasesize;
|
DEVESIZE(dev) = mtdinfo.erasesize;
|
||||||
|
else if (mtdinfo.type == MTD_NANDFLASH) {
|
||||||
|
DEVESIZE(dev) = mtdinfo.erasesize;
|
||||||
|
ENVSECTORS(dev) =
|
||||||
|
mtdinfo.size / mtdinfo.erasesize;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (DEVESIZE(dev) == 0)
|
if (DEVESIZE(dev) == 0)
|
||||||
/* Assume the erase size is the same as the env-size */
|
/* Assume the erase size is the same as the env-size */
|
||||||
DEVESIZE(dev) = ENVSIZE(dev);
|
DEVESIZE(dev) = ENVSIZE(dev);
|
||||||
|
|
Loading…
Add table
Reference in a new issue