Hi,
I made a custom board based on the ipnc solution. I change the NAND flash from 32MB to 512MB because the solution said it supports a nand up to 4Gbit.
I use a partition as data storge in linux system. When linux mount mtdblock4 as a jffs2 file system, the following information appears:
//////////////////////////////////////////////////////////////
jffs2: Erase block size too small (128KiB). Using virtual blocks size (256KiB) instead
ECC_STATE_TOO_MANY_ERRS
mtd->read(0x400 bytes from 0x0) returned ECC error
//////////////////////////////////////////////////////////////
When writing files to this partition, there are many ecc errors, often the data is corrupted randomly.
The NAND type is K9F4G08U0M, with a 2k page and a 128k block.
I can't determine whether it is a driver or file system problem.
In u-boot, nand works fine when writing uImage and ramdisk. I check the nand configuration in linux kernel, which is the same to that in u-boot.
Here's the nand configuration in linux kernel,I thought there's no need to modify for the flash chip I select. Looking forward to your suggestions. Thanks!
///////////////////////////////////////////////////////////////////////////////////////////////////
#define NAND_BLOCK_SIZE (SZ_16K)
static struct mtd_partition nand_partitions[] = {
/* bootloader (UBL, U-Boot, BBT) in sectors: 0 - 14 */
{
.name = "bootloader",
.offset = 0,
.size = 24*NAND_BLOCK_SIZE,
.mask_flags = MTD_WRITEABLE, /* force read-only */
},
/* bootloader params in the next sector 15 */
{
.name = "params",
.offset = MTDPART_OFS_APPEND,
.size = 104*NAND_BLOCK_SIZE,
.mask_flags = MTD_WRITEABLE, /* force read-only */
},
/* kernel starts in sector 16 */
{
.name = "kernel",
.offset = MTDPART_OFS_APPEND,
.size = SZ_2M,
.mask_flags = 0
},
{
.name = "filesystem",
.offset = MTDPART_OFS_APPEND,
.size = SZ_16M+SZ_4M,
.mask_flags = 0
},
{
.name = "data",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
.mask_flags = 0
},
};
/* flash bbt decriptors */
static uint8_t nand_davinci_bbt_pattern[] = { 'B', 'b', 't', '0' };
static uint8_t nand_davinci_mirror_pattern[] = { '1', 't', 'b', 'B' };
static struct nand_bbt_descr nand_davinci_bbt_main_descr = {
.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
| NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
.offs = 0,
.len = 4,
.veroffs = 5,
.maxblocks = 4,
.pattern = nand_davinci_bbt_pattern
};
static struct nand_bbt_descr nand_davinci_bbt_mirror_descr = {
.options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
| NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
.offs = 0,
.len = 4,
.veroffs = 5,
.maxblocks = 4,
.pattern = nand_davinci_mirror_pattern
};
static struct nand_davinci_platform_data nand_data = {
.options = 0,
.eccmode = NAND_ECC_HW10_512,//NAND_ECC_NONE,//NAND_ECC_HW3_512,//NAND_ECC_SOFT,//NAND_ECC_HW10_512,
.cle_mask = 0x10,
.ale_mask = 0x08,
.bbt_td = &nand_davinci_bbt_main_descr,
.bbt_md = &nand_davinci_bbt_mirror_descr,
.parts = nand_partitions,
.nr_parts = ARRAY_SIZE(nand_partitions),
};
static struct resource nand_resources[] = {
[0] = { /* First memory resource is AEMIF control registers */
.start = DM355_ASYNC_EMIF_CNTRL_BASE,
.end = DM355_ASYNC_EMIF_CNTRL_BASE + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
[1] ={ /* Second memory resource is NAND I/O window */
.start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
.end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16K - 1,
.flags = IORESOURCE_MEM,
},
};
static struct platform_device nand_device = {
.name = "nand_davinci",
.id = 0,
.dev = {
.platform_data = &nand_data
},
.num_resources = ARRAY_SIZE(nand_resources),
.resource = nand_resources,
};
////////////////////////////////////////////////////////////////////////////////////////////