devf-ram

Simulate flash filesystem using RAM memory

Note: You must be root or have the right abilities to start this driver.

Syntax:

devf-ram [-AaDElRrVv] [-b priority] [-d log_method] [-e arg] [-f verifylevel]
         [-i arrayindex[,partindex]] [-L limit] [-m mountover] [-P lock_mode]
         [-p backgroundpercent[,superlimit]] [-S sector_erase_latency]
         [-s base[,wsize[,aoffset[,asize[,usize[,bwidth[,ileave]]]]]]]
         [-T max_erase_diff] [-t threads] [-u update] [-w buffersize]
         [-x type]

Runs on:

QNX Neutrino

Options:

-A
When registering the path names for the partitions with resmgr_attach(), use the _RESMGR_FLAG_AFTER flag to force the path to be resolved after others with the same pathname at the same mountpoint.
-a
Don't automount filesystem partitions present on the media. If you specify both the -a and -R options, the driver ignores the -R option.
-b priority
Enable background reclaim at the specified priority. By default, background reclamation is disabled.
-D
Enable automatic detection of error-correcting code (ECC) mode. If you specify this option, you don't need to specify -x.
Note: Don't mix ECC-enabled partitions and ECC-disabled partitions; the driver doesn't support this.
-d log_method
Control the logging from the flash driver. The possible values for log_method are:
  • 0 — log to stdout (the default)
  • 1 — log to slogger2
  • 2 — log to both stdout and slogger2
-E
Don't daemonize. If the driver detects a corrupt filesystem, the exit status is that filesystem's partition number plus 1.
-e arg
Only enumerate the flash partitions, instead of doing a full scan and mount:
  • If arg is an integer, the flash driver automounts all partitions with a partition number less than or equal to arg.

    For example, assume we have a flash layout as follows:

    • /dev/fs0p0 — raw
    • /dev/fs0p1 — formatted
    • /dev/fs0p2 — formatted
    • /dev/fs0p3 — formatted

    If you start the driver with -e 1, the driver creates all the raw entries in /dev, but mounts only /dev/fs0p1 (/dev/fs0p0 is raw, so it's never mounted, regardless of the -e option).

  • If arg is a string, the driver interprets it as a colon-separated list of exact paths to mount, if found.
-f verifylevel
Simulate flash verify; provided only for syntax compatibility with real flash hardware (default=0, 0=none, write=1, erase=2, all=3).
-i arrayindex[,partindex]
Starting socket index and first partition index; 0 ≥ index ≥15. The default is 0,0. Use this to give multiple drivers unique IDs. The -i option is just a suggestion for the resource database manager; the selected indexes can be larger.
-L limit
The number of retries to make if the physical flash erase function for a unit fails. The default is 0.
-l
List the available flash databases and exit.
-m mountover
Override the mountpoints assigned to a file system that are formatted with an empty (i.e., flashctl -p/dev/fs0p0 -e -f -n "") mountpoint. The mountover argument can include two %X format specifiers (like those for printf()) that are replaced by the socket index and the partition index.
Note: The -m option doesn't override a mountpoint specified with mkefs.
-P lock_mode
(QNX Neutrino 6.6 or later) Set the protection mode for Spansion-compatible devices:
  • 0 — no lock (the default)
  • 1 — persistent lock mode
  • 2 — dynamic lock mode
-p backgroundpercent[,superlimit]
Set the background-reclaim percentage trigger (stale space over free space) and, optionally, the superseded extent limit before reclaim. The default is 100,16.
-R
Mount any automount filesystems as read-only. This option doesn't affect raw partition mounts, and it has an effect only at startup and initialization. Any subsequent mounting (with either flashctl or mount) ignores the -R option. If you also specify the -a option, the driver ignores the -R option.
-r
Enable fault recovery for dirty extents, dangling extents, and partial reclaims.
Note: You should always specify the -r option unless you're trying to debug an issue concerning flash corruption.

If you don't specify -r, and a power failure occurs, the following can happen:

  • You can waste space. If an erasure was happening when the power was cut off, there will be some “dangling” extents (i.e. marked for deletion, but not actually deleted). If you specify the -vv option, the driver prints dangle for every dangling extent found. These extents will continue to occupy space forever, until they're deleted. Using the -r option will cause them to be reclaimed.
  • The system may be marked as read-only. If the driver detects an error in the structure of the filesystem, and you haven't specified the -r option, the driver marks the partition as read-only, so that it can't be further damaged.
  • If a reclaim operation is interrupted by a power loss, the spare block may be unusable. In this case, if you specify the -vv option, the driver prints partial to the console. The partition is still read-write, but reclaims are turned off; if you continue to overwrite files, you'll eventually fill the filesystem with stale data.
-S sector_erase_latency
(QNX Neutrino 6.6 or later) Set the simulated sector erase latency in milliseconds (max = 10000).
-s base[,wsize[,aoffset[,asize[,usize[,bwidth[,ileave]]]]]]
Set socket options, normally the base physical address, window size, array offset, array size, unit size, bus width, and interleave. The format is left flexible for socket services with customized drivers.

The arguments are:

base
Physical base address of the flash part. This value is board-specific.
Note: For the devf-ram utility, the base argument carries a special meaning:
0
Allocate system memory.
Nonzero
Use the exact physical address. You must exercise caution here. See the caveats below.
wsize
Size of the physically contiguous flash part.
aoffset
For SRAM, the offset from the base address to the start of the flash array.
asize
For SRAM, the size of the flash array. The default is equal to wsize.
usize
The size of a physical erase sector. For SRAM, this number can be any power of two. 64 KB should be the minimum, for performance reasons.
bwidth
The total width of the data bus, as seen from the microprocessor's perspective. This is the width of one simulated flash chip multiplied by the interleave. This value must be a power of 2 (1, 2, 4, or 8).
ileave
The number of simulated flash chips arranged on the data bus. This value must be a power of 2 (1, 2, 4, or 8).

You can specify the base physical address, sizes, and offset in octal (0777), hexadecimal (0x1ff), or decimal (511). The sizes must be a power of two, and you can specify them with any of the following suffixes:

  • (nothing) — bytes
  • k — kilobytes
  • m — megabytes
Note: On ARM targets, devf-ram can't resize the shared object /dev/shmem/fs*. If you need to restart devf-ram with a new size, first unlink the old shared object:
rm /dev/shmem/fs*
-T max_erase_diff
(QNX Neutrino 7.0 or later) Set the threshold value (maximum erase count − minimum erase count in a partition) to trigger wear-levelling. The default value is two times the sector number in the partition. Typically, for very large partitions containing more than 1000 sectors, you should use this option to specify a threshold (for example, 1000) to make the sector erasure counts more evenly distributed across the entire partition.
-t threads
The number of threads. The minimum is 1, the default is 2, and the maximum is 100. Extra threads increase performance when background reclaiming is enabled (with the -b option) and when multiple chips and/or spare blocks are available.
-u update
Specify the update level for timestamps. POSIX specifies that timestamps be kept when you access, create, or modify a file. FFSv3 is documented as not supporting the access timestamp, in order to reduce wear on the hardware.

The values for update are:

  • 0 — don't update the modification time for files (the default).
  • 1 — update the modification time for files according to the POSIX rules.
  • 2 — update the modification time for files, as well as for the parent directory.
Note: The -u2 option is very, very expensive and will cause many reclaims because the time updates have to flow right up to the root directory, so one file update may cause many directory updates.
-V
Display filesystem and MTD version information, and then exit.
-v
Be verbose; specify additional v characters for more verbosity. For more information, see Verbose output in the entry for devf-generic.
-w buffersize
Write (append) buffer size in bytes. The default buffersize is 512. Using a larger write-buffer prevents the creation of very small extents, reducing overhead. If buffersize is 0, appending is disabled.
-x type
Enable software ECC mode. Specify type as 1 for 64-byte alignment ECC, or 2 for 32-byte.
Note: Don't mix ECC-enabled partitions and ECC-disabled partitions; the driver doesn't support this.

Description:

The devf-ram manager simulates flash filesystem in RAM using the following default filenames (you can use the -i option to change the ID, n, that's appended to /dev/fs):

/dev/fsn
Default mountpoint for socket n.
/dev/fsnp0
Raw access for socket n, partition 0.
mountpoint
Flash filesystem mountpoint for socket n, partition 0 with transparent decompression.

You can specify the mountpoint above with the mount attribute of the mkefs command, and override it with the -n option to flashctl. By default, it's /fsnp0.

Abilities:

The devf-ram driver may require the following abilities:

Use secpolmonitor to determine which abilities devf-ram is using on your specific system.

For more information on abilities, see procmgr_ability() in the C Library Reference.

Examples:

Start devf-ram with a 16 MB partition:

devf-ram  -s0,16m

Start devf-ram and automatically mount the flash filesystem partitions, with an initial fault recovery process, most POSIX semantics enabled and background reclaim at priority 5 (default size: 1 MB):

devf-ram -r -u2 -b5 &

Create a 32 MB flash partition, allocated from system RAM, with a 64 KB unit (sector) size:

devf-ram -s0,32m,,,64k  -v -r

Create a 128 MB flash partition in system RAM, with large block sizes (to speed formatting):

devf-ram -s0,128m,,,512k -v -r

Create a 4 MB partition from system RAM:

devf-ram -s0,4m,,,64k -v -r
Note: You must format and erase a devf-ram partition before you can mount the flash filesystem. See the caveats below.
Note: If you specify a block size in your buildfile for DRAM-based flash filesystems, limit the size to the default, which is 64 KB.

Caveats:

Although the flash filesystem supports most POSIX semantics, some functionality isn't implemented in order to keep the driver simple and efficient. The unsupported POSIX semantics include:

QNX Neutrino flash filesystem version 3 no longer provides built-in decompression. The flash filesystem's decompression functionality has moved into the inflator resource manager. You should now use the deflate utility to compress files.

Performance might be slow when multiple writers are writing randomly to a shared file or to a shared directory (e.g., using unlink or rename). In these cases, the offset pointers have to be rewound for every access. There's no performance penalty when appending to a file, or when creating files with open(O_CREAT), mkdir, mknod, or link.

Don't try to create a devf-ram partition at the address of a real flash memory. You may get an error message: Unable to properly identify any flash devices.

Don't try to create a devf-ram partition (e.g., using nonzero value for base argument) at the address of physical memory that is in use. It may destroy applications and crash the operating system. The only use for specifying such nonzero base is to create a flash filesystem for board specific memory (e.g., SRAM).

You must format and erase a devf-ram partition before you can mount the flash filesystem. For example:

devf-ram -s0,16m
flashctl -p /dev/fs0p0 -e -f -m

If there's insufficient RAM, when you try to create an nM size partition with -s0 option, the devf-ram driver returns without an error message. The partition isn't created.