The second part of a two-part series on µC/FS configuration values.
μC/FS comes with several configuration files. This article will focus on the remainder of this configuration file that wasn’t covered in Part I. It helps to ask yourself a few questions about your application:
- What size file system do I need to use? FAT12/16/32 depending on the size of data the application will be handling, processing, etc.
- Will the file system be creating a lot of small files or only a few files? This will determine how large you can or want to configure the file names, directory path names and other length restrictions.
- Will this application need any debugging counters or value checks enabled? There are several functions that can be enabled to keep track of error occurrences, statistical counters for operations completed and argument checks.
- What device do I intend to run my file system on? SD Card, NAND or NOR Chip, RAMDisk implementation? If you are running with a device that may encounter power failures you may wish to utilize the journaling functionality.
When setting up your file system application you will need to configure
fs_cfg.h to the specifics of your application. Here are the remainder of those configurations explained a bit more in-depth.
#define FS_CFG_MAX_DEV_NAME_LEN 15u #define FS_CFG_MAX_DEV_DRV_NAME_LEN 10u #define FS_CFG_MAX_FILE_NAME_LEN 255u #define FS_CFG_MAX_PATH_NAME_LEN 260u #define FS_CFG_MAX_VOL_NAME_LEN 10u #define FS_CFG_DBG_MEM_CLR_EN DEF_ENABLED #define FS_CFG_DBG_WR_VERIFY_EN DEF_DISABLED #define FS_CFG_ERR_ARG_CHK_EXT_EN DEF_ENABLED #define FS_CFG_ERR_ARG_CHK_DBG_EN DEF_ENABLED #define FS_CFG_CTR_STAT_EN DEF_DISABLED #define FS_CFG_CTR_ERR_EN DEF_DISABLED #define FS_FAT_CFG_LFN_EN DEF_ENABLED #define FS_FAT_CFG_FAT12_EN DEF_ENABLED #define FS_FAT_CFG_FAT16_EN DEF_ENABLED #define FS_FAT_CFG_FAT32_EN DEF_ENABLED #define FS_FAT_CFG_JOURNAL_EN DEF_DISABLED #define FS_FAT_CFG_VOL_CHK_EN DEF_DISABLED #define FS_FAT_CFG_VOL_CHK_MAX_LEVELS 20u #define FS_DEV_SD_SPI_CFG_CRC_EN DEF_DISABLED #define FS_TRACE_LEVEL TRACE_LEVEL_INFO #define FS_TRACE printf
The above values are part of the File System Configuration block of the file system configurations. These definitions are either numerical settings which require some application-specific configuring or more enable/disable settings. These configurable values will be further expanded on below.
FS_CFG_MAX_DEV_NAME_LEN: This define allows you to specify the maximum allowable length for naming any devices you create within the application. Keeping in mind this can be a point of optimization for reducing memory consumption. This is usually defined as a small length.
FS_CFG_MAX_DEV_DRV_NAME_LEN: This define allows you to specify the maximum allowable length when naming a device driver within the user application. Typically, this value can be kept shorter.
FS_CFG_MAX_FLE_NAME_LEN: This define controls the maximum allowable length when naming a file within an application. This value can be limited by the type of FAT FS you setup within the application. A filename length of 255 is the maximum supported in FAT12/16/32 with LFN enabled.
FS_CFG_MAX_PATH_NAME_LEN: This define controls the maximum allowable length when defining and constructing a path to a file or directory. This value must be coordinated with the type of FAT FS the application is using.
FS_CFG_MAX_VOL_NAME_LEN: This define controls the maximum allowable length when naming a volume created within an application. Similar to the driver and device names this is usually a shorter defined length.
Figure 1 - Diagram of File System Name Restriction Configurations
FS_CFG_DBG_MEM_CLR_EN: This controls the enable/disable of the memory clear feature within the file system. This feature is convenient when trying to debug an application. When enabled the file system will clear out internal data structure memory buffers. This does not provide any user API’s and is a function handled internally to the file system.
FS_CFG_DBG_WR_VERIFY_EN: This configurable control enables/disables the write verification feature within the file system. A useful feature to utilize if debugging a driver.
FS_CFG_ERR_ARG_CHK_EXT_EN: This enable/disable configuration allows for inclusion of the external argument checking feature. This will check any arguments received from a port interface provided by the developer or application layer. When using or interfacing with external sources this is a useful feature to use.
FS_CFG_ERR_ARG_CHK_DBG_EN: This enable/disable configuration allows for the inclusion of internal argument checking which is useful when debugging. There are no API’s that need calling for use, the argument checking will be done automatically. Typically, not recommended for use when application development is completed.
FS_CFG_CTR_STAT_EN: Enabling/disabling this feature includes statistical counters within the file system stack. Useful for debugging or if the application needs to keep track of occurrence rates of or other trackable operations within the stack.
FS_CFG_CTR_ERR_EN: When this enable/disable is enabled it allows the file system stack to keep count of error occurrences within the stack. Whether to use this feature after debugging and development is up to the developer.
FS_FAT_CFG_LFN_EN: This configuration control the stacks support for long file names. If this is disabled then long file name entries may NOT be used within the application that interact with the file system. Depending on the FAT implementation you use will impact how many files you can create with your allocated space and size of named files.
FS_FAT_CFG_FAT12_CFG: Enables support for FAT12. If you wish to create a device with FAT12 implementation you must enable this functionality.
FS_FAT_CFG_FAT16_CFG: Enables support for FAT16. If you wish to create a device with FAT16 implementation you must enable this functionality.
FS_FAT_CFG_FAT32_CFG: Enables support for FAT32. If you wish to create a device with FAT32 implementation you must enable this functionality.
FS_FAT_CFG_JOURNAL_EN: If journaling functionality is desired within the file system this must be enabled for use. Journaling effectively creates a “journal” to track changes that have not been successfully completed yet. This allows for recovery from sudden power loss without losing the state the file system was in. Journaling within µC/FS does not require additional API calls by the application. The operations are handled internally when enabled.
FS_FAT_CFG_VOL_CHK_EN: Enable this feature if you wish to ensure volume integrity. If this is enabled the
FS_FAT_CFG_VOL_CHK_MAX_LEVELS define will determine the maximum number of directory levels to be checked. If this feature is not required it may be disabled.
FS_FAT_CFG_VOL_CHK_MAX_LEVELS: Used by the
FS_FAT_CFG_VOL_CHK_EN feature to determine how many levels of a directory to check when the feature is enabled. If disabled this define will not be used.
FS_DEV_SD_SPI_CFG_CRC_EN: When enabled this will allow for a Cyclic Redundancy Check (CRC) value to be generated and checked during all data read and writes. When enabled a small “check value” will be appended and used for data integrity verification. If this functionality is not needed it can be disabled to remove it from the file system implementation.
FS_TRACE_LEVEL: This is used to configure a desired output level for file system output messages: TRACE_LEVEL_OFF - Disable all output messages from the file system.
TRACE_LEVEL_INFO - This will enable minimum trace for important events (opening a device, device initialization errors, etc)
TRACE_LEVEL_DBG - This will enable general debugging trace messages as well as INFO.
TRACE_LEVEL_LOG - This enables all trace messages, including low-level info traces.
FS_TRACE: This specifies which function to use when the trace messages attempt to display an output message. This is commonly set to use “printf” for simplistic cases. It can also use developer specified output functions if there is a problem accessing printf in some embedded applications or if other controls are needed to access a command line or other display terminal.
This completes the analysis of the µC/FS configuration values in the
fs_cfg.h file. There are many other configurable features of µC/FS that will be covered in subsequent articles. It’s important to familiarize with these configuration variables in order to best utilize and optimize your implementation of µC/FS with your design.