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.

Mount mtdblock as yaffs2 not working

Hi all,

I've managed to get my am3559 running kernel linux-ti33x-psp version 3.2.28-r17 to mount my micron nand flash (2GB, 8bit) as  ubifs and also boot from it.

Now I'm trying to get it running with yaffs2 due to the unstable bit issue with ubifs.

I'm following the TI guide : http://processors.wiki.ti.com/index.php/Put_YAFFS_Image_to_Flash

Unfortunately whenever I mount my partition, after erasing all content, and try to create a directory I'm getting the following error:

>> flash_erase /dev/mtd12 0 0
flash_erase: Skipping bad block at 00000000
flash_erase: Skipping bad block at 00020000
flash_erase: Skipping bad block at 00040000
flash_erase: Skipping bad block at 00060000
flash_erase: Skipping bad block at 00080000
Erasing 128 Kibyte @ 5060000 -- 32 % complete flash_erase: Skipping bad block at 05080000
Erasing 128 Kibyte @ 50a0000 -- 32 % complete flash_erase: Skipping bad block at 050c0000
Erasing 128 Kibyte @ f860000 -- 100 % complete

>> mount -t yaffs2 /dev/mtdblock12 /mnt/yaffs2
[  324.976593] yaffs: dev is 32505868 name is "mtdblock12" rw
[  324.982452] yaffs: passed flags ""

>>  mkdir test
mkdir: can't create directory 'test': Cannot allocate memory

I checked my free space, almost the whole partition is free:

>>  df -h /dev/mtdblock12
Filesystem                Size      Used Available Use% Mounted on
/dev/mtdblock12         248.5M      2.1M    246.4M   1% /mnt/yaffs2

mdtinfo for this partition is:

>> mtdinfo /dev/mtd12
mtd12
Name:                           File System
Type:                           nand
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          1988 (260571136 bytes, 248.5 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size:                  512 bytes
OOB size:                       64 bytes
Character device major/minor:   90:24
Bad blocks are allowed:         true
Device is writable:             true

And dmesg shows me that all my blocs are marked as bad:

[  324.976593] yaffs: dev is 32505868 name is "mtdblock12" rw
[  324.982452] yaffs: passed flags ""
[  324.985992] yaffs: yaffs: Attempting MTD mount of 31.12,"mtdblock12"
[  325.632476] yaffs: checking block 0 bad
[  325.632537] yaffs: block 1 is bad
[  325.632537] yaffs: checking block 1 bad
[  325.632598] yaffs: block 2 is bad
[  325.632629] yaffs: checking block 2 bad
[  325.632690] yaffs: block 3 is bad
[  325.632690] yaffs: checking block 3 bad
[  325.632751] yaffs: block 4 is bad
[  325.632751] yaffs: checking block 4 bad
[  325.632812] yaffs: block 5 is bad
[  325.632812] yaffs: checking block 5 bad
[  325.633209] yaffs: checking block 6 bad
......

[  326.399841] yaffs: checking block 1987 bad
[  326.402954] yaffs: yaffs_read_super: is_checkpointed 0

But when I use the mount-option "inband-tags" all works.

>> mount -t yaffs2 -o"inband-tags" /dev/mtdblock12 /mnt/yaffs2

Why is my normal yaffs mount not working?

What are the consequences of using the option "inband-tags" except of the loss of space needed for these tags? Is EEC still working?

I'm really stuck for the moment not knowing what to do.

Regards

Isak Lichtenstein

  • Hi Isak,

    I suggest you read this page: "How Yaffs works" from the official yaffs site.

    Scroll over to the "Inband tags" section and you will find out the following:

    With inband tags we store the tags in the flash data area alongside the data.
    There are three major penalties with inband tags:
    • Due to the loss of chunk alignment, all transactions must pass through the shortOpCache. This costs an extra memcpy().

    • Offset to chunk, free space and other calculations are no longer just shift and mask operations but instead require multiplications and divisions which can relatively expensive.

    • Reading tags during scanning etc can involve reading the whole page, making this slower. The impact is minimised by using checkpointing.

    Nothing is ever said about ECC stopping working when using inband tags, so no worries here.

    As for why the normal yaffs mount doesn't work, you can check if your OOB (out of band) area is big enough to hold both the tag data and the ECC. I think the default tags need 28 bytes. You may want to read this discussion (last 2 posts), where it is suggested what you can do if your OOB area isn't big enough to hold all the data it needs.

    Another suggestion: Maybe you are using an older kernel where there is a problem in the flash driver. The latest PSP is version 04.06.00.09. The kernel version tag is v3.2_AM335xPSP_04.06.00.09-rc2. Looking at the Compile-time settings section of this page there is a setting that suggest just that:

    CONFIG_YAFFS_ECC_WRONG_ORDER

    This flag should only be used with old Linux MTD code which had a bug in the ECC byte ordering.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thank you very much for your answer.

    Especially the Inband-tags part was exactly what I was looking for, but couldn't find it on the official yaffs website.

    Concerning my Kernel as said, I'm using l linux-ti33x-psp version 3.2.28-r17 and it doesn't even offer me the ]CONFIG_YAFFS_ECC_WRONG_ORDER option.

    According to the yaffs specs we need space for the following tags:

    Tag structure

    Each chunk in Yaffs2 has the following information:

    Field

    Comment

    Size for 1kb chunks

    Size for 2kB chunks

    blockState

    Block state. non-0xFF for bad block

    1 byte

    1 byte

    chunkId

    32-bit chunk Id

    4 bytes

    4 bytes

    objectId

    32-bit object Id

    4 bytes

    4 bytes

    nBytes

    Number of data bytes in this chunk

    2 bytes

    2 bytes

    blockSequence

    sequence number for this block

    4 bytes

    4 bytes

    tagsEcc

    ECC on tags area

    3 bytes

    3 bytes

    ecc

    ECC, 3 bytes/256 bytes of data

    12 bytes

    24 bytes

    Total

     

    30 bytes

    42 bytes

    Now my NAND has a 64 Byte OOB for every 2KB page and I'm using HW BCH8.  Shouldn't there be more than enough space in the OOB?

    Regards Isak

  • Hi Isak,

    Please refer to this section: http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide#BCH_Flash_OOB_Layout

    Your Micron NAND flash has page size 2KB with 64 byte OOB area. When you use H/W ECC BCH8, 58 bytes are consumed from the OOB area, which leaves only 8 bytes for the YAFFS2 tags, which is definitely not enough. When you use inband tags, the OOB area is not used, so there is no issue.

    Best regards,
    Miroslav

  • Hi Miroslav,

    Thank you very much for your answer. That was exactly my problem. Somehow when I first read the suggested page a few week ago, I forgot to adapt the 14 Bytes per 512 Byte sector to my page size of 2KB.

    Best Regards

    Isak