Main Site Documentation

Is there a way to persistent data without SD card add-on?


#1

I noticed TinyCLR provides a filesystem library for when the card is provided with a SD card, which is not the case for Fez.

I also know this topic has been covered for NETMF but not for TinyCLR.
So, on the new Fez, is there a way to persistent data without a SD card add-on?

If so, can you please provide some sample code?
If not, can you please provide some sample code for when one add e.g. a SD card-add on using SPI?

Help shall be much appreciated.


#2

We already have SPI drivers for SD cards and looking into ways to implement FAT on managed side. The SD code is not public but we can share it if you promise to help :wink:

Is implementing FAT something you can tackle? I am thinking a very simple library.


#4

Gus, thanks for the quick response.
I had a quick look at maybe porting FatFs (especifically Petit FatFs) (see http://elm-chan.org/fsw/ff/00index_p.html) from c to c#, but I must admit I’m not a strong enough programmer to do that professionally (and do not have the time really :frowning_face:).
What I’m only looking for now is just a simple “Settings type” library which either writes to the MCU flash or to the SD card, providing the following three basic functions:
void SetValue(string key, string value);
string GetValue(string key);
void ClearValues();
I can help with that for now (for the SD card) if you can give me access to your SD card code :wink:


#5

Gus, I think implementing a basic Settings Library will be relatively simple because it will manage only a single string saved as a Json serialised hashtable.
I’ll share my code with you, so would you be so kind to help with the SD card SPI drivers please?


#6

I finally decided to port the FatFs library to c# to run on a FEZ.
The end result now works well enough for me.
I used a Micro SD Card Shield and controlled it using the FEZ SPI port.
If anyone is interested, the code and examples can be found at:


Its unsupported code, so please use at your own risk.
Also please feel free to improve on it.


#7

Wow that is great. Sorry I got too busy to share what I have but looks like you have a lot more accomplished. I look forward to trying your code.

What file system functions have you tested?


#8

All the high-level ones that allows basic functionality:
f_mount
f_open
f_write
f_read
f_close
f_unlink
f_mkdir
f_stat
f_getfree
f_rename
Have a look in Program.cs, it shows all the functions tested.


#9

Basically, everything :wink: can’t wait to try it out.