Shop OBEX P1 Docs P2 Docs Learn Events
EEPROM File System — Parallax Forums

EEPROM File System

Dave HeinDave Hein Posts: 6,347
edited 2010-04-07 22:54 in Propeller 1
I want to begin working with file system code, such as fsrw.· However, I want to use an EEPROM instead of an SD card.· Does fsrw support EEPROMs, or does anybody have spin code that implements a file system on EEPROM?

Dave

Comments

  • lardomlardom Posts: 1,659
    edited 2010-04-03 15:14
    Andy Lindsay has posted an eeprom data logging lab in the 'propeller education kit' forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


  • Dave HeinDave Hein Posts: 6,347
    edited 2010-04-03 20:56
    I looked at the sticky thread, but·it looks like·basic EEPROM read/write routines.· What I am looking for a file system with file names, directories, etc.· I could adapt fsrw for EEPROM, but it would save time if somebody else has already done this.· Also, fsrw seems a bit much for use with an EEPROM.
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-04-03 21:26
    FSRW does not support directories. And YES ... I also think that it could be a bit overkill. You need at least root directory and a cluster-table, where the size of both depends on the size of the SD card. But even in old times FAT was used in systems having at least some hundreds of kilobytes.
    In the end it depends on the usecase. If you change content very often FAT is fine, because it allows files to be split if continuous free clusters are not big enough to store the file. But using clusters also means to waste storage area, as it's moste likely that the last cluter is not completely filled. For a 32k EEPROM I'D suggest a cluster size of 128 bytes, so the cluster address range is 0-255, which can be stored in one byte.

    An easy solution would be a linked list. You simply store the filename and the size of the file followed by the file itself. When you add file-position with filesize you'll find the next filename/size .... You don't waste bytes, your filename can be as long as you want ... But deleting/creating files is a bit of work.
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-04-07 16:58
    The attached disk3.spin contains my first cut at an EEPROM file system.· The test program is command driven.· Type "help" to get a list of the commands.· This programs sets up a file system using the second half of the boot EEPROM.· The code has to be loaded directly to RAM (F10) or you will wipe out the file system in EEPROM if you load the program to EEPROM (F11).

    The first time the program runs it will recognize that the EEPROM doesn't contain a file system and it will tell you to run the "format" command.· The "create" commmand will create a zero-length file.· The "dir" command will show a directory listing.· The "append" command will append a line of text to an existing file.· Enter a blank line to exit the append mode.· The "type" command will print out the contents of a file.

    My orignal idea was to treat the EEPROM as an array of longs, with a file header that contained a blocksize, pointer to the next block and pointer to the next file.· A file consists of a chain of blocks of varying size.· Unused disk space initially consists of a large block that is as large as the EEPROM minus a few bytes for the disk header.· The unused disk space block is whittled down every time a new block is allocated for a file.

    disk3.spin still contains the block headers for this method, but I am converging on a fixed-block size scheme, which will eliminate the need· for the block size parameter in the header.· My plan is to use block sizes, which match the size of the EEPROM page.· This is 64 bytes for the 24LC256.· This will allow me to easily take advantage of page-mode writes.· The header overhead will only be 3 or 4 bytes per 64-byte block.

    disk3.spin used the clib and Basic_I2C_Driver object from the OBEX library.
  • TonyWaiteTonyWaite Posts: 219
    edited 2010-04-07 20:45
    Very neat - and generated by CSPIN too I see!

    Regards,

    T o n y
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-07 20:58
    Once upon a time I wrote an operating system for the Prop using a simple file system in EEPROM. It was much more limited than yours in that it allocated 32K "pages" of EEPROM to named files, mostly for supporting named programs. With lots of EEPROM like 4 x 128K, this was actually very reasonable. Here's one link to it: http://forums.parallax.com/showthread.php?p=598350
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-04-07 22:01
    Mike, your OS looks interesting.· I'll have to check it out when I have a chance.· I'm using your Basic_I2C_Driver object, which works very well.· Is there a PASM version that will run at a higher speed?· I didn't see any PASM I2C objects for EEPROM in the OBEX.

    Tony, I wrote the original code in C so I could develop it on various platforms.· This way I can tinker with it during my lunch hour at work, and then copy it to one of my PCs at home.· Once I get it working in C I convert it to Spin and run it on the Prop.

    Dave
  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-07 22:54
    The SD card SPI / I2C driver included in FemtoBasic (sdspiFemto.spin) is the PASM descendant of the I2C-only driver included in the Propeller OS. It's designed for use separate from FemtoBasic and can do double buffered I/O if you modify the Spin<->PASM interface routines. The existing routines wait for I/O to finish before returning. It would be trivial to remove that and add a separate call to wait for I/O to finish (and report any error).
Sign In or Register to comment.