aboutsummaryrefslogtreecommitdiff
path: root/tools/env/fw_env.c
diff options
context:
space:
mode:
authorAnthony Loiseau <anthony.loiseau@allcircuits.com>2023-12-21 23:44:38 +0100
committerTom Rini <trini@konsulko.com>2024-01-05 15:41:47 -0500
commitd73a6641868029b5cae53ed00c5766921c9d8b1f (patch)
tree4add007f6818eafefe1ff7e617f2fcdf3911ae35 /tools/env/fw_env.c
parent9e3003f79d168eac7ee65cd457e3904e2fb4eea8 (diff)
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>
Diffstat (limited to 'tools/env/fw_env.c')
-rw-r--r--tools/env/fw_env.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 90010dabd8..74451ecb94 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1652,8 +1652,15 @@ static int check_device_config(int dev)
}
DEVTYPE(dev) = mtdinfo.type;
if (DEVESIZE(dev) == 0 && ENVSECTORS(dev) == 0 &&
- mtdinfo.type == MTD_NORFLASH)
- DEVESIZE(dev) = mtdinfo.erasesize;
+ mtdinfo.erasesize > 0) {
+ if (mtdinfo.type == MTD_NORFLASH)
+ DEVESIZE(dev) = mtdinfo.erasesize;
+ else if (mtdinfo.type == MTD_NANDFLASH) {
+ DEVESIZE(dev) = mtdinfo.erasesize;
+ ENVSECTORS(dev) =
+ mtdinfo.size / mtdinfo.erasesize;
+ }
+ }
if (DEVESIZE(dev) == 0)
/* Assume the erase size is the same as the env-size */
DEVESIZE(dev) = ENVSIZE(dev);