UBIFS corruption after update and reboot

Hello,

As pointed out by Edward there was my mistake when configuring redundant environment.

Default CONFIG_ENV_RANGE for imx6ull is set to (4 x CONFIG_ENV_SIZE) that in default NAND layout means all the env partition size 0x800000. And my configuration was that CONFIG_ENV_OFFSET_REDUND was by 0x20000 from env partition start.

So every two times env was updated I deleted 0x20000 bytes of mtd partition where my UBI partition starts.

And it was tricky to notice that from linux, because as soon as UBI is mounted if “fixes” itself and adds correct fingerprint bytes on the start of it. But checking with “nand dump 0x400000” on uboot cli revealed that every time redundant environment is written I get FFs on my UBI partition.

The following patches fixes my problem the first one sets half of the env partition to env and the other half to redundant env and ranges according to this.

 configs/colibri-imx6ull_defconfig | 2 +-
 include/configs/colibri-imx6ull.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configs/colibri-imx6ull_defconfig b/configs/colibri-imx6ull_defconfig
index 43b43712ba9..0afa853a304 100644
--- a/configs/colibri-imx6ull_defconfig
+++ b/configs/colibri-imx6ull_defconfig
@@ -3,7 +3,7 @@ CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x87800000
 CONFIG_ENV_SIZE=0x20000
 CONFIG_ENV_OFFSET=0x380000
-CONFIG_ENV_OFFSET_REDUND=0x3A0000
+CONFIG_ENV_OFFSET_REDUND=0x3C0000
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_BOOTCOUNT_BOOTLIMIT=3
 CONFIG_BOOTCOUNT_ENV=y
diff --git a/include/configs/colibri-imx6ull.h b/include/configs/colibri-imx6ull.h
index 0b6653b4bd8..1e6b3266fad 100644
--- a/include/configs/colibri-imx6ull.h
+++ b/include/configs/colibri-imx6ull.h
@@ -182,7 +182,7 @@
 #define CONFIG_SYS_MMC_ENV_DEV		0
 #define CONFIG_SYS_MMC_ENV_PART		1
 #elif defined(CONFIG_ENV_IS_IN_NAND)
-#define CONFIG_ENV_RANGE	(4 * CONFIG_ENV_SIZE)
+#define CONFIG_ENV_RANGE 0x40000
 #endif
 
 #ifdef CONFIG_TARGET_COLIBRI_IMX6ULL_NAND

The other problem was linux side for managing env. There was the same range mistake in fw_env.config. But libubootenv doesn’t allow to cross mtd partition so linux part was not corrupting UBI volume. But anyway it is needed to change to have correct locations of env and redundant env with correct ranges for both of them.

So this configuration is working for my setup

# MTD device name	Device offset	Env. size	Flash sector size	Number of sectors
# Colibri iMX6ULL
/dev/mtd3		0x00000000	0x00020000	0x20000			2
/dev/mtd3		0x00040000	0x00020000	0x20000			2

After making these changes, I have done about 250 update cycles with no problems. And then updated all the fleet on our infrastructure, also no problems was experencied.

Thank for pointing this fix for me. Regards!

2 Likes