Author Topic: Macro definition uFILE_SYSTEM_START  (Read 89211 times)

Offline frank

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Macro definition uFILE_SYSTEM_START
« Reply #15 on: October 17, 2009, 10:03:12 PM »
Hi Mark,

We are using STM25P40 SPI flash.

Offline frank

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Macro definition uFILE_SYSTEM_START
« Reply #16 on: October 17, 2009, 10:35:07 PM »
Hi Mark,

We are using STM25P20 ,not P40. Please igore my previous updation.

After uploading just 0Menu.htm, file this is what displaying while executing dir command.

ftp> put 0Menu.htm

200 OK.
150 Data.
226 OK.

ftp: 2032 bytes sent in 0.00Seconds 2032000.00Kbytes/sec.

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 2032 May 1 2009 4.HTM
-rwxrwxrwx 1 502 502 2032 May 1 2009 8.HTM
-rwxrwxrwx 1 502 502 2032 May 1 2009 C.HTM
226 OK.
ftp: 226 bytes received in 0.11Seconds 2.05Kbytes/sec.
ftp>


So, something wrong.  Do I need to enable SPI_DATA_FLASH macro definition ?.

Here is my setting:
===============

#if defined SPI_FLASH_ST                                                 // {18} ST SPI FLASH used
    #define SPI_FLASH_STM25P20                                           // the available ST chips
//  #define SPI_FLASH_STM25P40                                           // the available ST chips
  //#define SPI_FLASH_STM25P80                                               
  //#define SPI_FLASH_STM25P16                                               
  //#define SPI_FLASH_STM25P32                                               
  //#define SPI_FLASH_STM25P64                                               

    #if defined SPI_FLASH_STM25P20
        #define SPI_FLASH_PAGES             (4*256)
    #elif defined SPI_FLASH_STM25P40                                       // 512k
        #define SPI_FLASH_PAGES             (8*256)
    #elif defined SPI_FLASH_STM25P80                                     // 1M
        #define SPI_FLASH_PAGES             (16*256)
    #elif defined SPI_FLASH_STM25P16                                     // 2M
        #define SPI_FLASH_PAGES             (32*256)
    #elif defined SPI_FLASH_STM25P32                                     // 4M
        #define SPI_FLASH_PAGES             (64*256)
    #elif defined SPI_FLASH_STM25P64                                     // 8M
        #define SPI_FLASH_PAGES             (128*256)
    #endif

    #define SPI_FLASH_PAGE_LENGTH 256
    #ifdef SPI_DATA_FLASH
        #define SPI_FLASH_SECTOR_LENGTH (16*SPI_FLASH_PAGE_LENGTH)       // sub-sector size of data FLASH
    #else
        #define SPI_FLASH_SECTOR_LENGTH (256*SPI_FLASH_PAGE_LENGTH)      // sector size of code FLASH
    #endif
    #define SPI_FLASH_BLOCK_LENGTH  SPI_FLASH_SECTOR_LENGTH
--------------------

#ifdef FLASH_FILE_SYSTEM
    #ifdef SPI_FILE_SYSTEM
      //#define SPI_FLASH_SST25                                          // use SST SPI FLASH rather than ATMEL
      #define SPI_FLASH_ST                                             // use ST FLASH rather than ATMEL
      //#define SPI_DATA_FLASH                                           // FLASH type is data FLASH supporting sub-sectors (relevant for ST types)
        #if defined SPI_FLASH_ST
            #if defined SPI_DATA_FLASH
                #define FILE_GRANULARITY (2*SPI_FLASH_BLOCK_LENGTH)      // (2 x 4096 byte blocks) file granularity is equal to a multiple of the FLASH granularity (as defined by the device)
            #else
                #define FILE_GRANULARITY (SPI_FLASH_BLOCK_LENGTH)        // (65535 byte blocks) file granularity is equal to a multiple of the FLASH granularity (as defined by the device)
            #endif
        #elif defined SPI_FLASH_SST25
            #define FILE_GRANULARITY (SPI_FLASH_BLOCK_LENGTH)            // (4096 byte blocks) file granularity is equal to sub-sector FLASH granularity (as defined by the device)
        #else
            #define FILE_GRANULARITY (4*SPI_FLASH_BLOCK_LENGTH)          // (4224/2112 byte blocks) file granularity is equal to a multiple of the FLASH granularity (as defined by the device)
        #endif
    #else
        #define FILE_GRANULARITY (FLASH_GRANULARITY)                     // file granularity is equal to the FLASH granularity (as defined by the device)
    #endif
#endif

---------------------
#ifdef FLASH_FILE_SYSTEM
    #if defined SPI_FILE_SYSTEM                                          // this is a test setup for external SPI FLASH, with the parameters at the end of internal FLASH
        #define PARAMETER_BLOCK_START 0x1f000                            // {34} FLASH location at 2 parameter blocks short of end of internal FLASH
        #define uFILE_START 0x20000                                      // immediately after internal FLASH

        #define SINGLE_FILE_SIZE (FILE_GRANULARITY)                      // each file a multiple of 16k (64k ST)
        #if SINGLE_FILE_SIZE < 20000                                     // {36}
            #if SPI_DATA_FLASH_SIZE < (64*SINGLE_FILE_SIZE)              // {42} allow testing smallest SPI FLASH
                #define FILE_SYSTEM_SIZE  SPI_DATA_FLASH_SIZE
            #else
                #define FILE_SYSTEM_SIZE (64*SINGLE_FILE_SIZE)           // 1Meg reserved for file system (assuming 8k file size) {34} [PAR_BLOCK_SIZE removed]
            #endif
        #else
            #define FILE_SYSTEM_SIZE (16*SINGLE_FILE_SIZE)               // 1Meg reserved for file system {35}
        #endif
    #else                                                                // this is the normal set up for internal FLASH


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3244
    • View Profile
    • uTasker
Re: Macro definition uFILE_SYSTEM_START
« Reply #17 on: October 17, 2009, 10:56:14 PM »
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 STM25PE 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 system

it should be

            #define FILE_SYSTEM_SIZE (4*SINGLE_FILE_SIZE)                  // 256k reserved for the file system

What 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

Offline frank

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Macro definition uFILE_SYSTEM_START
« Reply #18 on: October 17, 2009, 11:03:35 PM »
Hi Mark,

Thankyou very much for your valuable informatin. I will modify the setting as per your suggestion, and try atleast 4 files.

- franklin

Offline frank

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: Macro definition uFILE_SYSTEM_START
« Reply #19 on: October 19, 2009, 11:27:18 PM »
Hi Mark,

As you said, this works now. May be we need to think about different SPI flash.