Re: Direct flash access from filesystem

Paul Sokolovsky

Hello Andrzej,

On Mon, 21 Aug 2017 10:31:26 +0200
Andrzej Kaczmarek <andrzej.kaczmarek@...> wrote:

Hi all,

I'm porting NFFS (Newtron Flash File System) from Mynewt to Zephyr.
The original fs implementation has direct access to flash, i.e. it
will read, write and erase data to/from flash directly using flash
HAL. But existing fs implementation in Zephyr (FAT12) is using disk
subsystem to access flash so I wanted to do the same in NFFS, however
it does not seem to be useful here because:
- NFFS needs byte-level access to flash - disk subsystem allows
sector-level access only
- NFFS takes case of erasing sectors itself, when required - disk
subsystem does this during writes

​So does it make sense to try to adjust NFFS and/or disk subsystem to
work together? ​Or it's actually better to let NFFS access flash
directly, just as it does in Mynewt?
Well, NFFS is a *flash* filesystem, it's expected that it would
require more specific underlying device type than a generic FS like
FAT which can work on any block device. The situation is similar to
Linux, where JFFS2, etc. require not just a block device,
but /dev/mtd (memory technology device).

So, I wouldn't be surprised that such a requirement arises, but how
to deal with it - extend existing block device interface in Zephyr,
introduce a separate MTD interface, or just work on top of existing
flash drivers, if they are generic enough - that's what more
experienced folks may suggest, I hope.

I opt for the latter as it makes
porting quite easy. The NFFS partition would be defined in DTS so
this is the only area NFFS code can access. Also all flash operations
are extracted to glue layer so they can be implemented in a different
ways in future, for example if one needs to have NFFS in RAM (which
disk subsystem would allow) for some reason this won't be a problem.


​Best regards,

Best Regards,
Paul | Open source software for ARM SoCs
Follow Linaro:!/linaroorg -

Join to automatically receive all group messages.