Programs for all boards
Rsadeika
Posts: 3,837
The program attached is a softRTC, a clock program that runs in RAM, while the board is turned on. It is a UI based program, so you have commands to set the clock, and then get the time, and etc. This is a C version, although a C++ version should not be a very big effort to accomplish.
I am still thinking about a filetest program that could be run on boards that do not have an SD reader, although I am not sure how the upper 32KB could be set up to work with a file directory. Of course this kind of program would limit it to using the CMM mode, if the EEPROM is going to be used for storing files. Still not sure if something like this is possible.
Ray
I am still thinking about a filetest program that could be run on boards that do not have an SD reader, although I am not sure how the upper 32KB could be set up to work with a file directory. Of course this kind of program would limit it to using the CMM mode, if the EEPROM is going to be used for storing files. Still not sure if something like this is possible.
Ray
Comments
Ray
Hi Dave,
What would it take to make a version up to 32MB for Flash?
I'm thinking of the case where 2x 16MB QuadSPI devices are used.
Thanks,
--Steve
The original EEProm file system I wrote is similar to this in that it was stream oriented. However, each block contained a ponter at the end that would chain to the next block. I'll have to look at it again.
A big "don't abuse it" disclaimer and/or some limiting strategy would be needed for chip type EEPROM/Flash.
eefs.spin implements a file structure kind of like the FAT file system, except there is no central file allocation table. Instead, each block contains an index that indicates if the block is in use, and the address of the next block in the chain. Directory entries consist of 30-bytes each, which allows for 2 entries for each 64-byte block, plus the 4-byte index. For the most part, directories are treated just like files. The size is updated whenever a new directory entry is added to the end. This should probably be changed so that the filesize is zero for a directory, just like in the FAT file system. That would reduce the number of times the directory pages get rewritten. Also, the current method for allocating a new block is to just use the first one available. This could be modified to use a page write count, and use the block with the least number of writes instead.
The circular buffer flash approach sounds good.
Ray
I encountered problems with spin2cpp and CLIB before. This is because CLIB contains methods that use the standard C function names. Eric got around this by capitalizing the first character of all the Spin methods when he converts it to C++. Maybe he neglected to do this when converting to C. Try changing "malloc" to "Malloc" in the Spin code to see if that fixes it. However, ultimately you would just want to use the standard C functions provided by the library. It would be nice if spin2cpp understood that calls to the CLIB methods should be preserved as calls to standard C functions.
Integrating eefs with the C file I/O will require duplicating the drivers used for SD file I/O. You'll need to modify FileDriver.c, which is located in the propgcc/lib/drivers source directory. You'll need to call functions in eefs instead of dosfs. You'll also need to modify the dfs_mount routine to make an eefs_mount routine. It's not a trivial task, but can be done.
I looked at flash file systems a bit more, and I think eefs could be modified to handle flash chips. It would need a few changes to handle wear leveling better, and it would need to be modified for the 512-sector size. It would also need changes to support block erase and reclaim.
Ray
Ray
Ray
I'm still using the spin2cpp version of eefs.c. I'll generate a cleaner version of eefs.c at some point. Then the next step is to add wear-leveling support and make it work with flash memory.
Ray
The directory functions are not part of the file driver. We would need to add them to the file driver function list to make them accessable in the same way as fopen, fread, etc. The drawback to this is that they will always be linked into the executable even if you never call them.
I tried a test where I added _FileDriver to the driverlist, and changed the File_prefix in eeFileDriver.c from a null string to "ee:". The program grew to about 26KB. I was able to copy a file from an SD card to EEPROM by typing "cat file1 >ee:file1. However, the opendir, mkdir, chdir, etc. functions only worked on the EEPROM due to the issue I mentioned above.
I have a new project that I started, using the XBee and Sensirion SHT-11 module. I am thinking of having a remote slave board that has the SHT-11 and XBee on it, and the base board, with an XBee on it, which will transfer the info to a PC for processing with a spreadsheet or database. I tried working out some ideas using C, but I just can not get the create new cog in XMMC to work the way I want it too work. So, what I am thinking is to make version in Spin, if all the code fits, then do a spin2cpp on it, just see how it looks and works in C.
The slave board, as I mentioned will have an XBee and SHT-11 module, which will use the uSD for temporary storage before it gets sent to the base board via XBee. I could probably use the eefs Spin version to start, but I would really need to be using the uSD for longer term data gathering. Any ideas will be appreciated.
Ray
An early version of spinix supported both SD and EEPROM file systems at the same time. The two file drivers were mapped to different directories under the root directory so you could do something like "cat /sd/file1 >/ee/file1". I removed EEPROM file support from later versions of spinix.