FLASH File System This file system can mount, read, and enumerate a file system image from Flash memory.
Fork of FlashFileSystem by
A filesystem for accessing a read-only file system placed in the internal FLASH memory of the mbed board.
The file system to be mounted by this file system should be created through the use of the fsbld utility on the PC.
This fsbld.zip archive contains the sources for that utility.
As fsbld creates two output files (a binary and a header file), there are two ways to add the resulting file system image:
- Concatenate the binary file system to the end of the .bin file created by the mbed online compiler before uploading to the mbed device.
On *nix this can be done with the cat command.
For example:cat Test_LPC1768.bin FileImage.bin >/Volumes/MBED/test.bin
On Windows this can be done with the copy command.
For example:copy /b Test_LPC1768.bin + FileImage.bin e:\test.bin
- Import the header file into your project, include this file in your main file and add 'roFlashDrive' to the FlashfileSystem constructor call.
eg :static FlashFileSystem flash("flash", roFlashDrive);
A third (optional) parameter in the FlashfileSystem constructor call allows you to specify the size of the FLASH (KB) on the device (default = 512). eg (for a KL25Z device) : static FlashFileSystem flash("flash", NULL, 128);
Note that in this example, the pointer to the header file has been omitted, so we need to append the binary file system ourselves (see above). When you include the binary file system header in your main file, you can also use the roFlashDrive pointer.
eg (for a KL25Z device) : static FlashFileSystem flash("flash", roFlashDrive, 128);
NOTE
This file system is case-sensitive.
Calling fopen("/flash/INDEX.html") won't successfully open a file named index.html in the root directory of the flash file system.
ffsformat.h@0:5ea6e74c35f7, 2011-07-29 (annotated)
- Committer:
- AdamGreen
- Date:
- Fri Jul 29 01:23:53 2011 +0000
- Revision:
- 0:5ea6e74c35f7
- Child:
- 1:a3cb118c4f6e
Initial version of FLASH File System
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:5ea6e74c35f7 | 1 | /* |
AdamGreen | 0:5ea6e74c35f7 | 2 | Copyright (c) 2011 Adam Green http://mbed.org/users/AdamGreen/ |
AdamGreen | 0:5ea6e74c35f7 | 3 | |
AdamGreen | 0:5ea6e74c35f7 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
AdamGreen | 0:5ea6e74c35f7 | 5 | of this software and associated documentation files (the "Software"), to deal |
AdamGreen | 0:5ea6e74c35f7 | 6 | in the Software without restriction, including without limitation the rights |
AdamGreen | 0:5ea6e74c35f7 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
AdamGreen | 0:5ea6e74c35f7 | 8 | copies of the Software, and to permit persons to whom the Software is |
AdamGreen | 0:5ea6e74c35f7 | 9 | furnished to do so, subject to the following conditions: |
AdamGreen | 0:5ea6e74c35f7 | 10 | |
AdamGreen | 0:5ea6e74c35f7 | 11 | The above copyright notice and this permission notice shall be included in |
AdamGreen | 0:5ea6e74c35f7 | 12 | all copies or substantial portions of the Software. |
AdamGreen | 0:5ea6e74c35f7 | 13 | |
AdamGreen | 0:5ea6e74c35f7 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
AdamGreen | 0:5ea6e74c35f7 | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
AdamGreen | 0:5ea6e74c35f7 | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
AdamGreen | 0:5ea6e74c35f7 | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
AdamGreen | 0:5ea6e74c35f7 | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
AdamGreen | 0:5ea6e74c35f7 | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
AdamGreen | 0:5ea6e74c35f7 | 20 | THE SOFTWARE. |
AdamGreen | 0:5ea6e74c35f7 | 21 | */ |
AdamGreen | 0:5ea6e74c35f7 | 22 | /* Specifies constants and structures used within the FLASH File System. The |
AdamGreen | 0:5ea6e74c35f7 | 23 | header is used by both the runtime and the tool which builds the image on |
AdamGreen | 0:5ea6e74c35f7 | 24 | the PC. |
AdamGreen | 0:5ea6e74c35f7 | 25 | */ |
AdamGreen | 0:5ea6e74c35f7 | 26 | #ifndef _FFSFORMAT_H_ |
AdamGreen | 0:5ea6e74c35f7 | 27 | #define _FFSFORMAT_H_ |
AdamGreen | 0:5ea6e74c35f7 | 28 | |
AdamGreen | 0:5ea6e74c35f7 | 29 | |
AdamGreen | 0:5ea6e74c35f7 | 30 | /* The signature to be placed in SFileSystemHeader::FileSystemSignature. |
AdamGreen | 0:5ea6e74c35f7 | 31 | Only the first 8 bytes are used and the NULL terminator discarded. */ |
AdamGreen | 0:5ea6e74c35f7 | 32 | #define FILE_SYSTEM_SIGNATURE "FFileSys" |
AdamGreen | 0:5ea6e74c35f7 | 33 | |
AdamGreen | 0:5ea6e74c35f7 | 34 | /* The size of the FLASH on the device to search through for the file |
AdamGreen | 0:5ea6e74c35f7 | 35 | system signature. */ |
AdamGreen | 0:5ea6e74c35f7 | 36 | #define FILE_SYSTEM_FLASH_SIZE (512 * 1024) |
AdamGreen | 0:5ea6e74c35f7 | 37 | |
AdamGreen | 0:5ea6e74c35f7 | 38 | |
AdamGreen | 0:5ea6e74c35f7 | 39 | /* Header stored at the beginning of the file system image. */ |
AdamGreen | 0:5ea6e74c35f7 | 40 | typedef struct _SFileSystemHeader |
AdamGreen | 0:5ea6e74c35f7 | 41 | { |
AdamGreen | 0:5ea6e74c35f7 | 42 | /* Signature should be set to FILE_SYSTEM_SIGNATURE. */ |
AdamGreen | 0:5ea6e74c35f7 | 43 | char FileSystemSignature[8]; |
AdamGreen | 0:5ea6e74c35f7 | 44 | /* Number of entries in this file system image. */ |
AdamGreen | 0:5ea6e74c35f7 | 45 | unsigned int FileCount; |
AdamGreen | 0:5ea6e74c35f7 | 46 | /* The SFileSystemEntry[SFileSystemHeader::FileCount] array will start here. |
AdamGreen | 0:5ea6e74c35f7 | 47 | These entries are to be sorted so that a binary search can be performed |
AdamGreen | 0:5ea6e74c35f7 | 48 | at file open time. */ |
AdamGreen | 0:5ea6e74c35f7 | 49 | } SFileSystemHeader; |
AdamGreen | 0:5ea6e74c35f7 | 50 | |
AdamGreen | 0:5ea6e74c35f7 | 51 | /* Information about each file added to the file system image. */ |
AdamGreen | 0:5ea6e74c35f7 | 52 | typedef struct _SFileSystemEntry |
AdamGreen | 0:5ea6e74c35f7 | 53 | { |
AdamGreen | 0:5ea6e74c35f7 | 54 | /* The 2 following offsets are relative to the beginning of the file |
AdamGreen | 0:5ea6e74c35f7 | 55 | image. */ |
AdamGreen | 0:5ea6e74c35f7 | 56 | unsigned int FilenameOffset; |
AdamGreen | 0:5ea6e74c35f7 | 57 | unsigned int FileBinaryOffset; |
AdamGreen | 0:5ea6e74c35f7 | 58 | unsigned int FileBinarySize; |
AdamGreen | 0:5ea6e74c35f7 | 59 | } SFileSystemEntry; |
AdamGreen | 0:5ea6e74c35f7 | 60 | |
AdamGreen | 0:5ea6e74c35f7 | 61 | |
AdamGreen | 0:5ea6e74c35f7 | 62 | #endif /* _FFSFORMAT_H_ */ |