Hi,
After few days of debugging few more inputs to the above stated issue. It may help to understand the issue better.
The log when executing "ubiattach" command in kernel:
--------------------------------------------------------------------------
ubi0: scanning is finished
ubi0: attached mtd4 (name "rootfs", size 1948 MiB)
ubi0: PEB size: 524288 bytes (512 KiB), LEB size: 516096 bytes
ubi0: min./max. I/O unit sizes: 4096/4096, sub-page size 4096
ubi0: VID header offset: 4096 (aligned 4096), data offset: 8192
ubi0: good PEBs: 3892, bad PEBs: 4, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 289220316
ubi0: available PEBs: 0, total reserved PEBs: 3892, PEBs reserved for bad PEB handling: 76
ubi0: background thread "ubi_bgt0d" started, PID 115
Here the bad PEBs(in BOLD) found as 4.
The log when executing "ubi part ${partition_name}" command in uboot.
----------------------------------------------------------------------------------------------
The log when executing "ubi part ${partition_name}" command in uboot.
ubi0: attached mtd1 (name "mtd=4", size 1948 MiB)
ubi0: PEB size: 524288 bytes (512 KiB), LEB size: 516096 bytes
ubi0: min./max. I/O unit sizes: 4096/4096, sub-page size 4096
ubi0: VID header offset: 4096 (aligned 4096), data offset: 8192
ubi0: good PEBs: 3896, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 289220316
ubi0: available PEBs: 0, total reserved PEBs: 3896, PEBs reserved for bad PEB handling: 80
Here the bad PEBs(in BOLD) found as 0.
So, whenever the uboot scans or checks for the bad block using bad block table in the NAND flash, it always return there is no bad blocks. This is the reason why "ubi erase.part" command clears the whole rootfs partition. But uboot should find the bad blocks present in the NAND flash right?
I guess Uboot couldn't able to find the bad block table(BBT) generated by kernel. But I am not sure about this process.
These are the configurations I added extra to support UBI command in UBOOT.
/* UBI */
#ifdef CONFIG_CMD_UBI
#define CONFIG_CMD_UBIFS
#define CONFIG_CMD_MTDPARTS
#define CONFIG_RBTREE
#define CONFIG_LZO
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
#define MTDIDS_DEFAULT "nand0=gpmi-nand"
#define MTDPARTS_DEFAULT \
"mtdparts=gpmi-nand:" \
"64m(boot)," \
"16m(kernel)," \
"16m(dtb)," \
"4m(initrd)," \
"-(rootfs)"
#endif
#define CONFIG_SYS_NAND_USE_FLASH_BBT
Is there anything I need to add more? Am I going in right direction?
Kindly help to understand this situation better.
Thanks,
Koil Arul Raj S