A board support package for the LPC4088 Display Module.

Dependencies:   DM_HttpServer DM_USBHost

Dependents:   lpc4088_displaymodule_emwin lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI ... more

Fork of DMSupport by EmbeddedArtists AB

Embed: (wiki syntax)

« Back to documentation index

QSPIFileSystem Class Reference

QSPIFileSystem Class Reference

Access the filesystem on an QSPI flash using SPIFI. More...

#include <QSPIFileSystem.h>

Public Member Functions

 QSPIFileSystem (const char *name)
 Create the File System for accessing a QSPI Flash.
int format (unsigned int fsSizeInMB=8)
 Creates a new file system on the QSPI flash.
bool isformatted ()
 Tests if there is a file system present on the QSPI flash.
bool getMemoryBoundaries (uint32_t *pStartAddr, uint32_t *pEndAddr)
 Retrieves the start and end addresses for the file system.

Detailed Description

Access the filesystem on an QSPI flash using SPIFI.

One way to utilize the 8MByte of QSPI FLASH on the LPC4088 QuickStart Board is to place a file system on it. The QSPIFileSystem is using the FileSystemLike interface making using it is as simple as:

 #include "mbed.h"
 #include "QSPIFileSystem.h"

 QSPIFileSystem qspifs("qspi");
  
 int main() {
     if (!qspifs.isformatted()) {
         qspifs.format();
     }

     FILE *fp = fopen("/qspi/myfile.txt", "w");
     if (fp != NULL) {
         fwrite("Hello World!", 12, 1, fp);
         fclose(fp);
     }
 }

The file system can be formatted to a specific size in increments of 1MByte and will allways be placed at the top of the address range. For the 8 MByte memory on the LPC4088 QuickStart Board this means:

                    0x28000000                                               0x28800000
                         |------|------|------|------|------|------|------|------|
 qspifs.format(1)        |   available for program                        |  FS  |
                         |------|------|------|------|------|------|------|------|
                                                                                  
                         |------|------|------|------|------|------|------|------|
 qspifs.format(2)        |   available for program                 | FileSystem  |
                         |------|------|------|------|------|------|------|------|
                                                                                  
                         |------|------|------|------|------|------|------|------|
 qspifs.format(7)        | PROG |                 FileSystem                     |
                         |------|------|------|------|------|------|------|------|
                                                                                  
                         |------|------|------|------|------|------|------|------|
 qspifs.format(8)        |                       FileSystem                      |
                         |------|------|------|------|------|------|------|------|
 

The file system must be placed at the top of the memory because the linker scripts places your program at the bottom of the memory (if needed).

The file system is using one or more blocks (each the size of one erase block) per file. Each file is stored in a sequence of blocks. If a file is written to so that it's size will occupy more than one block and the block after is already used by a different file the entire file will be moved, like this:

                   |-------|-------|-------|-------|-------|-------|-------|
 Before            |///////| FILE1 | FILE2 | FILE3 |///////|///////|///////|
                   |-------|-------|-------|-------|-------|-------|-------|
                                                                            
 After writing     |-------|-------|-------|-------|-------|-------|-------|
 to FILE2          |///////| FILE1 |///////| FILE3 |     FILE2     |///////|
                   |-------|-------|-------|-------|-------|-------|-------|
 

Note: As each file takes up at least one block it will limit the total number of files that can be stored on the file system. The formula for this is roughly

          max_num_files = fs_size_in_bytes / erase_block_size
 

For the SPI flash on the LPC4088 QuickStart Board it means

          max_num_files = 8MByte / 4KByte = 2048
 

Some of the blocks are used to store the table of content (TOC) at the very end of the spi flash. The TOC will contain a list of all blocks on the flash (even those not used by the file system) and will mark each block as "reserved","in use" or "free". For a file system that is 4MByte on a 8MByte flash half of the blocks will be marked as "reserved".

Note: The file system will not store any date/time information.

Note: The file system will not store any file attributes (hidden/system/read only).

Note: The file system stores the absolute path of each file (path + file name) in the file's first block's first 256 bytes. Folders are never stored themselves. This has the drawback that the file system cannot hold empty folders.

Definition at line 112 of file QSPIFileSystem.h.


Constructor & Destructor Documentation

QSPIFileSystem ( const char *  name )

Create the File System for accessing a QSPI Flash.

Parameters:
nameThe name used to access the virtual filesystem

Definition at line 1281 of file QSPIFileSystem.cpp.


Member Function Documentation

int format ( unsigned int  fsSizeInMB = 8 )

Creates a new file system on the QSPI flash.

The file system will have the specified size and will always be positioned at the end of the QSPI flash. If the fsSizeInMB is less than the size of the QSPI flash the lower end of the flash will be left untouched.

Parameters:
fsSizeInMBThe size of the file system
Returns:
0 on success, -1 on failure.

Definition at line 1439 of file QSPIFileSystem.cpp.

bool getMemoryBoundaries ( uint32_t *  pStartAddr,
uint32_t *  pEndAddr 
)

Retrieves the start and end addresses for the file system.

The pStartAddr and pEndAddr will only be assigned values if the function returns true.

Parameters:
pStartAddrWill return the start of the file system area
pEndAddrWill return the end of the file system area
Returns:
True if there is a file system, False on failure.

Definition at line 1470 of file QSPIFileSystem.cpp.

bool isformatted (  )

Tests if there is a file system present on the QSPI flash.

Returns:
True if a valid file system could be found, False on failure.

Definition at line 1458 of file QSPIFileSystem.cpp.