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@2:ca35ecd2fae6, 2015-04-05 (annotated)
- Committer:
- frankvnk
- Date:
- Sun Apr 05 10:04:44 2015 +0000
- Revision:
- 2:ca35ecd2fae6
- Parent:
- 1:a3cb118c4f6e
2 options added: The ability to include a header file containing the binary file system image built with fsbld and the ability to set the system flash size.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 1:a3cb118c4f6e | 1 | /* Copyright 2011 Adam Green (http://mbed.org/users/AdamGreen/) |
AdamGreen | 1:a3cb118c4f6e | 2 | |
AdamGreen | 1:a3cb118c4f6e | 3 | Licensed under the Apache License, Version 2.0 (the "License"); |
AdamGreen | 1:a3cb118c4f6e | 4 | you may not use this file except in compliance with the License. |
AdamGreen | 1:a3cb118c4f6e | 5 | You may obtain a copy of the License at |
AdamGreen | 1:a3cb118c4f6e | 6 | |
AdamGreen | 1:a3cb118c4f6e | 7 | http://www.apache.org/licenses/LICENSE-2.0 |
AdamGreen | 1:a3cb118c4f6e | 8 | |
AdamGreen | 1:a3cb118c4f6e | 9 | Unless required by applicable law or agreed to in writing, software |
AdamGreen | 1:a3cb118c4f6e | 10 | distributed under the License is distributed on an "AS IS" BASIS, |
AdamGreen | 1:a3cb118c4f6e | 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
AdamGreen | 1:a3cb118c4f6e | 12 | See the License for the specific language governing permissions and |
AdamGreen | 1:a3cb118c4f6e | 13 | limitations under the License. |
AdamGreen | 0:5ea6e74c35f7 | 14 | */ |
AdamGreen | 0:5ea6e74c35f7 | 15 | /* Specifies constants and structures used within the FLASH File System. The |
AdamGreen | 0:5ea6e74c35f7 | 16 | header is used by both the runtime and the tool which builds the image on |
AdamGreen | 0:5ea6e74c35f7 | 17 | the PC. |
AdamGreen | 0:5ea6e74c35f7 | 18 | */ |
AdamGreen | 0:5ea6e74c35f7 | 19 | #ifndef _FFSFORMAT_H_ |
AdamGreen | 0:5ea6e74c35f7 | 20 | #define _FFSFORMAT_H_ |
AdamGreen | 0:5ea6e74c35f7 | 21 | |
AdamGreen | 0:5ea6e74c35f7 | 22 | |
AdamGreen | 0:5ea6e74c35f7 | 23 | /* The signature to be placed in SFileSystemHeader::FileSystemSignature. |
AdamGreen | 0:5ea6e74c35f7 | 24 | Only the first 8 bytes are used and the NULL terminator discarded. */ |
AdamGreen | 0:5ea6e74c35f7 | 25 | #define FILE_SYSTEM_SIGNATURE "FFileSys" |
AdamGreen | 0:5ea6e74c35f7 | 26 | |
AdamGreen | 0:5ea6e74c35f7 | 27 | /* Header stored at the beginning of the file system image. */ |
AdamGreen | 0:5ea6e74c35f7 | 28 | typedef struct _SFileSystemHeader |
AdamGreen | 0:5ea6e74c35f7 | 29 | { |
AdamGreen | 0:5ea6e74c35f7 | 30 | /* Signature should be set to FILE_SYSTEM_SIGNATURE. */ |
AdamGreen | 0:5ea6e74c35f7 | 31 | char FileSystemSignature[8]; |
AdamGreen | 0:5ea6e74c35f7 | 32 | /* Number of entries in this file system image. */ |
AdamGreen | 0:5ea6e74c35f7 | 33 | unsigned int FileCount; |
AdamGreen | 0:5ea6e74c35f7 | 34 | /* The SFileSystemEntry[SFileSystemHeader::FileCount] array will start here. |
AdamGreen | 0:5ea6e74c35f7 | 35 | These entries are to be sorted so that a binary search can be performed |
AdamGreen | 0:5ea6e74c35f7 | 36 | at file open time. */ |
AdamGreen | 0:5ea6e74c35f7 | 37 | } SFileSystemHeader; |
AdamGreen | 0:5ea6e74c35f7 | 38 | |
AdamGreen | 0:5ea6e74c35f7 | 39 | /* Information about each file added to the file system image. */ |
AdamGreen | 0:5ea6e74c35f7 | 40 | typedef struct _SFileSystemEntry |
AdamGreen | 0:5ea6e74c35f7 | 41 | { |
AdamGreen | 0:5ea6e74c35f7 | 42 | /* The 2 following offsets are relative to the beginning of the file |
AdamGreen | 0:5ea6e74c35f7 | 43 | image. */ |
AdamGreen | 0:5ea6e74c35f7 | 44 | unsigned int FilenameOffset; |
AdamGreen | 0:5ea6e74c35f7 | 45 | unsigned int FileBinaryOffset; |
AdamGreen | 0:5ea6e74c35f7 | 46 | unsigned int FileBinarySize; |
AdamGreen | 0:5ea6e74c35f7 | 47 | } SFileSystemEntry; |
AdamGreen | 0:5ea6e74c35f7 | 48 | |
AdamGreen | 0:5ea6e74c35f7 | 49 | |
AdamGreen | 0:5ea6e74c35f7 | 50 | #endif /* _FFSFORMAT_H_ */ |