u-boot saveenv corrupted other MTD parttions

Andy Pont andy.pont at sdcsystems.com
Tue Feb 18 10:35:12 CET 2020

JH wrote...


>The saveenv does not take any parameters, how did it work to write to
>the NAND 1m(ubootenv)?
>=> saveenv
>Saving Environment to NAND... Erasing NAND...
>Erasing at 0x5e0000 -- 100% complete.
>Writing to NAND... OK
>It looks like that saveenv overwritten to the storage, is 0x5e0000 RAM
>or NAND address?
>Where was that address defined?
What U-Boot uses for the storage of the environment is controlled 
through configuration options.  In recent versions this is all handled 
through the options defined in env/Kconfig.  In older versions these may 
have been defined in the include/configs/myboardname.h file.

CONFIG_ENV_IS_IN_NAND tells U-Boot that the environment is to be stored 
in the NAND flash device

CONFIG_ENV_OFFSET defines how far into the NAND device the environment 
will be stored (in your case this is probably 0x5e0000)

CONFIG_ENV_SIZE defines how big it is

Your definition of the mtd partitions doesn’t match.  Your “ubootenv" partition starts at offset 0x100000 and your “storage” partition starts at offset 0x200000.  When you run the saveenv command you are writing somewhere in the middle of the “storage” partition.


More information about the U-Boot mailing list