u-boot saveenv corrupted other MTD parttions

Hi,
I have three MTD partitions, the mtd2 storage installed UBIFS volumes, first is dtb volume, second is kernel volume, third is rootfs volume. The saveenv was configured to save environment variables to NAND ubootenv.
gpmi-nand:1m(boot),1m(ubootenv),-(storage)
There was no issue to run NAND boot, but if I called saveenv in u-boot, then I run bootcmd again, it could not boot from NAND any more:
Bad Linux ARM zImage magic!
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?
How do I know it was the NAND 1m(ubootenv) address?
Thank you.
Kind regards,
- jh

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.
participants (2)
-
Andy Pont
-
JH