pC/SFS



In very small devices, there is often not even the possibility to add a normal (parallel) NVM memory to store various data and information.    A very small file system for serial NVM storage devices would be the right solution.    Running FAT-FileSystems on these very small memory is possible, but it can cost a lot of code- and RAM-memory.

   The (small) Serial-File-System presented here is based on simple concatenated blocks whose elements (DIR / FILE) are referenced by a 32bit hash of their name and where the number of max. entries per directory must be defined.    By using a 32bit hash as a name, the file system can be massively simplified, but there are therefore no references to the names of the entries. The hash of each entry must be unique within its directory.    Since a 32bit hash value can not be guaranteed to be unique in itself - that is, if two names have the same hash value - several 32bit hash algorithms are usable, but the selection must be set at compile time.
This file-system handles all names of directories/files as hash over a STRING, so special characters can be used in the names.

reserved names-elements:

.. - one directory back
/  - on the beginning of the Path: for from ROOT
./ - on the beginning of the Path: for from current DIR (optional)
/  - in middle of the Path: as separation for directory/file-names

The whole file-system works case-sensitive !
Various serial NVM memory devices (SPI & I2C) are tested as hardware (MRAM, FRAM, ReRAM, EEPROM). Additional the file system can run too on parallel memory like RAM, FRAM, MRAM or EEPROM. Ideal are all types that support byte-wise writing by internal buffering of sectors/pages, but this can also be done by the low-level hardware driver.
The use of serial flash memory was not provided due to the sector size of ≥ 64kB, the necessary buffering of such an update, as well as the long programming time of an entire page.
When using EEPROM, it is important to remember that 1.000.000 cycles are already quite a lot, but this also indicates a finite lifetime,
In addition, the SerialFileSystem do not respect hot spots (high-update files) or transactions.


memory consumption of the pC/SFS V1.14b:

ROM: approximately 8 kBytes on a 32bit CPU
RAM: approximately 124 bytes global + 42..64 bytes per user + 32 bytes * SFS_HANDLES
         plus approximately 180 bytes stack


tested NVM memory:

MRAM

Everspin MR25H40                                            

FRAM

Ramtron FM25H20, Ramtron FM24V10, Cypress CY15B104Q, Fujitsu MB85RS1MT, Fujitsu MB85RC256, ...

ReRAM

Fujitsu MB85AS4MT

nvRAM

Cypress CY14B101Q2

EEPROM

Microchip 25AA1024, Microchip 25AA1024, Atmel AT25M01, Atmel AT25256, Atmel AT24CM02, STM M95M01, STM M24M02, STM M95512, ONsemi CAT25M01, ONsemi CAT24M01, ...

running on hosts like: ARC-EM, ARMv8-M, FE310, GD32VF103, STM32F1xx, STM32F4xx, SAM3Sxx, SAMD21xx, SAMD51xx, SAML10, SAML11 ... plus Win32 & Linux



But no mechanisms of the File-sharing are deposited. So a file can be opened simultaneously from many users to reading but only from one user to writing.
As file attributes Write-Only and Read-Only are available.

pCSFS_114b.zip
download pC/SFS 1.14b (as ZIP)


Releases:

0.80a

first alpa-Release

0.81a

code for create & delete link can be disabled

0.90a

handling of file attributes completed and code uses found config values from file system if compatible to base settings

0.95b

internal function SFSChange_Entry() harmonised and the use of it readjusted

0.96a

SFS_GetEntry() added, but only the hash of the name can be returned instead the name itself - and optional LOCK/UNLOCK added in LLdriver to protect serial communication against timeouts

1.01b

parallel memory and I2C memory support added, rename of LL-driver files to split between SPI, I2C and parallel memory

1.02a

correction in internal SFSChange_Entry() for incorrect SFS_ChangeDir("/") handling

1.10c

correction in internal SFSMem_Alloc() & SFSCreate_Entry() on creation of a DIR

1.12b

optional extension SFS_RemoveDirTree() added and link handling corrected

1.13a

feature switch SFS_AUTO_CLOSE added

1.14b

feature switch SFS_DEEP_FORMAT added and SFS_PATHNAME central for all strings added, internal functions as static as far as possible



Services of the pC/SFS version 1.14b (abbreviation)
This here presented function overview only serves as short overview.
For detailed information, you please look in Reference-Manual about pC/SFS.


SFS-Control:

Description

SFS_Init

Initialization of the File-System

SFS_GetRev

It returns a pointer on SFS revision

SFS_Flush

saves the SFS as image into a Windows/Linux file

SFS_Format

Format the drive



User:

Description

SFS_BecomeUser

As User announce

SFS_CloseUser

As User cancel



Directories:

Description

SFS_CreateDir

Create a directory

SFS_RemoveDir

Remove a directory

SFS_RemoveDirTree

Remove a directory and all his sub-elements

SFS_RenameDir

Rename a directory

SFS_ChangeDir

Change current path

SFS_ChangeDirTemp

Change current path temorary

SFS_BackDirTemp

returns from temporary path



Files:

Description

SFS_CreateFile

Create a file

SFS_RemoveFile

Remove a file

SFS_RenameFile

Rename a file

SFS_AttribFile

Change the attributes of a file

SFS_GetFileAttrib

It returns the attributes of a file

SFS_GetFileSize

It returns the current size of a file

SFS_GetMaxFileSize

It returns the max size of a file

SFS_OpenFile

Open a file in "mode"

SFS_CloseFile

Close the opened file

SFS_SeekFile

Place the pointer in opened file absolutely

SFS_TellFile

It returns the pointer in opened file

SFS_SetEOF

Set EndOfFile in opened file to actual R/W-pointer

SFS_ReadFile

Read data from opened file

SFS_WriteFile

Write data into opened file

SFS_GetErrNo

read the error-code from Open, Read, Write ...



Links:

Description

SFS_CreateLink

Create a Link to a directory or file

SFS_RemoveLink

Remove a Link



Entries:

Description

SFS_GetEntry

It returns all infos of the given entry (dir/file/link) into a struct



Error-Codes:

Name

Decimal_Value

SFS_NO_ERR

0

SFS_USR_OVF

200

SFS_DBL_USER

201

SFS_NO_USER

202

SFS_NAME_EXIST

210

SFS_NOT_EXIST

211

SFS_PATH_ERR

212

SFS_TMP_DIR

213

SFS_NO_FILE

214

SFS_FILE_RO

215

SFS_FILE_WO

216

SFS_FILE_EOF

217

SFS_NOT_EMPTY

218

SFS_FILE_OPEN

219

SFS_NO_DATA

220

SFS_WRONG_PTR

221

SFS_NO_ENTRY

222

SFS_WRONG_A

223

SFS_LINKED

230

SFS_MAX_LINK

231

SFS_LINK_ERR

232

SFS_NO_LINK

233

SFS_MEM_ERR

240

SFS_MEM_OVF

241

SFS_FORMAT_ERR

250

SFS_PORT_ERR

251