Can we place a `jffs2` image into the flash at position where a `rootfs_data` partition is started?

I'm composing a final image to be flushed on a board with a NAND flash( erase block = 128Kb, page size = 2Kb).

After the OpenWrt build I've got a linux kernel and a rootfs-squashfs binaries.

I have a board with a binary-only u-boot which looks for a kernel at an address 0x640000. I place the kernel at that position in the flash. For some reason (1), I have to place the rootfs-squashfs image NOT the next to the kernel. I place it at an address 0x4020000 (I placed a fake u-boot image at a 0x4000000 address (2) which occupies exactly one erase block and u-boot image's header.ih_size == 128Kb - 64b - 8b).

Then I have two cases:

a. left it as is and power the board :). After linux gets booted, an overlayfs's upper directory is /tmp/root which is backed by the RAM, so all changes are lost after the board reboots.

b. place a jffs2 image immediately after the rootfs-squashfs image. After linux gets booted, an overlayfs's upper dir is /overlay which is backed by a rootfs_data partition. [after I make some changes to my system, I get a error/warning that some erase block was marked as a bad block...., there's a question about similar case: A 'create a bad block at page ...' message after a jffs2 image was mounted and files were added , however that's about a custom parition, not a rootfs_data]

(1) this how a recovery mode works on these hubs (one kernel plus two rootfs-squashfs images). I talk about a case when a second rootfs-squashfs image is used :slight_smile:
(2) to allow linux to split a partition into rootfs and rootfs_data partitions

So, the questions are:

  • is it allowed to just place a jffs image into the flash and let it work without bad blocks triggering
  • which way is used in OpenWrt to handle such problem

Not on NAND

You really need to put together a proper DTS for your device that identifies the kernel and, most likely, "ubi" partitions.

JFFS2 is generally considered a poor choice for NAND flash. See

and related.


Thanks, I will move to UBI fs.
However it's strange why OpenWrt uses a squashfs + jffs2 bundle for board with NAND flash.

Which board?

All I have run into are squashfs over ubiblock with UBIFS overlay.

I have some board provided by a manufacture alongside with an SDK with OpenWrt. And this OpenWrt uses jffs2 fs on a rootfs_data partition (mtdsplit patches series).

(There is a 3.10.14 Linux on an mt7620 cpu with a raw 1Gbi NAND flash, I don't know which router board was used as a reference device to design/develop this board, I guess some ralink router...)

Likely not OpenWrt in any recognizable way if QSDK, a MediaTek, proprietary SDK, or the like, especially with that Kernel version. Contact the supplier of the SDK.

Auto-split of the flash isn't an upstream-Linux feature, so there's a good chance it is being done differently by the SDK you have as compared to current OpenWrt.

1 Like