Nandwrite vs. "mtd write"?

As a few board targets seem to use "nandwrite", but the majority uses package/base-files/files/lib/upgrade/ for NAND flashes which uses "mtd write" I was wondering if there is a difference between these two commands or if one is preferred or discouraged in specific use-cases. Does this decision make a difference if the underlying device is a UBI partition (default for OpenWrt NAND based devices these days I think) or JFFS2 on an mtd device directly, without UBI?

I checked and saw that "mtd write" seems to support some bad block handling these days, but it seems that was not always the case, right? Is it less safe to use "mtd write" on old/ancient OpenWrts?

(I also have to work with an old industry device with OpenWrt Attitude Adjustment... which hopefully will be updated to a recent OpenWrt one day... but for now we are trying to revive access to and some first polishing. And it seems it was using JFFS2 for both the rootfs /rom and rootfs_data /overlay partitions, without UBI. And was using nandwrite from the mtd-utils package. And that's where basically the "nandwrite" vs. "mtd write" question popped up in my mind. Both using "nandwrite" and "mtd write" seemed to work, but I didn't see any bad block handling code in OpenWrt's "mtd write" in Attitude Adjustment.)

1 Like