Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor10465221046522 Using the RAM Disk Driver Anchor10465231046523To use the RAM disk driver, two files, in addition to the generic FS files, must be included in the build: Anchor10465241046524

  • fs_dev_ramdisk.c.

...

  • fs_dev_ramdisk.h.

...

The file fs_dev_ramdisk.h must also be #included in any application or header files that directly reference the driver (for example, by registering the device driver). The following directory must be on the project include path: Anchor10465271046527

  • \Micrium\Software\uC-FS\Dev\RAMDisk

...

A single RAM disk is opened as shown in Listing - Opening a RAM disk volume. The file system initialization (FS_Init()) function must have previously been called.

Anchor10478931047893ROM/RAM characteristics and performance benchmarks of the RAM disk driver can be found in section 9-1-1 “Driver Characterization” on page 113 Driver Characterization. For more information about the FS_DEV_RAM_CFG structure, see section D-4 “FSFS_DEV_RAM_CFG” on page 488CFG.anchor


Code Block

...

#define
HTML Table
summary
classCode_Listing
Table Row (tr)
Table Cell (td)
Anchor
10479021047902
language

...

#define
            512      (1)
#define  APP_CFG_FS_RAM_NBR_SECS     (48 * 1024)
static

static  CPU_INT32U  App_FS_RAM_Disk[APP_CFG_FS_RAM_SEC_SIZE * APP_CFG_FS_RAM_NBR_SECS / 4];

CPU_BOOLEAN  App_FS_AddRAM (void)
{ FS_ERR err;

{
    FS_ERR          err;
    FS_DEV_RAM_CFG  cfg;

    FS_DevDrvAdd((FS_DEV_API *)&FSDev_RAM,
/* (2) */
           (2)
                 (FS_ERR     *)&err);
if

    if ((err != FS_ERR_NONE) && (err != FS_ERR_DEV_DRV_ALREADY_ADDED))
{ return
 {
        return (DEF_FAIL);
}

    }
    ram_cfg.SecSize =  APP_CFG_FS_RAM_SEC_SIZE;
/* (3) */
      (3)    
    ram_cfg.Size    =  APP_CFG_FS_RAM_NBR_SECS;

    ram_cfg.DiskPtr = (void *)&App_FS_RAM_Disk[0]
/* (4) */
;

													 (4)    
    FSDev_Open((CPU_CHAR *)
“ram
"ram:0:
”, /* (a) */ (void
",                       (a) 
               (void     *)&ram_cfg,
/* (b) */
                       (b) 
               (FS_ERR   *)&err);
if (err !=
    
    if (err != FS_ERR_NONE)
{ return
 {
        return (DEF_FAIL);
} /* (5) */

    }
                                                     (5)        
    FSVol_Open((CPU_CHAR         *)
“ram
"ram:0:
”, /* (a) */ (CPU_CHAR *)“ram:0:”, /* (b) */
",              (a) 
               (CPU_CHAR         *)"ram:0:",              (b)  
               (FS_PARTITION_NBR  ) 0,
/* (c) */ (FS_ERR
                    (c) 
               (FS_ERR           *)&err);
switch
     
    
    switch (err)
{ case
 {
        case FS_ERR_NONE:

             APP_TRACE_DBG(("    ...opened volume (mounted).\r\n"));
break; case

             break;
        case FS_ERR_PARTITION_NOT_FOUND:            /* Volume error.
*/
     */
             APP_TRACE_DBG(("    ...opened device (not formatted).\r\n"));

             
             FSVol_Fmt("ram:0:", (void *)0, &err);
/* (6) */ if (err !=
     (6)    
             if (err != FS_ERR_NONE)
{
 {
                APP_TRACE_DBG(("    ...format failed.\r\n"));
return

                return (DEF_FAIL);
} break; default: /* Device error. */

             }
             break;
        default:                                      /* Device error.     */
             APP_TRACE_DBG(("    ...opening volume failed w/err = %d.\r\n\r\n", err));
return

             return (DEF_FAIL);
} return

    }
    return (DEF_OK);

}
cpp
titleListing - Opening a RAM disk volume
linenumberstrue
#define  APP_CFG_FS_RAM_SEC_SIZE
512 /* (1) */
Anchor
10479031047903
Anchor
10479041047904
Anchor
10479051047905
Anchor
10479061047906
Anchor
10479071047907
Anchor
10479081047908
Anchor
10479091047909
Anchor
10479101047910
Anchor
10479111047911
Anchor
10479121047912
Anchor
10479131047913
Anchor
10479141047914
Anchor
10479151047915
Anchor
10479161047916
Table Row (tr)
Table Cell (td)
Anchor
10479181047918
Anchor
10479191047919
Anchor
10479201047920
Anchor
10479211047921
Anchor
10479221047922
Anchor
10479231047923
Anchor
10479241047924
Anchor
10479251047925
Anchor
10479261047926
Anchor
10479271047927
Anchor
10479281047928
Anchor
10479291047929
Anchor
10479301047930
Anchor
10479311047931
Anchor
10479321047932
Anchor
10479331047933
Anchor
10479341047934
Anchor
10479351047935
Anchor
10479361047936
Anchor
10479371047937
Anchor
10479381047938
Anchor
10479391047939
Anchor
10479401047940
Anchor
10479411047941
Anchor
10479421047942
Anchor
10479431047943
Anchor
10479441047944
Anchor
10479451047945
Anchor
10479461047946
Anchor
10479471047947
Anchor
10479481047948
Anchor
10479491047949

...


...

Panel

(1) The sector size and number of sectors in the RAM disk must be defined. The sector size should be 512, 1024, 2048 or 4096; the number of sectors will be determined by your application requirements. This defines a 24-MB RAM disk (49152 512-B sectors). On most CPUs, it is beneficial to 32-bit align the RAM disk, since this will speed up access.

...

(2) Register the RAM disk driver FSDev_RAM.

...

(3) The RAM disk parameters—sector size, size (in sectors) and pointer to the disk—should be assigned to a FS_DEV_RAM_CFG structure.

...

(4) FSDev_Open() opens/initializes a file system device. The parameters are the device name (

...

4a) and a pointer to a device driver-specific configuration structure (

...

4b). The device name (

...

4a)

...

is composed of a device driver name (“ram”), a single colon, an ASCII-formatted integer (the unit number) and another colon.

...

(5) FSVol_Open() opens/mounts a volume. The parameters are the volume name (5a), the device name (5b) and the partition that will be opened (5c). There is no restriction on the volume name (5a); however, it is typical to give the volume the same name as the underlying device. If the default partition is to be opened, or if the device is not partition, then the partition number (5c) should be zero.

...

(6) FSVol_Fmt() formats a file system volume. If the RAM disk is in volatile RAM, it have no file system on it after it is opened (it will be unformatted) and must be formatted before a volume on it is opened.

...

10465841046584If the RAM disk initialization succeeds, the file system will produce the trace output as shown in Figure 11-1 in Figure - RAM disk initialization trace output (if a sufficiently high trace level is configured). See section E-9 “Trace Configuration” on page 507 Trace Configuration about configuring the trace level.anchor

Panel

...

borderWidth

...

0

...

titleFigure - RAM disk initialization trace output

...

Image Added