IMFS usage

Chris Johns chrisj at
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 ...

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));

    /* Create a mount point. */
    if (mkdir(mpoint, S_IRWXU | S_IRWXG | S_IRWXO)) {
        syslog ("mkdir %s failed: %s", mpoint, strerror(errno));

    /* Mount it. */
    if (mount (rd, mpoint,
               "rfs", RTEMS_FILESYSTEM_READ_WRITE, NULL) < 0) {
        syslog ("mount: %s", strerror(errno));

Note, you need to configure BDBUF (block device buffers) with something small:

#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE          (2 * 1024 * 1024)

The cache will be in the heap somewhere. The cache helps avoid the driver
overhead for small accesses to the file system.


More information about the users mailing list