A 'create a bad block at page ...' message after a jffs2 image was mounted and files were added

I have an OpenWrt based board with mediatek cpu and NAND flash.

I created a jffs2 image using a mkfs.jffs2 tool:

mkdir jffs2_root
touch jffs2_root/hello_world.txt
mkfs.jffs2 -r jffs2_root --pagesize=0x800 --eraseblock=0x20000 --no-cleanmarkers -o data.jffs2

Then I placed it into a flash, using a uboot (tftp loads data into the RAM, how the data comes into the flash I don't know, but I see that memory gets erased and then data gets written, so I guess uboot's nand commands are used) at an address multiple a flash erase block size.

Linux was adopted to have a new mtd partition starting at that address.

Then, when Linux got booted, I mounted this partition:

   mkdir /kyky
   mount -t jffs2 /dev/mtdblock8 /kyky

And I was able to see my hello_world.txt file under the /kyky directory.
But when I created a new file in this /kyky directory, I got an error:

 create a bad block at page 34c0

How something like this could happen? I checked on several boards and got the same problem. Of course it can happen that that block gets tired and gets broken, but it seems something other happened, as I checked on several boards...

NAND can't be treated like NOR. You need to use tooling that is aware of bit-flips as well as bad-block mapping and other metadata on the chip.

UBI is typically used on top of NAND, not JFFS2.

1 Like

Thanks for the answer :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.