User`s guide

VxWorks
BSP Developer’s Guide, 6.0
74
3.3.4 NVRAM
VxWorks defines an interface for reading and writing to a persistent storage area.
This interface is called the non-volatile memory library. VxWorks uses this library
to store boot information.
Early in the development process, it is recommended that you include
nullNvRam.c in sysLib.c. When you finalize your BSP, it is best to replace
nullNvRam.c with a more appropriate interface so that boot information can be
kept after the board is powered off.
The driver files in target/src/drv/mem/ include generic versions of NVRAM
support routines. These files include:
nvRam.c—supports NVRAM that is addressed as if it were RAM (for example,
battery-backed RAM)
nvRamToFlash.c—supports target systems with flash but no other
non-volatile memory
nullNvRam.c—supports target systems with no electronically programmable
non-volatile memory
Each of the standard files provides the required routines sysNvRamSet( ) and
sysNvRamGet( ), and can be #included in sysLib.c. The nvRamToFlash.c version
provides read and write wrappers that call the flash memory routines
sysFlashGet( ) and sysFlashSet( ). If nvRamToFlash.c is used, the sysFlashGet( )
and sysFlashSet( ) routines must be provided by the BSP. However, if the nvRam.c
version works for your board, no additional work is necessary.
If a more complex system is required or if the boards NVRAM does not work with
the provided routines, NVRAM support can be provided by the BSP. In many
BSPs, the required routines are put in the sysLib.c file. However, the preferred
method is to put NVRAM support in a separate file called sysNvRam.c. In either
case, the routines sysNvRamSet( ) and sysNvRamGet( ) must be provided to
prevent undefined references when building VxWorks. If it is necessary to write
custom versions of these routines, the routines from the standard libraries in
target/src/drv/mem/ can be used as a reference. If necessary, additional NVRAM
support routines can be provided in the BSP as well.
NOTE: Wind River does not recommend using nullNvRam.c in your final BSP
unless it is the only option available for your target system.