Page 1 of 1

Errors when I dowload a jffs2 image into NAND with SAM-BA

Posted: Thu Mar 26, 2009 10:32 am
by boogieman
Hello all,

I am having trouble getting a jffs2 image to work as a root file system when I program it into nand with SAM-BA. I have an AT91SAM9260ek evaluation board. I have stored Bootstrap, U-boot and linux in the dataflash and the filesystem in the NAND-flash. Booting works, but when I start linux it gives me a bunch of errors, like these :

mtd->read(0x2c5 bytes from 0x4f7000) returned ECC error
mtd->read(0x2cc bytes from 0x4f6800) returned ECC error
mtd->read(0x10f bytes from 0x4f6000) returned ECC error
mtd->read(0x1b9 bytes from 0x4f5800) returned ECC error
mtd->read(0x1d8 bytes from 0x4f5000) returned ECC error
mtd->read(0xcb bytes from 0x4f4800) returned ECC error

It gives these errors all the time. Now the funny thing is, the filesystem is actually working, it's as if the nand flash algorithm of SAM-BA does not store ECC data or something like that. I am running SAM-BA 2.8 right now, because I read somewhere that older versions are not capable of writing a jffs2 to nand at all, which I experienced, when I wrote the image to NAND with SAM-BA 2.3 linux was not able to see files at all. It does see the files now, but I get a lot of errors.

I create my jffs2 image with the following line :

mkfs.jffs2 -d temp --pagesize=0x800 --eraseblock=0x20000 -l -q -n -o root.jffs2

I read somewhere that pagesize and eraseblock size should include the oob area and that would mean a pagesize of 0x840 and an eraseblock of 0x21000 for my flash, but I don't think that this is correct because that is not working at all.

When I boot the board with a demo initrd, I am able to mount an empty flash, download the files onto it, unmounting the filesystem, reboot with that filesystem as root files system and that works flawlessly ! So there must be some difference in how SAM-BA programs the image to NAND or maybe the image itself misses some critical data.

Does this problem sound familiar to someone, does it ring a bell ?

Some more questions, where does linux expect the ECC data, is it in the oob area or in the data area. Does jffs2 need to add ECC data to the image ? Or does the flash algorithm need to add ECC data ?

Info about my system :

AT91SAM9260EK board
linux2.6.27 , uses NAND MTD driver with hardware ECC handling.

Hope someone can help me out.

Thanks !

Re: Errors when I dowload a jffs2 image into NAND with SAM-BA

Posted: Thu Mar 26, 2009 12:56 pm
by boogieman
Hi again,

Well I've done some researching and I think that SAM-BA, u-boot and the linux kernel use different schemes for calculating ecc.

I drivers/mtd/nand/atmel_nand I find :

static struct nand_ecclayout atmel_oobinfo_large = {
.eccbytes = 4,
.eccpos = {60, 61, 62, 63},
.oobfree = {
{2, 58}

In SAM-BA applet code ( C:\samba\applets\at91\memories\nandflash ) I find :

/// Spare area placement scheme for 2048 byte pages.
const struct NandSpareScheme nandSpareScheme2048 = {

// Bad block marker is at position #0
// 24 ecc bytes
// Ecc bytes positions
{40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
59, 60, 61, 62, 63},
// 38 extra bytes
// Extra bytes positions
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39}

And in U-boot I find yet other ecc schemes.

It appears to me that all of these schemes must match !

I have also examined my jffs2 image, trying to find an answer to my question if a jffs2 image should contain ecc data. If that was the case then I think I should find ecc data in the area 0x800 0x840, but I find filenames there ! So I think a jffs2 image contains no ecc data. Which is logical and leaves ecc handling purely to the nand program logic.

Can anyone confirm if my findings are correct ?

If so, is it possible to change SAM-BA ecc scheme ??

Thank you !

Re: Errors when I dowload a jffs2 image into NAND with SAM-BA

Posted: Thu Mar 26, 2009 10:45 pm
by falingtrea
uboot and SAM-BA use software ECC by default. And I don't think the linux HW ECC code is fully functional. Set linux to software ECC and you should be ok. Software ECC is more generic and not processor specific, which is why it is used in SAM-BA and uboot.

FYI ECC data is always in the OOB area.

Re: Errors when I dowload a jffs2 image into NAND with SAM-BA

Posted: Fri Mar 27, 2009 11:12 am
by boogieman
Thanks, falingtrea ! I switched ecc handling to software and that works fine indeed !