Flash EEPROM Emulation (FEE in AUTOSAR)

Padmanabh
7
After reading this article you will understand :
1. FEE module
2. Addressing Scheme and segmentation (i.e. Paging and Sector)
3. Limitation of erase cycles
4. Fee Read and Fee Write functionalities and job end notifications.
5. FEE Blocks.
6. Important configuration Parameters.





1. Introduction : 


FEE i.e. Flash EEPROM Emulation is present at Hardware abstraction layer. FEE is used to access underlying FLASH memory. FEE uses Flash (FLS) driver to read or write data from or to flash memory. Call from NVRAM manager is passed to FEE module and FEE to FLS.  FEE Provides services to write and read block.

Fig. 1 FEE module in AUTOSAR Architecture




2. Functionalities of FEE :

Functionalities of FEE modules are described in this section. FEE is implemented as per underlying Flash memory. i.e. page size and sector size


2.1 Addressing Mechanism and Address Calculation:

FEE provides 32 bit addressing scheme to upper layer module i.e. NVRAM manager. This 32 bit address is divided into 16 bit block number and 16 bit block base number. 
16 bit block number : Allows total 66535 blocks.
16 bit block offset    : Allows 64KByte  per block

16 bit block number represents represents a virtual block and virtual block is made up of  virtual pages. FeeVirtualPageSize is a configuration parameter used to configure virtual page size. Virtual page size should be multiple of Physical page size. Physical page size depends on underlying Flash memory. e.g. if block is of size 32 bytes and FeeVirtualPageSize is 8 bytes then 4 virtual pages are required for block and if size of block is 52 bytes then virtual pages required are 7 i.e. 56 bytes.


FEE calculates physical address from block number and block offset.

Note : The exact address format needed by the underlying flash driver and therefore the mechanism how to derive the physical flash address from the given 16bit block number and 16bit address offset depends on the flash device and the implementation of this module and shall therefore not be standardized

2.2 Read Block and Write Block :

Fee_Read() function is used for initiating read job.  Block offset  and block  number are provided as input parameter to Fee_Read() function using block offset and block number FEE calculates physical address.

Fee_Write() function is used for initiating write job. Function Fee_Write() takes block Number as input parameter i.e. block start address and calculates corresponding memory write address.
Fig 2 shows write operation call flow.

FeeNumberOfWriteCycles decides number of write cycles for logical block. 

Fig.2 Write Call Flow

2.3 Main Function :

Fee_MainFunction() handles read / write / erase job requests asynchronously

The function Fee_Main Function shall check, whether the block requested for reading has been invalidated by the upper layer module. If so, the function Fee_Main Function shall set the job result to MEMIF_BLOCK_INVALID and call the error notification routine of the upper layer if configured.

The function Fee_Main Function shall check the consistency of the logical block being read before notifying the caller. If an inconsistency of the read data is detected or if the requested block can’t be found, the function Fee_Main Function shall set the job result to MEMIF_BLOCK_INCONSISTENT and call the error notification routine of the upper layer if configured.

2.4 Callback Notifications :


Fee_JobEndNotification() service  to report successful end of Asynchronous request. The underlying flash driver shall call the function Fee_JobEndNotification to report the successful end of an asynchronous operation. Fee_JobEndNotification is mapped to NVRAM managers module's Job end notification. 

Fee_JobErrorNotification() is used to report the failure of an asynchronous operation. Fee_JobErrorNotificcation calls NvM Error Notification function.


2.5 Limitation of Erse cycle :

Underlying Flash memory has limitation of write cycle e.g. 10000 i.e. you can write only 10,000 times to flash memory. If you are using one block more times than other blocks then FEE module implements mechanism, such that one memory region will not be over-stressed.

In case requirement is you can able to write block 50000 times but flash memory's life/endurance is 10000 cycles then in this case FEE module will reserve 5 blocks and manages internally their access to meet requirement. 

2.6 Immediate Data Handling :

If block is configured with Immediate data i.e. data has to stored immediately (without need to erase block and store) when requested ( not when write all is processing). 

If there is on going lower priority job i.e. read/rite/cancel block then FEE suspends the on going job and processes immediate data request.
To store such data FEE uses pre-erased blocks.

2.7 FEE BLOCK Configuration :

FEE has its own configuration parameters related to blocks defined in NvM Module. Blocks can be configured using configuration container FeeBlockConfiguration. FEE blocks  have its own block ID and size of block (taken from NVRAM block configuration). 

Also Number of write cycles for particular block can be configured using FeeNumberOfWriteCycles.
If block data should be written immediately then enable configuration parameter FeeImmediateData.
Each block has reference of Device Index


3. Important Configuration Parameters :


1. FeeNvmJobEndNotification
2. FeeNvmJobErrorNotification
3. FeeVirtualPageSize
4. Fee Block Number
5. Fee Block Data size
6. FeeNumberOfWriteCycles
7. FeeImmediateData

Post a Comment

7 Comments
  1. Why Fee is required as we have NVM already?

    ReplyDelete
    Replies
    1. AUTOSAR is kind of a funny guy :P. Once a while he use to snort with Zuckerberg and hence results like FEE are there.
      On a serious note, the NvM in microcontrollers is usually a flash memory and unlike EEPROM, it is not suitable for rewriting data too frequently as the data can only be written after erase and erase operation needs to be executed for the entire block. Erasing entire block for change in just one byte of data is not so smart. So FEE provides the advantages of EEPROM while still using the FLASH memory.

      Delete
    2. The usage of EEPROM emulation which uses internal Data Flash of the microcontroller is generally preferred since less expensive than external EEPROMs.

      Delete
    3. The usage of EEPROM emulation which uses internal Data Flash of the microcontroller is generally preferred since less expensive than external EEPROMs.

      Delete
  2. Content is short and crisp
    Please check the spelling and other semantics

    ReplyDelete
  3. Is there any implementations code in previous project for FLASH CONTROLLER module.

    ReplyDelete
  4. NvM is another level of abstraction where the memory type is irrelevant. Besides Fee for Flash memory, you could have an EEPROM abstraction to access the EEPROM.

    ReplyDelete
Post a Comment
To Top