NVRAM Manager in AUTOSAR || Part -1

Padmanabh
10
After reading this article you will learn :

1. Basic working principle of NV data handling
2. Basic storage objects (RAM block, RAM Block, ROM Block and Administrative Block)
3. Block management types ( Native Data block, Redundant Data Block and Data set Block)





1. Basic Working Principle :


Consider fig.1 shown below, in case of write data (Blue arrow), SWC has data to write in NV memory, data is copied to RAM block then data is copied to NV Memory. Similar is the case while reading data (Yellow arrow), first data is copied to RAM block  from NV Block then SWC read data from RAM block or RAM mirror.


Fig.1 Basic Working Mechanism of MemStack

NV Block and Block IDs

NV blocks are used to store NV data and present into NV memory. Each block is associated with block ID and this is maintained in NV Block descriptor table.

e.g. if you have data related to vehicle speed e.g. max speed, min speed,  this data you can see on console of car, this data is stored in NV memory. There is a block dedicated to Vehicle Speed parameters and a block ID corresponding to a block. Similarly to store errors related to create a bock for vehicle error and assign a block ID using configuration tools.

2. Basic Storage Object and Block Management :


To understand memory stack you should understand basic storage object used in memory stack and block management. Basic storage object is smallest entity of memory block. Basic storeage objects are : RAM block, ROM block, NV block and  Administrative block.

To store data into NV memory and  to handle data to be stored into NV memory, a concept used called memory blocks, e.g. if you have a data related to Vehicle Speed  (Vspeed), this Vspeed is to be stored in NV memory. Size of Vspeed is 2 bytes, so to store Vspeed in NV memory blocks of memory is reserved in NV memory called NV blocks. 

Application (SWC) which uses VIN, uses RAM blocks to handle VIN. Now what is use of RAM blocks if you already  have NV block?. Application (SWCs) holds data into RAM block, at time of writing data in NV memory, data from RAM block is copied into NV block, at  time of data read, data from NV block is copied to RAM block. RAM block is required as there is limitation of NV memory write cycle (e.g. 10,000 write cycles), so data is held in RAM blocks and written to NV blocks when required, by doing so NV memory's life (write cycle) is maintained. 


Fig. 2 Basic Storage Objects

2.1 Basic Storage Objects :

Below are the basic storage objects

NV Block : NV block is basic storage object and resides in NV Memory. NV block structure is shown in fig.2. NV Block made up of optional CRC, optional Header and NV memory.

RAM Block : RAM block basic storage object resides in RAM. RAM blocks can be permanent or temporary. Each RAM block corresponds to a particular NV Block. Structure of RAM block is as per  fig.2. RAM block has optional CRC (is available if corresponding NV block is having a CRC) and Header block and RAM memory.

ROM Block : Rom block in ROM. It do not have CRC or Header refer fig.2. ROM block contains default data. This data is used in case of error in NV block (this will be explained in error recovery section)

Administrative Block : Administrative block resides in RAM and this block is mandatory. It is used to hold status of corresponding RAM block (discussed in Part -2 of NVRAM manager).





2.2 Block Management Types :

In above section we have discussed about basic storage object, in this section we will discuss about block management types. NVRAM block contains RAM block, ROM block, NV block and Administrative block. Combinations of these blocks can be configured to create different types of  NVRAM block. Below are the block management types supported by NvM :


1. Native Block :

The Native NVRAM block is the simplest block management type. It allows storage to/retrieval from NV memory with a minimum of overhead.

In case of native block, there will be 1 NV block created in NV memory. Then 1 RAM block will be created, as RAM block is required to provide data to application /run time. 1 ROM block to store default values and 1 Administrative block.

NV Block : 1
RAM Block : 1
ROM Block : 1 or 1
Administrative Block : 1

2. Redundant Block :

In addition to the Native NVRAM block, the Redundant NVRAM block provides enhanced fault tolerance, reliability and availability. It increases resistance against data corruption.

So if one NV block fails, we have still have one more block, from which data can be retrieved. This will help to keep data secure in NV memory.

In case of Redundant block there will be 2 NV blocks but 1 RAM block as application will require only a copy if valid data, so valid data NV block will be copied to RAM. ROM block will be required as 1 and 1 Administrative block.

NV Block : 2
RAM Block : 1
ROM Block : 0 or 1
Administrative Block : 1

3. Data Set Block :

The Dataset NVRAM block is an array of equally sized data blocks (NV/ROM). The application can at one time access exactly one of these elements. A specific dataset element is accessed by setting the corresponding index using the API NvM_SetDataIndex.

NV Block : 1...n
RAM Block : 1
ROM Block : 0 or n
Administrative Block : 1




Post a Comment

10 Comments
  1. Hello Sir,
    The above article is very well explained, Thank you for that.
    But i have a question, if you can provide inputs it will be great:
    Context:As per my understanding any block of memory in NV memory is called NV block and Blocks of memory form RAM is called RAM block and Block of Memory in ROM is called Rom block,and basically we map this RAM block and RAM block we map to NV block(NV memrory).
    if my above understanding is wrong please correct me.
    Q1. How we map NV block to RAM block and Rom block.
    Q2. How we map SWC info To RAM block and RAM to NV block.

    This above question will complete the full cycle of data,
    Thank you

    ReplyDelete
  2. Hello Anshuman, your understanding is right. While reading data copied to NV block from RAM block and while writing data copied from RAM block to NV block.

    RAM, NV and ROM block can be configured using DaVinci Developer, in NV Block descriptor.

    ReplyDelete
  3. Hello thanks for this interesting explanation,
    I would like to ask how can we determine the block address in NV memory if we want to view it for example with trace32

    ReplyDelete
  4. Hello for debugging purpose you can check 1st Ram Block.

    Address is determined by FEE, so to check NV memory, you can add breakpoint in FEE Write function and check for address of NV Block.

    ReplyDelete
  5. Hi Sir,
    Thank you so much for the detailed description.
    1. Could you elaborate Native block and Redundant block. Not clearly understood.
    2. Nv Block number mentioned as 1 in Native block, and 2 in case of Redundant block. May I know why is it so?

    ReplyDelete
  6. Hello Jai, In case of Native block there will one NV block. If block is corrupted then there will not be any mechanism to retrieve data.

    In case of redundant there will be 2 NV blocks for storage of same data.

    Now why redundant block is required? For error recovery. Consider one NV block corrupted, still data cam be retrieved from another NV block.

    ReplyDelete
  7. Hello Sir, Thank you for nice article. Could you please explain about the DTC storage process in NVM. How the NV blocks are configured for DTCs, snapshot data. Is there any limit for storing number of DTCs in NVM? Thank you.

    ReplyDelete
  8. Hello G92 , to store DTC in NVM, you need to configure NV Blocks e.g you can configure 7 NV blocks (size of each block should be size of maximum size of snapshot data). Also it is not like yoy have 10 DTCs so you should configure 10 NV blocks. It depends on requirement.

    Provide references of these NV blocks in DEM. DEM will store snapshot data into available block (configured for DEM).

    ReplyDelete
  9. For redundant block explanation, you mistakenly mentioned as " In case of Native block there will be 2 NV block". Please correct if its so..

    ReplyDelete
  10. Hi Sir,
    Thank you for the detailed description.
    1)Could you please elaborate about, How do NVM module idenfies Virgin ECU? and
    2)How does it load Default/ROM data?

    ReplyDelete
Post a Comment
To Top