![]() |
RA Flexible Software Package Documentation
Release v5.8.0
|
|
Functions | |
fsp_err_t | RM_FILEX_BLOCK_MEDIA_Open (rm_filex_block_media_ctrl_t *const p_ctrl, rm_filex_block_media_cfg_t const *const p_cfg) |
fsp_err_t | RM_FILEX_BLOCK_MEDIA_Close (rm_filex_block_media_ctrl_t *const p_ctrl) |
void | RM_FILEX_BLOCK_MEDIA_BlockDriver (FX_MEDIA *p_fx_media) |
Access Block Media device functions open, close, read, write and control. More... | |
Middleware for the Azure RTOS FileX File System control using Block Media on RA MCUs.
This module provides the hardware port layer for FileX file system. After initializing this module, refer to the FileX API reference to use the file system: https://docs.microsoft.com/en-us/azure/rtos/filex/
The FileX Block Media module supports the following features:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | Selects if code for parameter checking is to be included in the build. |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_rm_filex_block_media_0 | Module name. |
Callback | Name must be a valid C symbol | g_rm_filex_block_media_0_callback | A user callback function can be provided. If this callback function is provided, it will be called when media is inserted or removed. It will also be called during operations by the lower level block media as a way for the user to provide their desired waiting functionality. |
Partition Number |
| 0 | The partition to use for partitioned media. This partition will only be used if a Master Boot Record with partition table exists at block 0 of the media, otherwise the FileX FAT boot record should exist or be formatted to block 0. |
Configuration | Options | Default | Description |
---|---|---|---|
Common | |||
Max Long Name Len | Value must be an integer greater than or equal to 13 and less than or equal to 256, or empty | Specifies the maximum file name size for FileX. If left blank the default value is 256. Legal values range between 13 and 256. | |
Max Last Name Len | Value must be an integer greater than or equal to 13 and less than or equal to 256, or empty | This value defines the maximum file name length, which includes full path name. If left blank the default value is 256. Legal values range between 13 and 256. | |
Max Sector Cache | Value must be an integer greater than 0 and power of 2 or empty | Specifies the maximum number of logical sectors that can be cached by FileX. The actual number of sectors that can be cached is lesser of this constant and how many sectors can fit in the amount of memory supplied at fx_media_open. The default value if left blank is 256. All values must be a power of 2. | |
Fat Map Size | Value must be an integer greater than 0 or empty | Specifies the number of sectors that can be represented in the FAT update map. The default value if left blank is 256. Larger values help reduce unneeded updates of secondary FAT sectors. | |
Max Fat Cache | Value must be an integer greater than 0 and power of 2 or empty | Specifies the number of entries in the internal FAT cache. The default value if left blank is 16. All values must be a power of 2. | |
Threading | |||
Update Rate (Seconds) | Value must be an integer greater than 0 or empty | Specifies rate at which system time in FileX is adjusted. Default value if left blank is 10, specifying that the FileX system time is updated every 10 seconds. | |
No Timer |
| Disabled (default) | Eliminates the ThreadX timer setup to update the FileX system time and date. Doing so causes default time and date to be placed on all file operations. |
Single Thread |
| Disabled (default) | Eliminates ThreadX protection logic from the FileX source. It should be used if FileX is being used only from one thread. |
Standalone |
| Disabled (default) | Enables FileX to be used in standalone mode (without Azure RTOS). |
Extra Features | |||
Don't Update Open Files |
| Disabled (default) | When enabled, FileX does not update already opened files. |
Media Search Cache |
| Enabled (default) | When disabled, the file search cache optimization is disabled. |
Direct Data Read Cache Fill |
| Enabled (default) | When disabled, the direct read sector update of cache is disabled. |
Media Statistics |
| Enabled (default) | When disabled, gathering of media statistics is disabled. |
Single Open Legacy |
| Disabled (default) | When enabled, legacy single open logic for the same file is enabled. |
Rename Path Inherit |
| Disabled (default) | When enabled, renaming inherits path information. |
No Local Path |
| Disabled (default) | When enabled, removes local path logic from FileX, resulting in smaller code size. |
64-bit LBA |
| Disabled (default) | When enabled, 64-bits sector addresses are used in I/O driver. |
Cache |
| Enabled (default) | Enables or disables the cache, default is enabled. |
File Close |
| Enabled (default) | Enables or disables file close, default is enabled. |
Fast Close |
| Enabled (default) | Enables or disables fast open, default is enabled. |
Force Memory Operation |
| Enabled (default) | Enables or disables force memory operation, default is enabled. |
Build Options |
| Enabled (default) | Enables or disables build options, default is enabled. |
One Line Function |
| Enabled (default) | Enables or disables one line function, default is enabled. |
FAT Entry Refresh |
| Enabled (default) | Enables or disables FAT entry refresh, default is enabled. |
Consecutive Detect |
| Enabled (default) | Enables or disables consecutive detect, default is enabled. |
Enable exFAT |
| Disabled (default) | Enables exFAT support in FileX. |
Fault Tolerant | |||
Fault Tolerant Service |
| Disabled (default) | When enabled, enables the FileX Fault Tolerant Module. Enabling Fault Tolerant automatically defines the symbol FX_FAULT_TOLERANT and FX_FAULT_TOLERANT_DATA. |
Fault Tolerant Data |
| Disabled (default) | When enabled, FileX immediately passes all file data write requests to the media's driver. This potentially decreases performance, but helps limit lost file data. Note that enabling this feature does not automatically enable FileX Fault Tolerant Module, which should be enabled separately. |
Fault Tolerant |
| Disabled (default) | When enabled, FileX immediately passes write requests of all system sectors (boot, FAT, and directory sectors) to the media's driver. This potentially decreases performance, but helps limit corruption to lost clusters. Note that enabling this feature does not automatically enable FileX Fault Tolerant Module, which should be enabled separately. |
Fault Tolerant Boot Index | Value must be an integer greater than or equal to 116 and less than or equal to 119 | Defines byte offset in the boot sector where the cluster for the fault tolerant log is. By default if left blank this value is 116. This field takes 4 bytes. Bytes 116 through 119 are chosen because they are marked as reserved by FAT 12/16/32/exFAT specification. | |
Error Checking |
| Enabled (default) |
Configuration | Options | Default | Description |
---|---|---|---|
Name | Name must be a valid C symbol | g_fx_media0 | Symbol used for media_ptr parameter in FileX APIs |
Volume Name | Name must be a maximum of 11 characters | Volume 1 | Volume name string, which is a maximum of 11 characters. |
Number of FATs | Number of FATs must be an integer greater than 0 | 1 | Number of FATs in the media. The minimal value is 1 for the primary FAT. Values greater than 1 result in additional FAT copies being maintained at run-time. |
Directory Entries | Number of Directory Entries must be an integer greater than 0 | 256 | Number of directory entries in the root directory. |
Hidden Sectors | Number of Hidden Sectors must be an integer | 0 | Number of sectors hidden before this media’s boot sector. If using media formatted with multiple partitions this number should correspond to the starting block number for the desired partition. |
Total Sectors | Total Sectors must be an integer greater than 0 | 65536 | Total number of sectors in the media. When using a Renesas provided block media implementation, total sectors can be fetched by the infoGet from the block media API. Any removable media must be inserted and initialized first to retrieve this info. |
Bytes per Sector | Bytes per Sector must be multiple of 32 | 512 | Number of bytes per sector, which is typically 512. FileX requires this to be a multiple of 32. When using a Renesas provided block media implementation, bytes per sector can be fetched by the infoGet from the block media API. Any removable media must be inserted and initialized first to retrieve this info. |
Sectors per Cluster | Sectors per Cluster must be an integer greater than 0 | 1 | Number of sectors in each cluster. The cluster is the minimum allocation unit in a FAT file system. |
Volume Serial Number (exFAT only) | Volume Serial Number must be an integer greater than 0 | 12345 | Serial number to be used for this volume. exFAT only. |
Boundary Unit (exFAT only) | Boundary unit must be an integer greater than 0 | 128 | Physical data area alignment size, in number of sectors. exFAT only. |
Working media memory size | Memory size must be an integer greater than or equal to the size of one sector | 512 | Memory allocated for file system. Memory size must be an integer greater than or equal to the size of one sector. |
The FileX Block Media driver provides a number of events in the user callback to handle waiting or pending while it is doing blocking operations. The events received in the callback will differ depending on the lower level block media driver in use.
If the lower level block media driver is rm_block_media_spi (SPI blocks on read/write operations):
If the lower level block media driver is rm_block_media_sdmmc (SDMMC is interrupt based, the FileX Block Media driver will still block while waiting for interrupts from SDMMC):
When using fx_format to format a partition the number of hidden sectors should match the starting block number of the partition and the total number of sectors should be equal to the number of sectors in the partition.
Certain events are defined in rm_block_media_event_t but not returned by the FileX Block Media user callback:
The area of the flash memory being used for the FileX instance should be erased using the lower level flash API prior to usage. Otherwise, FileX open operation may fail when fx_media_open( ) is called.
This is a basic example of FileX Block Media in an application.
This shows how to partition and format a disk if it is not already partitioned and formatted.
This shows how to use the I/O driver callback with ThreadX in order to wait/pend for operations to complete.
This shows how to use the callback to wait for media insertion.
When using a Custom Block Media implementation with rm_filex_block_media the custom implementation must call rm_filex_block_media_memory_callback upon the completion of a read/write operation. This callback should be called with an event of RM_BLOCK_MEDIA_EVENT_OPERATION_COMPLETE and p_context of rm_filex_block_media_instance_ctrl_t *. The following example shows how this should be done in the context of a demo RAM block media read function.
Data Structures | |
struct | rm_filex_block_media_instance_ctrl_t |
struct rm_filex_block_media_instance_ctrl_t |
Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. FileX block media private control block. DO NOT MODIFY. Initialization occurs when RM_FILEX_BLOCK_MEDIA_Open is called.
fsp_err_t RM_FILEX_BLOCK_MEDIA_Open | ( | rm_filex_block_media_ctrl_t *const | p_ctrl, |
rm_filex_block_media_cfg_t const *const | p_cfg | ||
) |
The file system relies on the media to be formatted prior to creating directories and files The sector size and sector count will change depending on the media type and size.
The File Allocation Table (FAT) starts after the reserved sectors in the media. The FAT area is basically an array of 12-bit, 16-bit, or 32-bit entries that determine if that cluster is allocated or part of a chain of clusters comprising a subdirectory or a file. The size of each FAT entry is determined by the number of clusters that need to be represented. If the number of clusters (derived from the total sectors divided by the sectors per cluster) is less than 4,086, 12-bit FAT entries are used. If the total number of clusters is greater than 4,086 and less than or equal to 65,525, 16-bit FAT entries are used. Otherwise, if the total number of clusters is greater than 65,525, 32-bit FAT entries are used. Initializes callback and configuration for FileX Block Media interface. Call this before calling any FileX functions.
Implements rm_filex_block_media_api_t::open().
FSP_SUCCESS | Success. |
FSP_ERR_ASSERTION | An input parameter was invalid. |
FSP_ERR_ALREADY_OPEN | Module is already open. |
fsp_err_t RM_FILEX_BLOCK_MEDIA_Close | ( | rm_filex_block_media_ctrl_t *const | p_ctrl | ) |
Closes media device.
Implements rm_filex_block_media_api_t::close().
FSP_SUCCESS | Media device closed. |
FSP_ERR_ASSERTION | An input parameter was invalid. |
FSP_ERR_NOT_OPEN | Module not open. |
void RM_FILEX_BLOCK_MEDIA_BlockDriver | ( | FX_MEDIA * | p_fx_media | ) |
Access Block Media device functions open, close, read, write and control.
The RM_FILEX_BLOCK_MEDIA_BlockDriver function is called from the FileX file system driver and issues requests to a Block Media device through the FSP Block Media Interface. Uses block media driver for accesses.
[in,out] | p_fx_media | FileX media control block. All information about each open media device are maintained in the FX_MEDIA data type. The I/O driver communicates the success or failure of the request through the fx_media_driver_status member of FX_MEDIA (p_fx_media->fx_media_driver_status). Possible values are documented in the FileX User Guide. |
None |