Fundamentals of NVM in AutoSAR.
Published: 2024-01-16 09:02:31

Hello Readers, 👋😃
My name is Shiva Kumar M, and I work at Luxoft India as a Junior Software Developer. Luxoft has given me several opportunity to work on various projects, which has inspired me to learn the essential processes involved in developing in the NVM in AutoSAR.
 
The AUTOSAR collaboration brings about a transformation, in the sector by introducing a standardized framework. This framework includes the Memory Stack, which effectively handles volatile memory in automotive systems thereby improving the development of software applications.
 
**Introduction**
The MemStack, which stands for the AUTOSAR Memory Stack plays a role, in handling volatile memory within the AUTOSAR framework. It provides services to both the application layer and Basic Software Modules enabling utilization of NV memory. Its primary function is to ensure data storage and effortless integration, with hardware setups.
 
**AUTOSAR Memory Stack Architecture**
 
The AUTOSAR Memory Stack consists of modules like NVRAM Manager, Memory Interface, Memory Abstraction, and Memory Driver Modules, which work together for efficient memory management.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9wids0ps1vs1b3otuh5.png)
Fig: AUTOSAR Memory Stack Architecture
 
The main role of the NVRAM Manager is to handle data storage and maintenance ensuring that data is stored in compliance, with requirements. It acts as a gateway for software components (SWCs) and Basic Software Modules (BSW) to access NV memory allowing them to read from and write to NV memory.
 
The Memory Interface (MemIf) serves as a layer between the NVRAM Manager and the underlying memory abstraction modules (Flash EEPROM Emulation and EEPROM Abstraction). It establishes a segmentation and linear address space enabling the NVRAM Manager to remain independent of memory device interfaces.
 
The Memory Abstraction modules, Flash EEPROM Emulation (FEE) and EEPROM Abstraction (Ea) abstract the device addressing scheme while providing a virtual addressing scheme. They ensure an addressing scheme so that upper layer modules can remain unaffected even if there are changes, in the underlying memory devices.
The modules responsible, for managing memory, such, as the Flash Driver (Fls). Eeprom Driver (Eep).
 
**Ensuring data storage and maintenance**
The NVRAM Manager [NVM], which is also referred to as the NvM module plays a role, in the AUTOSAR Memory Stack. It is responsible for storing and maintaining data in NV memory.
 
This module effectively handles NV data coming from EEPROM. Flash EEPROM emulation devices ensuring that the storage and retrieval of data align with automotive requirements. One of its functions is managing the lifespan of NV memory by optimizing writing cycles to prolong its durability. Additionally it incorporates error correction and detection mechanisms to guarantee the integrity of stored information. The NVRAM Manager takes care of initializing memory addressing any errors that may arise and offers services, for both asynchronous read and write operations.
 
**Memory Abstraction Interface**
The Memory Abstraction Interface, also known as MemIf serves as a link, between the NVRAM Manager and the memory abstraction modules like Flash EEPROM Emulation and EEPROM Abstraction. Its primary function is to provide a layer of abstraction ensuring that the NVRAM Manager remains independent of the underlying interfaces of memory devices.
 
MemIf plays a role in standardizing access to memory abstraction modules by creating a virtual segmentation and a uniform address space for the NVRAM Manager. It abstracts the device addressing schemes employed by Flash EEPROM Emulation and EEPROM Abstraction effectively offering an interface for upper layer modules.
 
By leveraging the capabilities of MemIf, the NVRAM Manager gains access to memory abstraction modules without requiring in depth knowledge of each modules specifics. Facilitates integration, with diverse memory devices.
 
 
**Simplifying a Device Specific Addressing Scheme**
The Flash EEPROM Emulation (FEE) module, within the AUTOSAR Memory Stack simplifies the device addressing scheme and segmentation of Flash memory. It offers higher level modules, just like the NVRAM Manager, a digital addressing scheme and segmentation.
 
FEE ensures that the higher layers of the AUTOSAR stack have a digital addressing scheme it is no longer dependent on the reminiscence layout. Additionally it enhances the durability and longevity of Flash memory by allowing an number of erase cycles.
 
By abstracting the complexities of Flash memory the FEE module provides an interface for data reading and writing. This ensures access, to Flash memory, enabling storage and retrieval of data.
 
**Achieving Consistency in Addressing**
The AUTOSAR Memory Stack's EEPROM Abstraction (Ea) module offers various services for managing data in an EEPROM, such as reading, writing, erasing and comparing. Its main purpose is to standardize the addressing scheme used by the underlying EEPROM driver, ensuring a consistent approach.
 
By abstracting the addressing scheme of the EEPROM driver, the Ea module allows for easy replacement of the actual EEPROM device without requiring any modifications to be made to higher level modules. This flexibility ensures that modules like the NVRAM Manager can remain unchanged even when a different EEPROM device is used.
 
The Ea module plays a essential function in enabling efficient get right of entry to to EEPROM memory through presenting a unified interface. It ensures that data can be stored and retrieved from the EEPROM with reliability seamlessly integrating it into the AUTOSAR framework.
 
**Initialization and Retrieval of Flash Memory**
 
The Flash Driver also referred to as Fls has a role, in the AUTOSAR Memory Stack by managing the initialization and retrieval of data from Flash memory. Its main purpose is to enable storage and retrieval of data by offering services for reading from and writing to Flash memory.
 
The Fls driver takes care of initializing the Flash memory and handling low level operations required for accessing it. It presents capabilities that allow studying, writing and erasing records blocks inside the Flash memory.
 
By utilizing the services offered by the Fls driver upper layer modules like NVRAM Manager can effectively interact with Flash memory. The Fls driver simplifies complexities associated with Flash memory ensuring storage and retrieval of data.
 
**Efficient Access to EEPROM Memory**
 
The Eep driver is a component of the AUTOSAR Memory Stack that plays a role in efficiently accessing EEPROM memory. Its primary function is to provide services for reading, writing, erasing and comparing data, in EEPROM.
The Eep driver simplifies the process of accessing, EEPROM memory by abstracting its complexities. It provides an interface that ensures storage and retrieval of data from the EEPROM seamlessly integrating it into the AUTOSAR framework.
 
In addition the Eep driver includes a service that enables comparing a data block stored in the EEPROM with a block in another form of memory like RAM. This feature is crucial, for maintaining data integrity within the EEPROM.
 
 
**Different Ways to Utilize the AUTOSAR Memory Stack and Its Applications**
The AUTOSAR Memory Stack has use cases. Is applied in different ways within the automotive industry. It plays a role, in managing volatile memory and allowing for persistent storage of data.
 
One important use case of the AUTOSAR Memory Stack is its involvement in the Diagnostic Event Manager (DEM) module in managing freeze frame data and event memory. The NVRAM Manager and other related memory abstraction modules facilitate the storage and retrieval of freeze frame data and event memory.
 
Additionally the AUTOSAR Memory Stack is utilized in BSW modules that require access, to volatile memory. These applications include storage of calibration data, management of error memory and handling dynamic data storage.
 
**Here is an example of an AUTOSAR Memory Stack**
We have a requirement to store the Odometer data, which's 2 bytes, in size in the Flash memory.
The diagram below illustrates how the data moves from the Application Layer to the MCAL Layer, in the Autosar Memory Stack.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/haz2flezgn5f18su7c1u.png)
 
The next article will continue with examples.
 
If you have any questions or comments, please let me know below.
 
Thank you for reading.
 
 
**References**:
 
- AUTOSAR_SWS_NVRAMManager. (2018, October 31). AUTOSAR. Retrieved October 31, 2018, from https://www.autosar.org/fileadmin/standards/R20-11/CP/AUTOSAR_SWS_NVRAMManager.pdf