IMFS usage
Chris Johns
chrisj at rtems.org
Sun May 20 21:14:01 UTC 2018
On 18/5/18 4:09 am, Matthew J Fletcher wrote:
>
>> The IMFS uses malloc for disk blocks so that might have to be addressed for
> your use cases.
>
> Is there any way to pass in / override the block allocator ?
>
Not that I know of with the IMFS.
Another way to have a RAM disk in a specific area of memory is to use the RAM
disk driver and a file systems. If a project has the web-server running I create
a RAM disk this way and use the RFS for the file system and hold all the web
pages plus any uploads.
The RFS was developed for the MMS satellites to create a specialized volatile
memory disk that had some unusual specific physical characteristics such as a
weird block size.
To create a RAM disk see ...
https://docs.rtems.org/doxygen/branches/master/group__rtems__ramdisk.html#gac6c99eed9f3b92bb4cf5184b25972e65
Note, the 'area_begin' argument lets you specify the location.
To format with the RFS ...
void mount_ram_disk (const char* rd, const char* mpoint)
{
/* Format the ram disk. */
rtems_rfs_format_config rfs_config;
memset (&rfs_config, 0, sizeof (rtems_rfs_format_config));
if (rtems_rfs_format (rd, &rfs_config) < 0) {
syslog ("RFS format of ram disk failed: %s", strerror (errno));
return;
}
/* Create a mount point. */
if (mkdir(mpoint, S_IRWXU | S_IRWXG | S_IRWXO)) {
syslog ("mkdir %s failed: %s", mpoint, strerror(errno));
return;
}
/* Mount it. */
if (mount (rd, mpoint,
"rfs", RTEMS_FILESYSTEM_READ_WRITE, NULL) < 0) {
syslog ("mount: %s", strerror(errno));
return;
}
}
Note, you need to configure BDBUF (block device buffers) with something small:
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
#define CONFIGURE_SWAPOUT_TASK_PRIORITY 123
#define CONFIGURE_BDBUF_READ_AHEAD_TASK_PRIORITY 123
#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (2 * 1024 * 1024)
#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 0
#define CONFIGURE_BDBUF_MAX_WRITE_BLOCKS 512
The cache will be in the heap somewhere. The cache helps avoid the driver
overhead for small accesses to the file system.
Chris
More information about the users
mailing list