u-boot saveenv corrupted other MTD parttions

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


JH wrote...

>gpmi-nand:1m(boot),1m(ubootenv),-(storage)
<snip>

>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.

-Andy.



More information about the U-Boot mailing list