STD Filesystem issue

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

STD Filesystem issue

Post by SeeCwriter »

Using v2.8.3, I'm using the EFFS-STD-HTTP example for the Nano to write a test file. I use fs_main() to initialize the file system, then I call WriteFile() to create a test file.

Code: Select all

WriteFile( (PBYTE)"Hello World", "hworld.bin", strlen("Hello World") );
WriteFile does an fs_open and fs_write without error, but when it does an fs_close it throws error F_ERR_INVALIDDRIVE. What happened between the write and the close to lose the drive?

Code: Select all

      rvW = fs_write( pDataToWrite, 1, NumBytes, fp );
      if ( rvW != NumBytes )
         iprintf( "\r\n*** Error in fs_write(%s): %ld out of %ld bytes writte\r\n", pFileName, rvW, NumBytes );

      rvC = fs_close( fp );  // Close a previously opened file of type FS_FILE
      if ( rvC != FS_NO_ERROR )
      {
         iprintf( "*** Error in fs_close(%s): ", pFileName );
         DisplayEffsErrorCode( rvC );
       return 0;
      }
And when I call DumpDir() to display the directory contents it shows an empty file.

Here is the output:

File system version: EFFS_STD ver:1.91
Init NOR.
*** Error in fs_close(hworld.bin): F_ERR_INVALIDDRIVE
Found File [/hworld.bin] : 0 Bytes
Display time in gettimedate(): 00:00:00 |01/00/1980 |
hworld.bin |00:00:00 |01/00/1980 | 0 Bytes


I noticed in the EFFS-STD-HTTP example that there was a function for doing a write and read test, ReadWriteTest(), so I tried it and did a directory dump after it was complete. Same file close error and an empty file.

Here is the output.
--------------------
Creating test file: TestFile.txt
Wrote 15 bytes: Hello World 0
Wrote 15 bytes: Hello World 1
Wrote 15 bytes: Hello World 2
Wrote 15 bytes: Hello World 3
Wrote 15 bytes: Hello World 4

Rewinding file
Read 75 bytes:
Hello World 0
Hello World 1
Hello World 2
Hello World 3
Hello World 4

Closing file TestFile.txt

*** Error in fs_close(): F_ERR_INVALIDDRIVE
Found File [/TestFile.txt] : 0 Bytes
Display time in gettimedate(): 00:00:00 |01/00/1980 |
TestFile.txt |00:00:00 |01/00/1980 | 0 Bytes
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: STD Filesystem issue

Post by TomNB »

Hello,

I just ran the effs-http example off a clean 2.8.3 install on a MOD54417 and it is working properly. What platform are you using?
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: STD Filesystem issue

Post by SeeCwriter »

I'm using the NANO. I am writing a few files to flash that take up about 6k bytes. So I reduced the file system size to 16k from the 64k used in the example. Once I restored the file system size to 64k the problem went away. Seems like a lot memory for a relatively small amount of data.
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: STD Filesystem issue

Post by TomNB »

You may already know this, but you can't just make it an arbitrary size. When you reduced to 16k, did you follow all the rules for sector size, block size, descriptor size, etc? We put a lot of comments in the example file for the 64k configuration, but you should also take a look at the effs-std manual in the docs directory. If you were getting corruption, my guess is the settings were not correct.
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: STD Filesystem issue

Post by TomNB »

One other question out of curiosity. You have 8MB of flash on the nano. How much of that space are you using?
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: STD Filesystem issue

Post by SeeCwriter »

I am using about 3.5% of flash and a similar percentage of ram.
Post Reply