Example showing how to create a file system on the QSPI flash.
The app_qspi_memstick application cannot create a QSPI file system - it can only modify an existing one. This application will create a file system for you. Modify the application by changing DESIRED_SIZE_IN_MB to get the desired size of the file system, compile it, download and run to format the QSPI FLASH.
main.cpp@2:03417cea6ccc, 2014-08-26 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Aug 26 06:47:52 2014 +0000
- Revision:
- 2:03417cea6ccc
- Parent:
- 0:52d05cabc12f
Updated to latest version of EALib and mbed.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:52d05cabc12f | 1 | |
embeddedartists | 0:52d05cabc12f | 2 | /****************************************************************************** |
embeddedartists | 0:52d05cabc12f | 3 | * Includes |
embeddedartists | 0:52d05cabc12f | 4 | *****************************************************************************/ |
embeddedartists | 0:52d05cabc12f | 5 | |
embeddedartists | 0:52d05cabc12f | 6 | #include "mbed.h" |
embeddedartists | 0:52d05cabc12f | 7 | |
embeddedartists | 0:52d05cabc12f | 8 | #include "QSPIFileSystem.h" |
embeddedartists | 0:52d05cabc12f | 9 | |
embeddedartists | 0:52d05cabc12f | 10 | /****************************************************************************** |
embeddedartists | 0:52d05cabc12f | 11 | * Typedefs and defines |
embeddedartists | 0:52d05cabc12f | 12 | *****************************************************************************/ |
embeddedartists | 0:52d05cabc12f | 13 | |
embeddedartists | 0:52d05cabc12f | 14 | #define DESIRED_SIZE_IN_MB (8) |
embeddedartists | 0:52d05cabc12f | 15 | |
embeddedartists | 0:52d05cabc12f | 16 | /****************************************************************************** |
embeddedartists | 0:52d05cabc12f | 17 | * Local variables |
embeddedartists | 0:52d05cabc12f | 18 | *****************************************************************************/ |
embeddedartists | 0:52d05cabc12f | 19 | |
embeddedartists | 0:52d05cabc12f | 20 | QSPIFileSystem qspifs("qspi"); |
embeddedartists | 0:52d05cabc12f | 21 | |
embeddedartists | 0:52d05cabc12f | 22 | /****************************************************************************** |
embeddedartists | 0:52d05cabc12f | 23 | * Local functions |
embeddedartists | 0:52d05cabc12f | 24 | *****************************************************************************/ |
embeddedartists | 0:52d05cabc12f | 25 | |
embeddedartists | 0:52d05cabc12f | 26 | /****************************************************************************** |
embeddedartists | 0:52d05cabc12f | 27 | * Main function |
embeddedartists | 0:52d05cabc12f | 28 | *****************************************************************************/ |
embeddedartists | 0:52d05cabc12f | 29 | |
embeddedartists | 0:52d05cabc12f | 30 | int main() { |
embeddedartists | 0:52d05cabc12f | 31 | |
embeddedartists | 0:52d05cabc12f | 32 | printf("\nQSPI FS formatter\n"); |
embeddedartists | 0:52d05cabc12f | 33 | printf("Will format QSPI as %d MB file system\n", DESIRED_SIZE_IN_MB); |
embeddedartists | 0:52d05cabc12f | 34 | |
embeddedartists | 0:52d05cabc12f | 35 | int err = qspifs.format(DESIRED_SIZE_IN_MB); |
embeddedartists | 0:52d05cabc12f | 36 | if (err == 0) { |
embeddedartists | 0:52d05cabc12f | 37 | printf("Successfully formatted!\n"); |
embeddedartists | 0:52d05cabc12f | 38 | } else { |
embeddedartists | 0:52d05cabc12f | 39 | printf("Failed to format. Got error %d\n", err); |
embeddedartists | 0:52d05cabc12f | 40 | } |
embeddedartists | 0:52d05cabc12f | 41 | } |