This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

testing MTD partitions

for our custom board we have a 512MB Micron NAND flash chip.

I have compiled MTD utilities and changed the number and size of partitions as needed, also flashing root filesystem works with jffs2..all good

however, from time to time, we get a board that fails to flash for some reason, some times IO error or CRC failures...etc

so I'm building a new feature in the firmware for the production group to test the nand chip before flashing it (something like quick test, full test with a progress bar)

so I'm using mtd_pagetest and mtd_oob tests sucess as an indication for a healthy NAND MTD partition. 

I have MTD2 used for u-boot environment and it is 1 block in size (128KB). The pagetest always fails on this partition for some reason! I think the partition is good, it has all u-boot variabled read/write fine, so i guess something wrong with page test dealing with a small partition maybe?? 

so, I'm just asking if anyone knows or have experienced similar problem with the mtd_pagetest?

Regards,

Ahmed

  • here is the kernel logging with the error

    [ 414.115539] =================================================
    [ 414.121673] mtd_pagetest: MTD device: 2
    [ 414.127441] mtd_pagetest: MTD device size 131072, eraseblock size 131072, page size 2048, count of eraseblocks 1, pages per eraseblock 64, OOB size 64
    [ 414.172912] mtd_pagetest: scanning for bad eraseblocks
    [ 414.197845] mtd_pagetest: scanned 1 eraseblocks, 0 are bad
    [ 414.203613] mtd_pagetest: erasing whole device
    [ 414.208374] nand_erase_nand: start = 0x000000260000, len = 131072
    [ 414.236968] mtd_pagetest: erased 1 eraseblocks
    [ 414.241638] mtd_pagetest: writing whole device
    [ 414.339324] mtd_pagetest: written up to eraseblock 0
    [ 414.344543] mtd_pagetest: written 1 eraseblocks
    [ 414.349365] mtd_pagetest: verifying all eraseblocks
    [ 414.458129] mtd_pagetest: verified up to eraseblock 0
    [ 414.491912] mtd_pagetest: verified 1 eraseblocks
    [ 414.496887] mtd_pagetest: crosstest
    [ 414.516296] mtd_pagetest: reading page at 0x0
    [ 414.521240] mtd_pagetest: reading page at 0x1f800
    [ 414.526489] mtd_pagetest: reading page at 0x0
    [ 414.531311] mtd_pagetest: verifying pages read at 0x0 match
    [ 414.537200] mtd_pagetest: crosstest ok
    [ 414.541137] mtd_pagetest: erasecrosstest
    [ 414.545318] mtd_pagetest: erasing block 0
    [ 414.549530] nand_erase_nand: start = 0x000000260000, len = 131072
    [ 414.572814] mtd_pagetest: writing 1st page of block 0
    [ 414.578643] mtd_pagetest: reading 1st page of block 0
    [ 414.584289] mtd_pagetest: verifying 1st page of block 0
    [ 414.589843] mtd_pagetest: erasing block 0
    [ 414.594055] nand_erase_nand: start = 0x000000260000, len = 131072
    [ 414.619750] mtd_pagetest: writing 1st page of block 0
    [ 414.625549] mtd_pagetest: erasing block 0
    [ 414.629821] nand_erase_nand: start = 0x000000260000, len = 131072
    [ 414.658813] mtd_pagetest: reading 1st page of block 0
    [ 414.664428] mtd_pagetest: verifying 1st page of block 0
    [ 414.669952] mtd_pagetest: verify failed!
    [ 414.707305] mtd_pagetest: error -1 occurred
    [ 414.711730] =================================================
  • I will forward this to the software team. They will respond here.
  • Hi Ahmed,

    The last 2 rows of the log:

    [ 414.669952] mtd_pagetest: verify failed!

    [ 414.707305] mtd_pagetest: error -1 occurred

    are caused by discrepancy between written and read buffers in the end of erasecrosstest function in ..linux/drivers/mtd/tests/pagetest.c file. This means that the verification of fails.

    I suggest you to print the values of writebuf, readbuf and pgsize variables. This step could be helpful for investigation of the issue.

    BR

    Tsvetolin Shulev

  • I have added few print statements for the variables, but wanted to double check: do you need the pointers only or the whole contents of both read and write buffers?
  • You need at least 2 eraseblocks to perform this test. Check the working log, it writes to block 0, then erases block 1 and reads back the data in block 0 and they match, otherwise if you run this test on 1 block it erases itself then the comparison fails.

    [ 891.339949] mtd_pagetest: erasecrosstest
    [ 891.348293] mtd_pagetest: erasing block 0
    [ 891.355128] mtd_pagetest: writing 1st page of block 0
    [ 891.360769] mtd_pagetest: reading 1st page of block 0
    [ 891.370528] mtd_pagetest: verifying 1st page of block 0
    [ 891.378542] mtd_pagetest: erasing block 0
    [ 891.385647] mtd_pagetest: writing 1st page of block 0
    [ 891.391280] mtd_pagetest: erasing block 1
    [ 891.400554] mtd_pagetest: reading 1st page of block 0
    [ 891.408523] mtd_pagetest: verifying 1st page of block 0
    [ 891.416377] mtd_pagetest: erasecrosstest ok

  • Hello Everyone,

    i think the problem is in the following lines in the source code in mtd_pagetest.c:

    ebnum2 = ebcnt - 1;
    while (ebnum2 && bbt[ebnum2])
    ebnum2 -= 1;

    with a 1 block partition, you end up with both ebnum and ebnum2 equal to 0,
    so second part of the test fails when you verify because you erased the block not the next to it.

    I have verified by making the u-boot environment partition bigger (2 blocks) and the test passes, then created 2 partitions 1 block each in other physical locations that were passing before and both are failing now.

    cat /proc/mtd
    dev: size erasesize name
    mtd0: 00080000 00020000 "X-Loader"
    mtd1: 001e0000 00020000 "U-Boot"
    mtd2: 00040000 00020000 "Environment" (this passes now after size increase to 2 blocks)
    mtd3: 00020000 00020000 "env1"
    mtd4: 00020000 00020000 "env2"
    mtd5: 00400000 00020000 "Kernel"
    mtd3 and mtd4 both fail now although they were parts of the kernel partition (MTD3 in older kernel images) that was passing the test


    So the bug is that the mtd_pagetest will fail with any MTD partition that contains only one block

    For now, I will avoid the bug by assigning 2 blocks for the u-boot environment partition instead of 1

    Best Regards,
    Ahmed