NvM Overview

Micael Coutinho,autosarbswnvm

Memory operations on an ECU are achieved through the NvM. Learn how to use the module here

In the past weeks, we have covered the very basics of the memory stack, which contains the NvM (NVRAM Manager) on top, the Basic Software component used for memory interactions within the ECU. Although we already told you how useful the memory stack is, in the article Memory Stack Overview (opens in a new tab), let's refresh.

It's very common in the product lifecycle the need to store and read data persistently. The easiest example which is right under your nose is the diagnostics in your vehicle. Every time a problem is detected within your vehicle, it gets stored "somehow", for your mechanic (or you, in your spare time) to read, right? That's when the NvM comes in. In this specific case, the DEM (Diagnostic Event Manager) interacts with the NvM to store the diagnostic errors detected while you drive (you can learn more about the DEM here, in DEM Overview (opens in a new tab)). This is not limited to diagnostics, though. There are multiple instances where your application needs to access and modify data, to recalibrate sensors or actuators and even use the resume mode of XCP (which you can learn more about in What is XCP (opens in a new tab)).

In sum, the NvM handles the reading and writing to non-volatile memory. It provides you API's to perform synchronous and asynchronous operations, along with service ports to interact with it in the application layer (you can learn more about interfaces and ports in Types of Interfaces and Ports (opens in a new tab)). Now, let's dive deep into the NvM.

The NvM defines internally basic storage objects, which are the blocks where your non-volatile memory gets stored:

There are 3 blocks of NvM block management, which define the number of NV blocks associated, along with administrative blocks. They differ in reliabily against data corruption, mostly:

Regarding the setup of NvM, the ECUM (ECU State Manager) is the only module that can initialize the NvM, through the API NvM_Init. Another API is needed in order to initiaize the RAM data blocks, NvM_ReadAll, which is also responsibility of the ECUM. You can take a look at these and other API's here:

As you can see, the NvM interacts a lot with the ECUM, as other BSW modules to, specially in initialization and shutdown. If you want to learn more about mode management, you can check our article Mode Management (opens in a new tab).

Lastly, let's look at the most important API's and ports that you can use for the NvM:

When it comes to ports and interfaces, you have at your disposal a service interface to all block-related services, with the exception of NvM_SetBlockProtection, and you can have a Client-Server interface, for notification callbacks. You can also have a port for a CS interface regarding the administrative services for a block. To read and write data you have a Sender-Receiver interface, as we covered in previous articles.

NvData sender (left) and NvData receiver (right) ports symbol { w: 250, h: 61 }

NvData sender (left) and NvData receiver (right) ports symbol

As some final notes, we hope this article provided you with a thorhough understanding of the NvM module, and hope you are ready to use it in your next application. If you want to learn about the other stacks in the Autosar layered architecture, we already covered the watchdog and communication stack, respectively in Watchdog Stack Overview (opens in a new tab) and Communication Stack Overview (opens in a new tab). See you next time!

Author: Micael Coutinho (opens in a new tab)

References:

© AutosarToday —@LinkedIn