[OpenWrt-Devel] [RFC] fstools: Question: Approach to make jffs2reset NAND-aware

Jeff Kletsky lede at allycomm.com
Tue Nov 12 13:43:33 EST 2019

One of the next things on my list is getting `firstboot` to work with
NAND (UBI) flash.

As reported[1], `jff2reset.c` does not seem to consider that there is
a UBI volume being used for the overlay. It appears to fail in
"marking" the file system as needing erasure.

root@(none):/# firstboot
[   32.530266] jffs2reset: This will erase all settings and remove any 
installed packages. Are you sure? [N/y]
[   34.958257] jffs2reset: /dev/ubi0_1 is not mounted
[   34.963187] jffs2reset: /dev/ubi0_1 will be erased on next mount
[   34.969244] jffs2reset: writing /dev/ubi0_1 failed: Operation not 

While there are command-line work-arounds, this also impacts the
"button-press reset" functionality.

The failure is due to at least

   sz = write(fd, &deadc0de, sizeof(deadc0de));

which returns -1 when trying to write directly to NAND flash.

Before I dive into dealing with UBI from C code, what would be a
project-preferred way to mark a UBI volume for erasure at next mount?

   * Presence of `.erase_this_volume` in the root of the file system?
   * Some other mark?

I'll work through how to erase the volume without losing track of the
existing wear-balancing and bad-block management features once I've
got a good way to detect that it should be done at next mount,
preferably without a "double erase" occurring[2].


[1] https://bugs.openwrt.org/index.php?do=details&task_id=468

[2] http://www.linux-mtd.infradead.org/faq/ubifs.html#L_why_ubiformat

openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list