simple FS  v0.1.0
Simple File System

Simple File System (sFS) is very simple file system for for embedded devices. Support fast append to file operation. The type of FS is RA (Read-Append). It is optimized for FLASH-like types of memories, where write/erase operation is much time consuming that reading. Primary use of sFS is store data from connected sensors to external memory.

Properties of sFS:

  • sFS is Read-Append oriented file system
  • does not support extended info as file owner, protected access, file rights, ...
  • Configurable for small (in kB) and large (in MB) memory capacity - it is possible to shring overhead, by reducing max. count of files and size of single file record (row).

Predefined variants

Simple File system predefine 4 variants of configurations. The configuration is tetermined only by "Files" and "Column per file" values. Other value depend on these basic setting.

HEADER HEADER HEADER META META META DATA
Variant Files Column per file ADDRESS RECORD_LENGTH SIZE ADDRESS RECORD_LENGH SIZE ADDRESS
Ultra small U 1 4 32 32 32 64 48 48 112
eXtra small X 2 8 32 32 64 96 96 192 288
Small S 8 16 32 32 256 288 192 1536 1824
Large L 22 42 32 32 704 736 504 11088 11824

Properties of files in sFS:

  • binary format,
  • CSV-like format: data are always stored in rows. Each row contains of set of columns, or data from external sensors,
  • each file has limitted count of columns, depending on memory capacity,
  • files is FS is self-descripted; there is stored also information how to interpret that file,
  • only to last file if sFS can be append data; other files are locked (can't be extended))
  • file name is automatically generated (depending on HW ID of used memory),

Supporting platforms:

  • STM32
  • ESP32 (in future)
  • native C app (in simulation mode)

Supported memories:

  • SPI-like: FLASH memory. Winbond W32 with high capacity
  • 1-wire: EEPROM memory. E.g. Maxim integrated DS28EC20 with maximum 20kB of capacity
  • RAM memory - as a dektop application (in SIMULATION mode)

Each class of memories has own limitations:

  • normal size (FLASH): 1 - 16MB.
  • limited size (EEPROM): 1 - 1024 kB

Technical documentation

SIMPLE_FS

sFS Memory map

Memory map for sfS v.1
  • MAC - Manufacturer
  • MT - Memory Type
  • CAP - Capacity code
  • CC - Size variant
  • MF - Max files
  • MS - Max. sensors per file
  • NP - Number of parts (column) in file
  • RL - Record length (length of one record in file [B])

Examples of use

Create instance of simpleFS

#include "sensor_FS.h"
//....
// create drives for physical sensors
SensorInterface_t *driverTime = &timeSensor;
// init drivers
driverADC->Init(NULL, DUMMY_VALUE);
//init FS in SIMULATION mode
init_FS(NULL, NULL, 0);
/* init FS on STM32 application, use SPI FLASH memory */
/* FS_init(&hspi1, SPI1_CS_GPIO_Port, SPI1_CS_Pin); */
// add sensors to opened file.
uint8_t sensor_index = 0;
file_add_sensor(sensor_index++, 0, driverTime);
file_add_sensor(sensor_index++, 0, driverADC);

Fill file with data

if (FS) {
for (uint8_t p = 0; p < file_get_num_parts(FS); p++) {
if (sd != NULL) {
sv = sd->getValue(); // read value from sensor
int len = get_sensor_data_length(FS->file.format[p].value_format.meta_length);
file_store_data(FS, p, sv); // add value to file
}
}
//write values to file
}

Versions

[24.6.2021] v0.1.0, FW version: sFS

  • first version,
  • works with SPI FLASH memory
  • data drivers:
    • one-wire DS18B20,
    • internal MCU peripherals: RTC clock, ADC converter
    • primitive data types

Author

Juraj Dudak

file_get_num_parts
uint8_t file_get_num_parts(SimpleFS_t *fileP)
Return number parts of opened file.
Definition: sensor_FS.c:249
DUMMY_VALUE
#define DUMMY_VALUE
Dummy/empty value.
Definition: file_format.h:73
sensor_FS.h
Simple file system for application of sensoric and primitive data types .
FS_open_last_file
SimpleFS_t * FS_open_last_file(void)
Open last file on sensorFS.
Definition: sensor_FS.c:226
SimpleFS_t::file
FileDescriptor_t file
Detailed information about open file: FileDescriptor_t.
Definition: file_format.h:273
FS_commit_file_header
FS_state FS_commit_file_header(void)
Finish write information about created file.
Definition: sensor_FS.c:204
RecordDescriptor_t
Describes internal structure of file.
Definition: file_format.h:228
SensorInterface_t
The interface, that defines list of functions, tha have to be implemented for each type of value (or ...
Definition: sensor.h:66
SensorValue_t
Sensor value is stored as array of bytes.
Definition: sensor.h:42
FS_sensor_driver
SensorInterface_t * FS_sensor_driver(uint8_t sensor_part)
Return driver for attached sensor.
Definition: sensor_FS.c:287
SimpleFS_t
Base structure for sFS.
Definition: file_format.h:271
file_data_row_commit
void file_data_row_commit(SimpleFS_t *fs)
Write prepared measured values (by file_store_data} function) to FLASH.
Definition: sensor_FS.c:347
SensorInterface_t::getValue
SensorValue_t *(* getValue)(void)
Read prepared value from sensor.
Definition: sensor.h:104
file_column_format
RecordDescriptor_t file_column_format(SimpleFS_t *fileP, uint8_t index_part)
Return format of i-th sensor inf datafile.
Definition: sensor_FS.c:259
RecordDescriptor_t::sensor_type
SensorType_t sensor_type
Type of stored value.
Definition: file_format.h:232
file_add_sensor
FS_state file_add_sensor(uint8_t index, uint8_t index_in_driver, SensorInterface_t *sensor)
Add new sensor to created file.
Definition: sensor_FS.c:180
file_data_row_begin
uint32_t file_data_row_begin(SimpleFS_t *fs)
Initialize internal data structures for new data record.
Definition: sensor_FS.c:321
SensorInterface_t::Init
void(* Init)(void *hw1, uint16_t hw2)
Initialization of sensor.
Definition: sensor.h:73
RecordDescriptor_t::value_format
RecordTypeValue_t value_format
This information contain every sensor in his driver file.
Definition: file_format.h:234
adcSensor
SensorInterface_t adcSensor
Interface to ADC sensor.
Definition: module_adc.c:38
FS_write_preamble
FS_state FS_write_preamble(void)
Write preamble aprt in sensorFS, if not exists.
Definition: sensor_FS.c:384
FS_create_file
uint8_t FS_create_file()
Begin file creation procedure.
Definition: sensor_FS.c:114
FileDescriptor_t::format
RecordDescriptor_t format[MAXIMUM_FS_SENSORS_PER_FILE]
Format specification for each column in file.
Definition: file_format.h:258
FORMAT_META_FMT_SPECIAL_TIME
@ FORMAT_META_FMT_SPECIAL_TIME
Format as time (binary coded)
Definition: file_format.h:166
file_store_data
FS_state file_store_data(SimpleFS_t *fs, uint8_t index, SensorValue_t *value)
Prepare measured value to file buffer.
Definition: sensor_FS.c:337
get_sensor_data_length
uint8_t get_sensor_data_length(ValueFormatMetaLength_t length_code)
Compute real data length (in bytes) from code length.
Definition: sensor.c:20