Versions Compared

Key

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

RAM Disks and ROM Disks

NSH mkrd command

The typical way to create a RAM disk is to use the NuttShell (NSH) mkrd command. The syntax of that command is:

...

  • Allocate kernel-space memory using kmm_malloc() of size <nsectors> times <sector-size>,
  • Zero the allocated memory, then
  • Call the OS-internal function ramdisk_register() to create the RAM disk.

NSH ROMFS /etc Support

A ROM disk is a block device created on a read-only file system image in FLASH or other ROM.
There is no NSH command that can be used to recreate a ROM disk. This capability can be enabled for NSH using the CONFIG_NSH_ROMFSETC as described in the section discussing NSH start-up scripts in the NSH User Guide.

Any application can create a ROM disk, however, using the boardctl() BOARDIOC_ROMDISK command.

Creating RAM Disks in Board Bring-Up Logic

RAM disks maybe created by your board-specific initialization logic that runs in supervisor mode. The board initialization function would contain logic something like the following:

...

or, equivalently, this could all be replaced with a call to the OS internal function mkrd().

Creating ROM Disks in Board Bring-Up Logic

NOTE: Currently, the romdisk_register() function is only available within the OS. There is currently logic under apps/ that violates the portable POSIX OS interface by calling romdisk_register() directly. The correct way for an application to create a ROM disk is via the boardctl(BOARDIOC_ROMDISK) command as described above. Calling romdisk_register() directly is not only a violation of the NuttX portable interface, but also cannot be done in PROTECTED or KERNEL build modes.

...