The purpose of this application is to allow easy manipulation of the QSPI file system from a PC
Dependencies: EALib USBDevice mbed
The purpose of this application is to allow easy manipulation of the QSPI file system from a PC.
The application makes the LPC4088 QuickStart Board appear as a USB Memory Stick when connected to a PC. The PC will see the current content of the QSPI file system plus an image file of the file system that can be downloaded and (at a later time) be used to restore the file system to it's current state.
To use this application:
- Make sure that the QSPI file system has been formatted (using either the app_qspi_format application or one of the erase.* images).
- Download the app_qspifs_memstick application using drag-n-drop and then reset the board
- Optionally start a terminal program to read the status messages from the application
- Connect a USB cable to the micro USB slot on the back of the LPC4088 QuickStart Board, underneath the ethernet connector, and then to the PC
- The PC will install drivers if needed and then the USB Memory Stick will be available as a new drive
- Modify the file system to suit your needs
- With the USB cable still connected, press the button on the LPC4088 QuickStart Board
- The application will now:
- disconnect the USB Memory Stick
- write all changes to the QSPI flash memory
- create a new image file of the updated QSPI file system and store it in the .current/ folder
- connect the USB Memory Stick again
- Continue from step 6. until satisfied
Note 1: The file system that is exposed is a copy (in SDRAM) of the QSPI file system. The reason for this is that the USBMSD class requires a FAT file system.
Note 2: The image files created in step 8.3 above will be a *.fsX file (where the 'X' is the size of the file system in MB so *.fs1 for a 1MByte file system). The *.fsX file extensions are recognized by the HDK and can be used to drag-n-drop to the MBED drive in the same way as the *.bin files are. A *.fsX file will not overwrite the program stored in internal flash.
USBMSD_RAMFS.h@2:5a954ee65b33, 2014-08-26 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Aug 26 06:44:43 2014 +0000
- Revision:
- 2:5a954ee65b33
- Parent:
- 0:bd0d999bb6fb
Aligned with the updates in FATFileSystem (i.e. one more parameter in disk_read/disk_write).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:bd0d999bb6fb | 1 | #ifndef USBMSDRAMFS_H |
embeddedartists | 0:bd0d999bb6fb | 2 | #define USBMSDRAMFS_H |
embeddedartists | 0:bd0d999bb6fb | 3 | |
embeddedartists | 0:bd0d999bb6fb | 4 | #include "mbed.h" |
embeddedartists | 0:bd0d999bb6fb | 5 | #include "USBMSD.h" |
embeddedartists | 0:bd0d999bb6fb | 6 | #include "RAMFileSystem.h" |
embeddedartists | 0:bd0d999bb6fb | 7 | #include <stdint.h> |
embeddedartists | 0:bd0d999bb6fb | 8 | |
embeddedartists | 0:bd0d999bb6fb | 9 | /** |
embeddedartists | 0:bd0d999bb6fb | 10 | * USBMSD_RAMFS class: Allows the mbed board to expose a FAT file system in SDRAM as a USB memory stick |
embeddedartists | 0:bd0d999bb6fb | 11 | */ |
embeddedartists | 0:bd0d999bb6fb | 12 | class USBMSD_RAMFS : public USBMSD { |
embeddedartists | 0:bd0d999bb6fb | 13 | public: |
embeddedartists | 0:bd0d999bb6fb | 14 | |
embeddedartists | 0:bd0d999bb6fb | 15 | /** |
embeddedartists | 0:bd0d999bb6fb | 16 | * Constructor |
embeddedartists | 0:bd0d999bb6fb | 17 | * |
embeddedartists | 0:bd0d999bb6fb | 18 | * @param ramfs The RAM file system |
embeddedartists | 0:bd0d999bb6fb | 19 | * @param vendor_id Your vendor_id |
embeddedartists | 0:bd0d999bb6fb | 20 | * @param product_id Your product_id |
embeddedartists | 0:bd0d999bb6fb | 21 | * @param product_release Your preoduct_release |
embeddedartists | 0:bd0d999bb6fb | 22 | */ |
embeddedartists | 0:bd0d999bb6fb | 23 | USBMSD_RAMFS(RAMFileSystem* ramfs, uint16_t vendor_id = 0x0703, uint16_t product_id = 0x0104, uint16_t product_release = 0x0001); |
embeddedartists | 0:bd0d999bb6fb | 24 | |
embeddedartists | 0:bd0d999bb6fb | 25 | protected: |
embeddedartists | 0:bd0d999bb6fb | 26 | |
embeddedartists | 0:bd0d999bb6fb | 27 | /* |
embeddedartists | 2:5a954ee65b33 | 28 | * read one or more blocks on a storage chip |
embeddedartists | 0:bd0d999bb6fb | 29 | * |
embeddedartists | 0:bd0d999bb6fb | 30 | * @param data pointer where will be stored read data |
embeddedartists | 2:5a954ee65b33 | 31 | * @param block starting block number |
embeddedartists | 2:5a954ee65b33 | 32 | * @param count number of blocks to read |
embeddedartists | 0:bd0d999bb6fb | 33 | * @returns 0 if successful |
embeddedartists | 0:bd0d999bb6fb | 34 | */ |
embeddedartists | 2:5a954ee65b33 | 35 | virtual int disk_read(uint8_t* data, uint64_t block, uint8_t count); |
embeddedartists | 0:bd0d999bb6fb | 36 | |
embeddedartists | 0:bd0d999bb6fb | 37 | /* |
embeddedartists | 2:5a954ee65b33 | 38 | * write one or more blocks on a storage chip |
embeddedartists | 0:bd0d999bb6fb | 39 | * |
embeddedartists | 0:bd0d999bb6fb | 40 | * @param data data to write |
embeddedartists | 2:5a954ee65b33 | 41 | * @param block starting block number |
embeddedartists | 2:5a954ee65b33 | 42 | * @param count number of blocks to write |
embeddedartists | 0:bd0d999bb6fb | 43 | * @returns 0 if successful |
embeddedartists | 0:bd0d999bb6fb | 44 | */ |
embeddedartists | 2:5a954ee65b33 | 45 | virtual int disk_write(const uint8_t* data, uint64_t block, uint8_t count); |
embeddedartists | 0:bd0d999bb6fb | 46 | |
embeddedartists | 0:bd0d999bb6fb | 47 | /* |
embeddedartists | 0:bd0d999bb6fb | 48 | * Disk initilization |
embeddedartists | 0:bd0d999bb6fb | 49 | */ |
embeddedartists | 0:bd0d999bb6fb | 50 | virtual int disk_initialize(); |
embeddedartists | 0:bd0d999bb6fb | 51 | |
embeddedartists | 0:bd0d999bb6fb | 52 | /* |
embeddedartists | 0:bd0d999bb6fb | 53 | * Return the number of blocks |
embeddedartists | 0:bd0d999bb6fb | 54 | * |
embeddedartists | 0:bd0d999bb6fb | 55 | * @returns number of blocks |
embeddedartists | 0:bd0d999bb6fb | 56 | */ |
embeddedartists | 0:bd0d999bb6fb | 57 | virtual uint64_t disk_sectors(); |
embeddedartists | 0:bd0d999bb6fb | 58 | |
embeddedartists | 0:bd0d999bb6fb | 59 | /* |
embeddedartists | 0:bd0d999bb6fb | 60 | * Return memory size |
embeddedartists | 0:bd0d999bb6fb | 61 | * |
embeddedartists | 0:bd0d999bb6fb | 62 | * @returns memory size |
embeddedartists | 0:bd0d999bb6fb | 63 | */ |
embeddedartists | 0:bd0d999bb6fb | 64 | virtual uint64_t disk_size(); |
embeddedartists | 0:bd0d999bb6fb | 65 | |
embeddedartists | 0:bd0d999bb6fb | 66 | |
embeddedartists | 0:bd0d999bb6fb | 67 | /* |
embeddedartists | 0:bd0d999bb6fb | 68 | * To check the status of the storage chip |
embeddedartists | 0:bd0d999bb6fb | 69 | * |
embeddedartists | 0:bd0d999bb6fb | 70 | * @returns status: 0: OK, 1: disk not initialized, 2: no medium in the drive, 4: write protected |
embeddedartists | 0:bd0d999bb6fb | 71 | */ |
embeddedartists | 0:bd0d999bb6fb | 72 | virtual int disk_status(); |
embeddedartists | 0:bd0d999bb6fb | 73 | |
embeddedartists | 0:bd0d999bb6fb | 74 | protected: |
embeddedartists | 0:bd0d999bb6fb | 75 | |
embeddedartists | 0:bd0d999bb6fb | 76 | RAMFileSystem* ramfs; |
embeddedartists | 0:bd0d999bb6fb | 77 | }; |
embeddedartists | 0:bd0d999bb6fb | 78 | |
embeddedartists | 0:bd0d999bb6fb | 79 | #endif |
embeddedartists | 0:bd0d999bb6fb | 80 |