krzydec
Posts: 1
Joined: Fri Oct 16, 2020 10:35 am

Accessing EEPROM memory from file system

Fri Oct 16, 2020 10:59 am

Hello

Is anybody aware of the method of making a eeprom memory part of the file system?
I would like to have a non volatile memory to store some logs and variables to extend an SD card life.

I was thinking about adding eeprom or f-ram and mounting it as a part of the file system.
I will appreciate any directions, tutorials, projects to look at.

I already did some google research , this is what I found so far:

https://github.com/nasa/eefs

https://github.com/joembedded/JesFs

but to be honest I don't know where to start with implementing this.

Maybe somebody did something like this in the past and it's willing to share the knowledge.

User avatar
DougieLawson
Posts: 40193
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 12:59 pm

It's not possible (or desirable).
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

timg236
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 691
Joined: Thu Jun 21, 2018 4:30 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 1:11 pm

krzydec wrote:
Fri Oct 16, 2020 10:59 am
I would like to have a non volatile memory to store some logs and variables to extend an SD card life.
That makes no sense. You'll wear out the EEPROM long before the SD card if you do that.

DarkElvenAngel
Posts: 1048
Joined: Tue Mar 20, 2018 9:53 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 1:17 pm

DougieLawson wrote:It's not possible (or desirable).
Are you sure about that?

I have a RTC with a small amount of ram that is backed up by the battery and I can hold values between reboots. It's mapped as a file not a filesystem it's only a few bytes. I would think the OP application would be possible. Even if it maps the eeprom as a file you can still put a filesystem on it from there and off you go.

I thought about doing something like this but I abandoned the idea using a usb drive was much simpler and more portable.

Why do you think an eeprom or fram would be a better choice?

stevend
Posts: 284
Joined: Fri Oct 11, 2013 12:28 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 1:19 pm

I'm assuming you want to attach an EEPROM or FRAM chip to your Pi, and use that for storage.
FRAM is slightly easier to code for, but costs more.
It will probably be an 8-pin chip with a serial-type interface; if so, go for SPI rather than I2C (faster).

You could look at littleFS, which is designed for small memories, and also designed to be resilient if the power is cut off without warning. At the hardware end you need some code to interface to the chip; possibly that already exists for the Pi; if not, it's relatively trivial. LittleFS can also be set up to do wear levelling if desired, although FRAM in particular probably doesn't need it.

If you only want to access the file system from your own code, there is a fairly familiar API to littleFS. To integrate it into the main file system would require more effort; I know littleFS uses FUSE for testing, which may do what you want, but I don't know enough to comment. From DarlElvenAngel's comments, it seems likely that there is a way forward here.

User avatar
Botspot
Posts: 1549
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 3:48 pm

stevend wrote:
Fri Oct 16, 2020 1:19 pm
I'm assuming you want to attach an EEPROM or FRAM chip to your Pi, and use that for storage.
No, I think the OP is asking how to make changes to the Pi4's internal EEPROM.
Want to run Minecraft Java on your RPi? Easiest way is with Pi-Apps - just click Install.
https://github.com/Botspot/pi-apps
Pi-Apps also includes Zoom, Visual Studio, Tor browser, Windows 10 theme, and 33 more.
Over 50,000 users!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 27425
Joined: Sat Jul 30, 2011 7:41 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 3:56 pm

Which is a really bad idea. There is no guarantee the EEPROM will remain as is. For example, it could change size, leaving no space for extra data other than the bootloader. It has no wear levelling either so could wear out pretty quickly.

Just use the SD card. Or add EEPROM on the GPIO's/SPI/I2C etc.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

DarkElvenAngel
Posts: 1048
Joined: Tue Mar 20, 2018 9:53 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 4:01 pm

krzydec wrote:
Fri Oct 16, 2020 10:59 am
I was thinking about adding eeprom or f-ram and mounting it as a part of the file system.
Botspot wrote:
stevend wrote:
Fri Oct 16, 2020 1:19 pm
I'm assuming you want to attach an EEPROM or FRAM chip to your Pi, and use that for storage.
No, I think the OP is asking how to make changes to the Pi4's internal EEPROM.
They want to add one going back to OP.

I agree though using an eeprom like this isn't really a good idea when the goal is to the SD card an eeprom will not hold much data. The fram on the other hand wouldn't ware out and would make for an interesting proof of concept. Again the space is going to be minimal and not useful for logs

hippy
Posts: 8545
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 5:24 pm

FUSE (Filesystem in Userspace) is one way to turn virtually anything into a usable filesystem.

stevend
Posts: 284
Joined: Fri Oct 11, 2013 12:28 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 8:11 pm

DarkElvenAngel wrote:
Fri Oct 16, 2020 4:01 pm
I agree though using an eeprom like this isn't really a good idea when the goal is to the SD card an eeprom will not hold much data. The fram on the other hand wouldn't ware out and would make for an interesting proof of concept. Again the space is going to be minimal and not useful for logs
Depends how much space you actually need - not every system generates megabytes of logs. You can get FRAM up to 0.5MByte (1MByte coming soon), which can be sufficient for some applications. And the robustness of a file system such as littleFS can be very valuable in some applications - a log isn't much help in resolving problems if its on the corrupted bit of the SD card....
If you've got a small memory you want minimal overhead for the file system, which rules out FAT.
If more space is needed, there's always the possibility of adding a small serial flash chip; some of the available file systems handle the complexities of partial block writes, data moves and wear levelling.
These file systems originally evolved to serve the embedded systems market, where memory is often short; hardly a problem on the Pi, but they still have their uses.

DarkElvenAngel
Posts: 1048
Joined: Tue Mar 20, 2018 9:53 pm

Re: Accessing EEPROM memory from file system

Fri Oct 16, 2020 10:34 pm

stevend wrote:
Fri Oct 16, 2020 8:11 pm
DarkElvenAngel wrote:
Fri Oct 16, 2020 4:01 pm
I agree though using an eeprom like this isn't really a good idea when the goal is to the SD card an eeprom will not hold much data. The fram on the other hand wouldn't ware out and would make for an interesting proof of concept. Again the space is going to be minimal and not useful for logs
Depends how much space you actually need - not every system generates megabytes of logs. You can get FRAM up to 0.5MByte (1MByte coming soon), which can be sufficient for some applications. And the robustness of a file system such as littleFS can be very valuable in some applications - a log isn't much help in resolving problems if its on the corrupted bit of the SD card....
If you've got a small memory you want minimal overhead for the file system, which rules out FAT.
If more space is needed, there's always the possibility of adding a small serial flash chip; some of the available file systems handle the complexities of partial block writes, data moves and wear levelling.
These file systems originally evolved to serve the embedded systems market, where memory is often short; hardly a problem on the Pi, but they still have their uses.
I found an old Kickstarter F-RAM hat don't think it ever got made. I'd be interested in F-RAM for my kiosk project it's nice having a little non-volitial memory but more would be welcome. I'm interested in how this all unfolds

stevend
Posts: 284
Joined: Fri Oct 11, 2013 12:28 pm

Re: Accessing EEPROM memory from file system

Sat Oct 17, 2020 8:22 am

DarkElvenAngel wrote:
Fri Oct 16, 2020 10:34 pm
I'd be interested in F-RAM for my kiosk project it's nice having a little non-volitial memory but more would be welcome. I'm interested in how this all unfolds
I've been using I2C FRAM for years, and found it rock solid and very simple to use - byte-sized access for both read and write, and no need to erase and/or wait when writing.
LittleFS uses FUSE for the test harness, which I've not looked at, but not sure what it does at the hardware level. It's a bit slow with an I2C FRAM at 400kHz; hence my suggestion of using SPI. But it does have very low overhead; from memory a FAT file system has overhead of about 78kBytes, which is a lot if you have 256K of FRAM. LittleFS has much less than 1K if you configure it right.

DarkElvenAngel
Posts: 1048
Joined: Tue Mar 20, 2018 9:53 pm

Re: Accessing EEPROM memory from file system

Sat Oct 17, 2020 1:44 pm

stevend wrote:
Sat Oct 17, 2020 8:22 am
DarkElvenAngel wrote:
Fri Oct 16, 2020 10:34 pm
I'd be interested in F-RAM for my kiosk project it's nice having a little non-volitial memory but more would be welcome. I'm interested in how this all unfolds
I've been using I2C FRAM for years, and found it rock solid and very simple to use - byte-sized access for both read and write, and no need to erase and/or wait when writing.
LittleFS uses FUSE for the test harness, which I've not looked at, but not sure what it does at the hardware level. It's a bit slow with an I2C FRAM at 400kHz; hence my suggestion of using SPI. But it does have very low overhead; from memory a FAT file system has overhead of about 78kBytes, which is a lot if you have 256K of FRAM. LittleFS has much less than 1K if you configure it right.
Okay questions,
How are you accessing the F-RAM with a program or kernel driver? What F-RAM chip are you using? And would your setup work for the OP?

stevend
Posts: 284
Joined: Fri Oct 11, 2013 12:28 pm

Re: Accessing EEPROM memory from file system

Sat Oct 17, 2020 6:46 pm

DarkElvenAngel wrote:
Sat Oct 17, 2020 1:44 pm
Okay questions,
How are you accessing the F-RAM with a program or kernel driver? What F-RAM chip are you using? And would your setup work for the OP?
I've actually been using FRAM on embedded non-Linux systems; hence my vagueness on some points. Similarly with LittleFS; however I do know that the project uses FUSE for much of the testing; with, I think, some sort of memory driver to emulate the memory. It sounds as if FUSE will manage the hooks between the OS and the LittleFS driver; the other piece of the puzzle is the low-level hardware access driver between LittleFS and the FRAM. It's not difficult code; basically initialise interface, read block of FRAM, write block of FRAM; possibly there's already a suitable low-level driver if someone knew where to look.
On actual parts, I've been using the Cypress (formerly Ramtron, and now Infineon) 8-pin chips with I2C interface - 32K x 8 and 128K x 8. They seem to have changed the part numbers since I last bought any; CY14X101J1 looks to be the 128K x 8 part. For this application I'd recommend similar devices with an SPI interface - the CY15B108QN is actually 1MByte - although not cheap. Other manufacturers do what appear to be pin-compatible parts; Rohm and Fujitsu at least.

Return to “General discussion”