分类: 嵌入式
2010-06-18 21:31:56
RAM-disk File system
Q: When I use the RAM-disk as supplied with DosFS2 (configured using the item Hardware->Peripherals->RAM Disk with MSDOS filesystem) it is formatted every time I startup, even if I assign a seperate memory area.
A: Using the device provided as-is this is right. During the initialisation of the device it is formatted. This can be changed by replacing/adding a number of lines to the component INCLUDE_RAM_DISK in the file 10dosfs2.cdf in target\config\comps\vxworks. The definition of INIT_RTN should be changed to:
INIT_RTN { void * cbio ; int ramDiskTestFd = -1;\
cbio=ramDiskDevCreate(RAM_DISK_MEM_ADRS,512,17,RAM_DISK_SIZE/512,0);\
if(cbio!=NULL){ \
dosFsDevCreate(RAM_DISK_DEV_name,cbio,RAM_DISK_MAX_FILES,NONE);\
if(RAM_DISK_FORMAT_ALWAYS == FALSE){ \
ramDiskTestFd = open(RAM_DISK_DEV_name, 2, 0);\
} \
if((RAM_DISK_FORMAT_ALWAYS != FALSE)||(ramDiskTestFd == -1)){\
dosFsVolFormat(cbio,DOS_OPT_BLANK | DOS_OPT_QUIET, NULL);\
} \
if(ramDiskTestFd != -1){ \
close(ramDiskTestFd);\
} \
}}
Also a configuration parameter should be added, called RAM_DISK_FORMAT_ALWAYS. To define this parameter the Parameter-definition has to be added:
Parameter RAM_DISK_FORMAT_ALWAYS
{
name Format always, even if already formatted
TYPE bool
DEFAULT FALSE
}
When this parameter is set to TRUE the disk is always formatted, just like the original situation. When this parameter is set to FALSE (the default situation) the disk is only formatted when the open of the RAM-disk root does not succeed.