Notes on a JFFS2


A whole partition should be erased before an jffs2 image is written to it. See

Normally clean markers should be written after erasing. When we erase from a bootloader or a bare-metal flasher which doesn't have an ability to write clean markers we could just leave partition empty. In this case the kernel jffs2 driver will write markers for us. See


A minimum erase block size that mkfs.jffs2 supports without patching is 8KiB. The sector erase size of SPI flash that is reported by MTD driver as an erase size is 4KiB.

See and this thread

Workaround for an 8K erase size limit

In the stock firmware the erase size of jffs2 that drives /etc partition is 4K and it seems to work.

On the device side

It can be achieved by first erasing the whole partition with the following call

flash_eraseall -j /dev/mtd6

and then by mounting an empty partition:

mount -t jffs2 /dev/mtdblock6 /etc

It makes a clean jffs2 with an erase block of 4K mounted over an /etc directory.

On the host side

In order to make an image file of jffs2 on the host machine one should patch the mkfs.jffs2 program. Clone the git repository of mtd user-space tools and make it

git clone git://
cd mtd-utils
make -j5


vim jffsX-utils/mkfs.jffs2.c

and comment out the following lines

/* If it's less than 8KiB, they're not allowed */
if (erase_block_size < 0x2000) {
    fprintf(stderr, "Erase size 0x%x too small. Increasing to 8KiB minimum\n",
    erase_block_size = 0x2000;

Creating a JFFS2 Partition Image

So that after patching a mkfs.jffs2 tool the command to make a jffs2 image is

../toolchain/mtd-utils/mkfs.jffs2 --little-endian --pagesize=0x1000 --eraseblock=0x1000 --pad --root=filesystem/etc --output=etc.jffs2