Simple file system for application of sensoric data. Support fast append to file operation.
More...
Simple file system for application of sensoric data. Support fast append to file operation.
Type of FS: RA (Read-Append). Optimized for FLASH-like types of memories, where write/erase operation is much time consuming that reading.
Parts in simple FS:
- PREAMBLE: first 32 bytes, system information start at address 0, size: 32B
- HEADER: contains list of files, each record is 32B long Size of HEAD area: 1024B, support up to 31 files start at address 32, the begining of file table Start address: 0
- META: contains list of sensors for one file. Each record is 512B long each sensor contains of 11B: 8B for ID and 3B for meta information one meta record (one file) can contain 46 sensors (46*11B = 506B). Start address: 1024 Size of META area: 11264 B (12Kb - 1 kb header)
- DATA: Start address: 12288
Memory map
Area | Start address | Size |
PREAMBLE | 0x0 | 32B (0x20B) |
HEADER | FILE_HEADER_ADDRESS - 32 (0x20) | 32B - 704 B |
META | FILE_META_ADDRESS | 48 - 11088 B |
DATA | FILE_DATA_ADDRESS | up to memory capacity |
Used data structures
PREAMBLE
Structure: FS_Header_t
typedef struct {
uint8_t version;
uint8_t manufacturer;
uint8_t memory_type;
uint8_t memory_capacity;
uint8_t memory_id[8];
Mapping
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 - 15 | 16 | 17 | 18 | 19 - 32 |
's' | 'F' | 'S' | '1' | M | T | C | 0 | sFS_ID | CC | MF | MS | NOT_USED |
- bits 0..4: "sFS1"
- bit 3: version of sFS
- M - manufacturer code
- T - Memory type code
- C - Capacity code
- sFS_ID - 8B hardware ID
- CC - Size variant
- MF - Max files in sFS
- MS - max sensors/columns in one file.
HEADER
- start address 32
- contains records of length FILE_DESCRIPTOR_SIZE (32B). (FileDescriptor_t) Each record contains of:
- FILE_ID 1B - ID of file
- META_ADDRESS 4B - address of meta file description (list of sensors)
- DATA_ADDRESS 4B - address of file beginning
- FILE_NAME 16B - filename (ASCII)
- NUM_PARTS 1B - number parts in one record (one measure form all sensors)
- RECORD_LENGTH 2B - Length of one record in file in bytes.
- FILE_FORMAT 3B for each sensor in file. Number of these parts is NUM_PARTS. (RecordDescriptor_t) It contains of:
Mapping (FileDescriptor_t)
FILE_ID | META_ADDRESS | DATA_ADDRESS | FILE_NAME | NUM_PARTS | RECORD_LENGTH | not used |
1B | 4B | 4B | 16B | 1B | 2B | 4B |
Capacity of HEADER area:
- Single file occupied 32B in HEADER area.
Used data structure combine HEADER data and META data of file:
typedef struct {
uint8_t ID;
uint32_t meta_address;
uint32_t data_address;
uint8_t num_parts;
uint16_t record_length;
uint16_t recordAddressMap[MAXIMUM_FS_SENSORS_PER_FILE];
META
- start address: FILE_META_ADDRESS
- length: 48B - 11088B (depending on selected variant)
- Size of 1 meta block is: META_RECORD_LENGTH (48-504B)
- this block contains fixed sized block of size 12B
- SENSOR_ID maximum 8B
- SENSOR_TYPE 1B enumerate type of sensor
- SENSOR_VALUE_FORMAT 3B enumerate value format of sensor value
- Number of columns/sensors in file: META_RECORD_LENGTH/12
Mapping (RecordDescriptor_t)
SENSOR_ID | SENSOR_TYPE | VALUE_FORMAT |
8B | 1B | 3B |
Used data structure combine HEADER data and META data of file:
typedef struct {
uint8_t sensor_id[8];
VALUE_FORMAT is data structure with definition:
Mapping (RecordDescriptor_t)
DATA
- contains file content
- starting address: FILE_DATA_ADDRESS
- file contains of fixed size records (or rows). The size of single row is defined by RECORD_LENGTH
Datastructure:
typedef struct {
uint8_t *value;
uint8_t data_length;