How to integrate a new memory to the Linux?

How to integrate a new memory to the Linux?

Please, I would like the get some advises about how to get some C/C++ global variables and some dynamically allocated memory to be mapped into a parallel NVRAM connected to the Colibris iMX6 EIM bus, so that these data could be automatically non volatile data.

Explaining my problem in more details:

My new carrier board have a NVRAM (SRAM + Battery) connected to the Colibri iMX6 parallel bus (EIM bus). This NVRAM is intended to keep the structure to run a legacy application firmware from a former hardware platform, which had a NVRAM for nonvolatile data.

In the former platform there was an RTOS. The nonvolatile data were C/C++ global variables and dynamically allocated memory, allocated in specials .data and .heap segments, both of them mapped into the NVRAM by the linker. So, the data allocated in these segments were non volatile.
The difficulty now is that this nonvolatile data, including pointers to nonvolatile allocated memory, are accessed all along the firmware, during run time. So it is difficult to change to another method of nonvolatile data retentions that demands functions calls, because it would demand a big rework in the firmware.
To save the nonvolatile data during shunt down is also not possible because there is not enough time for that.

So, the most straight forward solution appears to be the nonvolatile data directly mapped into the NVRAM, like in the former platform, without the need functions calls for saving/restoring data.

Currently, in the Colibri iMX6 platform with Linux, I can access that NVRAM only with pointers obtained with mmap(). Even using this pointers that would demand a big rework in the firmware.

Maybe I am not in the right way with this idea. So, I would appreciate any other advise.

thank you,


Using the mmap() function calls is the way to access the physical address space of weim.

I’m not aware on how to tell mmap() to keep the mapped virtual address constant. Thus I don’t see how you would be able to have the linker putting your global variables into the NV memory region.


Yes, usually running such NVRAM devices in a managed operating system like Linux would require a device driver which does the whole abstraction and one may not really just link it into application programs like on a microcontroller. One NVRAM device which is supported in Linux is the good oldé MC146818 RTC whose clone may be found on may a regular X86 motherboard. The device driver which is somewhat more generic may be found here.