High-level formatting

From SEGGER Knowledge Base
Revision as of 11:50, 19 December 2024 by Marius (talk | contribs) (Created page with "== General information == The high-level formatting is a file system operation that can be used to initialize the structure of the file system on a storage device. Typically, this operation has to be performed only once on a lifetime of a storage device before writing any data to the storage device. The high-level format operation can also be performed on a storage device that is already formatted and that contains files and directories. However, all the files and direc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

General information

The high-level formatting is a file system operation that can be used to initialize the structure of the file system on a storage device. Typically, this operation has to be performed only once on a lifetime of a storage device before writing any data to the storage device. The high-level format operation can also be performed on a storage device that is already formatted and that contains files and directories. However, all the files and directories will be lost after the high-level format operation.

The reason why this operation is called high-level is to differentiate it from the other type of format operation that is performed by the NAND and NOR drivers and is called low-level formatting. High-level indicates that the operation is performed in the file system layer that is located above the driver layer in the emFile software stack where the low-level formatting operation is implemented.

Theory of operation

An application can perform a high-level format operation by calling the FS_Format() API function. This API function can be used to perform a high-level format for any of the file system types supported by emFile. The type of file system used by the high-level format operation is determined the file system support enabled in emFile at compile time via FS_SUPPORT_FAT, FS_SUPPORT_EFS or FS_SUPPORT_EXFAT configuration defines. If emFile is configured to support more than one file system type then the type of file system used by high-level format operation has to be specified by calling the FS_SetFSType() API function.

In addition, emFile comes with specialized API functions for formatting a storage device as FAT and exFAT. These API functions format a storage device according to the specification SD Association. The FS_FAT_FormatSD API function can be used to format a storage device as FA12, FAT16 or FAT32 while the FS_EXFAT_FormatSD can be used to format a storage device as exFAT.

The high-level formatting operation is initializing at least the following regions of a file system:

  • Boot sector
  • Allocation table
  • Root directory

The format API functions may initialize other regions of the file system depending on the file system type.