I am going to use JFFS2 on top of my USB stick/CF card/etc, is it OK?
USB sticks, CompactFlash cards and other removable flash media are not MTDdevices. They are block devices. They do contain flash chip inside, butthey also contain some translation layer above which emulates block device.This translation layer is implemented in hardware. So for outside world thesedevices look exactly as hard drives, not like MTD devices.
Please, read the bellow FAQ entry about usingJFFS2 on top of hard drives.
[
First off, JFFS2 was designed for MTD devices, not for block devices like harddrives. These are two very different types of devices. Please read the last chapter in this page for the difference.
Now you understand that you are going to use JFFS2 with devices it was notdesigned for, is it OK? Obviously, it is generally not OK.
It is possible to use JFFS2 with the block2mtd
driver. The driveremulates an MTD device on top of a block device so that you may feed theemulated MTD device to JFFS2 and utilize the file system on top of it. But donot complain when you have noticed that the performance suffers.
Owing to peculiarities of flash devices, JFFS2 is very different toconventional HDD-oriented file system. And one of its drawbacks is that mounttime as well as memory consumption grow linearly with growing flash size. Sobeware you may end up with tremendous amount memory eaten and huge mount time ifyour block device is very large. Also, JFFS2 implements only write-throughcaching (while conventional filesystems have write-back) and does many things which arenot really needed in the case of hard drives.
So, beware of this and think twice. Also, nobody guaranteesblock2mtd
is bug-free. It it mostly used for debugging purposes,when it is easier to utilize emulated mtd device on the host developmentmachine rather then debug on the target board. But of course, if you tested itand everything is OK with you - go ahead.
So, the answer is probably yes, you technically can, but be sure you realizewhy you do this. In general it is bad idea. It is much better to use anyconventional file system like ext2.
Also note, these devices are "black boxes". The way they implement thisflash-to-block device translation layer is not usually published. And in manycases the algorithms used at this layer are far from brilliant. For example,many USB sticks and other cards lose data in case of unclean reboots/powercuts. So, be very careful.
What are the differences between flash devices and block drives?
The following table describes the differences between block devices andraw flashes. Note, SSD, MMC, eMMC, RS-MMC, SD, mini-SD, micro-SD, USB flashdrive, CompactFlash, MemoryStick, MemoryStick Micro, and other FTL devicesare block devices, not raw flash devices. Of course, hard drives arealso block devices.
Block device | MTD device |
Consists of sectors | Consists of eraseblocks |
Sectors are small (512, 1024 bytes) | Eraseblocks are larger (typically 128KiB) |
Maintains 2 main operations: read sector andwrite sector | Maintains 3 main operations: read from eraseblock,write to eraseblock, and erase eraseblock |
Bad sectors are re-mapped and hidden by hardware (atleast in modern LBA hard drives); in case of FTLdevices it is the responsibility of FTL to provide this | Bad eraseblocks are not hidden and should be dealt within software |
Sectors are devoid of the wear-out property (in FTL devicesit is the responsibility of FTL to provide this) | Eraseblocks wear-out and become bad and unusable afterabout 103 (for MLC NAND) - 105(NOR, SLC NAND) erase cycles |
So as one sees flashes (MTD devices) are somewhat more difficult to workwith.