Hi Franklin
The STM25P20 is a code FLASH. It has 4 sectors of each 64k in size (writes are possible as 256 byte pages but deletes require a complete 64k sector to be erased) - there are STM25P
E types (data FLASH) with 4k sectors which are generally better suited for use as file system.
This means that you must
not set
SPI_DATA_FLASH since the device will physically not be able to work with it.
The restriction is basically that you can only have up to 4 files saved in the file system (with this chip).
Where there is certainly a setup error is
#define FILE_SYSTEM_SIZE (16*SINGLE_FILE_SIZE) // 1Meg reserved for file systemit should be
#define FILE_SYSTEM_SIZE (4*SINGLE_FILE_SIZE) // 256k reserved for the file systemWhat will happen with 1M setting is that the file system believes that it has more space and will try to write to higher locations - this will probably cause a wrap around in the physical chip and pages may be overwritten (without deletes) and so corruption result. In fact I can't test this with the simulator because it doesn't wrap around but instead writes beyond physical memory and crashes the simulator...
If I test with the 256k setting and copy all of the demo web pages I get the following in the file system afterward:
220 Welcome M5225X FTP.
Benutzer (192.168.0.3:(none)):
331 Enter pass.
Kennwort:
230 Log OK.
ftp>
ftp> dir
200 OK.
150 Data.
-r-xr-xr-x 1 502 502 1150 May 1 2009 favicon.ico
-rwxrwxrwx 1 502 502 2032 May 1 2009 0.HTM
-rwxrwxrwx 1 502 502 2519 May 1 2009 1.HTM
-rwxrwxrwx 1 502 502 2007 May 1 2009 3.JPG
226 OK.This is the result is what I expect because the file system will only accept files called '0', '1', '2' and '3'. (see the uFileSystem guide).
Generally I wouldn't use such a chip but you may be able to use it in sub-file mode (see
http://www.utasker.com/docs/STR91XF/FileSystemSTR91X.PDF ). Another way to make very good use of it would however be to used an embedded user file system (
http://www.utasker.com/docs/uTasker/uTaskerUserFiles.PDF) where all of the files are packed into a single file (it is then not possible up upload individual files but a complete project set can be embedded in a single file, which can then be uploaded and replaced via FTP).
It depends on which use you actually have for the chip and the file system - once you are convinced that it is basically working you can decide which mode of operation is best, or whether a different chip type is more suitable.
Regards
Mark