I will look at lomtd, thanks. But if littlefs is not suitable (a quick look and it seemed it might be a reasonably choice for a 16KiB EEPROM?) is there an FS in NuttX that is suitable? "Out there" I find NASA's EEFS and one or two others I could try (and submit to NuttX; depending on licensing of course) but quicker to try/use something we already have of course.

On 16/12/2023 04:10, Xiang Xiao wrote:
On Fri, Dec 15, 2023 at 5:17 PM Sebastien Lorquet<sebast...@lorquet.fr>
wrote:

Hi,

I dont think you can use losetup to create a mtd device. loop devices
are regular block devices.

You can use lomtd to setup a mtd device loop:
https://github.com/apache/nuttx-apps/blob/master/nshlib/nsh_fscmds.c#L1144-L1306




This will only work if littlefs can mount a
block device (no idea if thats possible)


Yes, littlefs can work with block devices directly, the difference between
mtd and block is hidden by littlefs wrapper.
Of course, littlefs isn't an efficient solution for block devices since
the wear leveling built inside littlefs is useless and
harms the performance a lot.


what you need is an adaptation layer that will implement a mtd device on
an eeprom.

You can duplicate a spi flash driver, and change its read/erase/write
routines (and initialization) by copying code from a spi eeprom driver.

Sebastien.

Le 14/12/2023 à 19:13, Tim Hardisty a écrit :
Question first, then explanation.

How do I use losetup (which is what I think I need) with a character
memory device and mount an FS on it? SPI EEPROM and LittleFS
specifically.

Yes, it's a bad idea, probably, but I just want to have a play and
lack of NuttX/POSIX/Linux knowledge has bitten my behind again. This
is perhaps the 3rd time over the years I've asked but even checking
the dev emails archive and I can't find what I need.

SPI EEPROM is correctly registered as /dev/at25 and I can
read/write/etc to it as a character device. NB: it does not initialize
in the same way as an I2C EEPROM so you can't directly initialise it
as an mtd. It is for storage of settings, and some of the values may
change 10,000's time over the life of the product, hence EEPROM with
1,000,000+ write cycles.

But there is then no wear levelling or anything like that as just a
character device, so I thought I'd have a play, and LittleFS has a
small minimum sector size and *might* work. A quick Google turns up
the same Linux-related losetup examples that don't seem relevant; my
Googling skills are probably as bad as those of my software
engineering <grin><rolleyes>.

Any pointers/suggestions please?

Reply via email to