Project - Tiny File System

@ Valkyrie-MT - Thank you for the feedback and kind words.

Now that I have the physical device I will test that out. One of the key issues I had in the code was with the SPI and the fact that the data in the read buffer is offset by the length of the write buffer. I have fixed that last night, but will now need to run the tests for the edge cases like the compaction etc. This weekend will hopefully see a lot of activity on the file system.

Please let me know of any issues or pain points you come across.

I just dropped a quick update. I have done some more testing and fixes. If you are using this, please make sure you pick-up the latest version.

So far I have tested the following

Create
Open
Read
ReadAllBytes
Write
Close
Copy
Compact
Delete
Mount
Format
GetFiles
GetFileSize

1 Like

@ taylorza - top man :slight_smile:

@ Valkyrie-MT - Would you mind taking the latest version out for a spin?

Since addressing the SPI issues I have done more testing and tweaking and I am hopeful that the compaction and the partial compaction are working. If you have a scenario that I am not considering I would be glad to hear about it and address it.

I tryed this code:

            
SystemConfiguration systemConfiguration = null;

            var systemConfigurationExist = _fileSystem.Exists(_systemConfigurationFileName);

            if (systemConfigurationExist)
            {
                byte[] buff = _fileSystem.ReadAllBytes(_systemConfigurationFileName);

                systemConfiguration = Reflection.Deserialize(buff, typeof(SystemConfiguration)) as SystemConfiguration;
            }
            else
            {
                systemConfiguration = getDefaultSystemConfiguration();
                
                byte[] buff = Reflection.Serialize(systemConfiguration, typeof(SystemConfiguration));

                _fileSystem.WriteAllBytes(_systemConfigurationFileName, buff);
            } 

but the Exists never returns “true”…

@ AlbeNET - What is the name that you have for _systemConfigurationFileName? The filename should not exceed 16 bytes otherwise it will be truncated when written to the device and you will need to used the truncated name.

1 Like

@ taylorzaKing: it was “SystemConfiguration” too long!!! :wink: now with "SysConf " it works! FANTASTIC!!!

I am glad that resolved your issue. If you have any other issues please let me know.

Has anyone got the Flash Module working as a USB mass storage device? I want to be able to plug my netmf device into a PC and work with the files in the Flash Module like I can with the SD Card.

@ untitled - No, Flash Module will not work like that.

@ untitled - I have never looked into it, but I would assume that for this to work a native file system driver that is integrated into the NETMF file system infrastructure would be required.

Maybe this requires native code (as taylorza suggested).

I had thought it might be possible to implement a Mass Storage device using the Microsoft.SPOT.Hardware.UsbClient and this tiny file system. No?

Interesting idea.

Using USBC_Device class and emulate a typical USB storage device but using this tiny file system underneath.

That actually might work.

1 Like

Has anybody used this on a G120 / Cobra II boards internal flash?
if so what is the chip select cpu pin#?
I know it uses spi2 .
thanks

What do you mean with internal Flash? G120 does not have internal flash as far as I knoiw!
There is an NAND FLash module, but this is external.

The 4MB flash chip on the SOM. I believe it is connected to SPI 2. What is the CS Cpu pin#?
Will the default device driver work for this or is it different?
It works on the USB Mountaineer board.

Looks like for the G120 only EWR is available as taylorza said in this topic : http://www.tinyclr.com/forum/topic?id=10189&page=1

I hope I’m missing something obvious. I’m using a S25FL512S 64MB module (http://www.mouser.com/ds/2/380/S25FL512S_00-7893.pdf) with the TinyFileSystem.

I thought everything was working great. The protocol seems to be compatible. Then I noticed every time I unplug my board it seems like I lost my file system. On the next boot up CheckIfFormatted returns false and my program reformats the flash.

Everything is fine if I stop/start or re-deploy my program. As long as the USB cable is connected everything is fine. This only happens when I remove power.

Any ideas?

I found the problem. I had to add this method…


public bool WriteDisable()
    {
        data1[0] = CMD_WRITE_DISABLE;
        _spi.Write(data1);
        data1[0] = CMD_READ_STATUS;
        _spi.WriteRead(data1, data2);
        return true;
    }

Then I had to add it to each method that wrote data like this…


    public void EraseChip()
    {
      while (WriteEnable() == false) Thread.Sleep(0);
      data1[0] = CMD_ERASE_CHIP;
      _spi.Write(data1);
      while (WriteInProgress() == true) Thread.Sleep(0);
      while (WriteDisable() == false) Thread.Sleep(0); 
    }

@ untitled - That is interesting, is is a documented requirement for that flash module?

You should consider publishing that as a IBlockProvider for the file system. If you have no objection, it might be worth adding to the file system as an option. Since you are using the file system I would appreciate it if you let me know of any issues you face/fix.