Advice on using file systems

File system (acronym FS) refers to the mechanism by which files are located and organized on devices used for data storage. Our systems SlimLine based on ARM processors /Cortex by default they have a FLASH memory storage device organized as a disk “C:” accessible in read / write. According to the module model, it is possible to add additional SDCard storage devices to be inserted directly into the system as described above this CPU module identified as a disk “D:” or on USB adapter for other CPU modules identified as disk “F:”.

File system structure

The storage device is managed by sectors, each sector of the devices we use has a size of 512 bytes, the file system manages the disk with a FAT 32 structure, this is how the data on the disk is organized.

FAT representation
  • Boot sector: First sector of the device contains information about the drive and the implemented file system.
  • File Allocation Table (FAT): Array of sectors in which all the cluster concatenations necessary to rebuild the files are recorded.
  • Data region: Array of sectors divided into clusters that contain the data of the directories or files.
Using removable disks to transfer data from / to PC

Here are the rules to follow to use a removable disk (SDCard or PenDrive) on both a system SlimLine than on a PC. This can be useful for transferring data between the two systems.

  • Removable disks (SDCard or PenDrive) can only be operated with the system off.
  • Before turning off the system, you must be sure that all files are closed, therefore you must not have active FTP operations and the writing operations from the LogicLab program must have ended with the execution of the function Sysfclose. The systems file system SlimLine to safeguard data loss, it provides a transaction in the FRAM memory, in case of shutdown during access, the transaction will be automatically restored at the next power-up, but if the disk is replaced, the system will update the new one, making it dirty
  • The disk must be formatted FAT_32 using only names in 8 + 3 uppercase format for files and directories and the names can have only one "." inside them. If you format FAT_32_ELS and SlimLine you create uppercase or lowercase files in the 8 + 3 style, the PC CANNOT log in. If you create a file from a PC, regardless of whether it is a fully mapped name and in the 8 + 3 style, SlimLine CANNOT log in.

I use long names

How come while formatting as FAT_32 which allows long names in uppercase or lowercase, lo SlimLine does not allow it?

  • The long names in uppercase and lowercase are stored on multiple entries of the FAT and this could lead to a problem in the management of a possible power failure while working on these files.
  • The filenames are in UNICODE, the signing of the SlimLine does not support it.

Disc life

The disc C: internal uses a NOR Flash memory with a minimum data retention of 20 years, each sector (512 Bytes) has a minimum number of 100.000 writing cycles. When used as a disk, it is necessary to keep in mind the number of writes on each sector to avoid destroying the memory.

The PCK051C000 and PCK054B000 versions have been implemented Wear leveling, wear leveling, which distributes data evenly across all sectors of the disk.

  • The operating system upgrade does not activate wear leveling while maintaining disk accessibility. To enable it save the files on the disk and format the disk with the command Format C: then copy the previously saved files.
  • When downgrading, if the disk is formatted with wear leveling, save the files on the disk and format the disk with the command Format C: FAT_32_ELS. Then downgrade and copy the previously saved files.
Disk life calculation

To calculate the life of a disk sector, follow the formula: Life Time (h)=Write time (s)*27.78

Assuming we always write the same sector every minute we will have: 60*27.78=1666 (H) (69 days). In reality on the disk we operate with files that occupy multiple sectors, so if we wrote every minute in a 50KBytes file the life time in days would be: 69*(50000/512)=6738 days (18 years).

The above times refer to the writing of the Data region of the disk, but on the creation of the file and on every variation of its size it is also written in the FAT. Therefore, to minimize writing, it is best to create the file of the size necessary to contain the data and then operate with commands Sysfseek to move inside it without changing its size.

Disk format

The internal disk “C:” it is supplied already formatted and usually does not have to be formatted by the user, inside there are the product configuration files which in case of formatting would be lost. The format operation is instead required on additional storage devices “D:” e “F:”, I remind you that although they are extractable devices, when inserted into the system and formatted they can no longer be removed. For formatting use the command Format bycommand interpreter, additional parameters can be supplied to the command:

  • Drive: Identification of the unit to be formatted, C: Internal FLASH disk, D: SDCard on card, F: SDCard on USB adapter
  • FAT Type: Specifies the format of the File Allocation Table.
    FAT_32: Standard format, allows the reading of SDCards formatted on a PC, Directories / Files names only uppercase length 8 + 3.
    FAT_32_ELS: Custom format, allows you to define Directories / Files names both in upper and lower case, length 14 total characters.
    FAT_32_ELS_WL: Custom format, like the previous one with wear leveling enabled only on the internal disk C:.
  • Cluster Size: Allows you to define the size of the cluster in bytes, the size must be a multiple of the sector size (512 bytes).
Formatting examples

Format C: Format the internal disk in FAT_32_ELS automatically choosing the cluster size. If the operating system manages wear leveling, the format is used FAT_32_ELS_WL.

Format D: Format on-board SDCard to FAT_32_ELS by automatically choosing cluster size

Format D: FAT_32 Format SDCard on card in FAT_32 setting the cluster size to 512 bytes (1 sector, minimum value)

Format D: FAT_32_ELS 512 Format SDCard on card in FAT_32_ELS setting the cluster size to 512 bytes (1 sector, minimum value)

Format F: FAT_32_ELS 2048 Format SDCard on USB adapter in FAT_32_ELS setting the cluster size to 2048 bytes (4 sectors)

Cluster format

If the cluster size is not indicated in the format command, the system automatically sets the appropriate value based on the size of the SDCard. In general, the format should be chosen based on the following assessments.

Small cluster

  • Pro: Optimize disk occupation.
  • Against: Increases the number of writes in FAT sectors reducing disk life.
    Determines slower disk access speed.

Large cluster

  • Pro: Reduces writes in FAT sectors by extending disk life.
    Faster disk access speed.
  • Contro: Memory waste for each file (Average 1/2 cluster size).
    Increases the time for creating directories on the disc.

Advice

  1. It is preferable to use external disks as an alternative to the internal FLASH disk “C”.
  2. Preferably use files up to 640 KBytes in size.
  3. To speed up disk access without penalizing the execution time of the back task, limit the number of files and directories.
  4. To increase the "life" of the disk, if possible, use fixed size files by updating the data inside (As managed by the FB FIFOFile).
  5. If you are using the disk to save log files transferred via FTP to other systems, delete the file after the transfer and recreate it, rather than rewriting it.
Disk access errors

Viewing the system log, command SysLog or by analyzing the file Logs.txt in the folder System, you can see any disk access errors, here are the most common.

  • 3380, Not enough cluster vs required: An attempt was made to access a location larger than the size of the disk. It typically occurs when the disk is full, or a Sysfseek to a position greater than the disk size.
Was this article helpful?