Chapter 62. FLASH I/O devices

It can be useful to be able to access FLASH devices using the generic I/O infrastructure found in CYGPKG_IO, and the generic FLASH layer provides an optional ability to do so. This allows the use of functions like cyg_io_lookup(), cyg_io_read(), cyg_io_write() etc.

Additionally it means that, courtesy of the “devfs” pseudo-filesystem in the file I/O layer (CYGPKG_IO_FILEIO), functions like open(), read(), write() etc. can even be used directly on the FLASH devices.

Overview and CDL Configuration

This package implements support for FLASH as an I/O device by exporting it as if it is a block device. To enable this support, the CDL option titled “Provide /dev block devices”, also known as CYGPKG_IO_FLASH_BLOCK_DEVICE, must be enabled. (There is also a legacy format alternative which is now deprecated).

There are two methods of addressing FLASH as a block device:

  1. Using the FLASH Information System (FIS) - this is a method of defining and naming FLASH partitions, usually in RedBoot. This option is only valid if RedBoot is resident and was used to boot the application. To reference FLASH partitions in this way, you would use a device name of the form /dev/flash/fis/partition-name, for example /dev/flash/fis/jffs2 to reference a FIS partition named JFFS2.

    The CDL option CYGFUN_IO_FLASH_BLOCK_FROM_FIS must be enabled for this support.

  2. Referencing by device number, offset and length - this method extracts addressing information from the name itself. The form of the device would be /dev/flash/device-number/offset[,length]


    This is a fixed number allocated to identify each FLASH region in the system. The first region is numbered 0, the second 1, and so on. If you have only one FLASH device, it will be numbered 0.


    This is the index into the FLASH region in bytes to use. It may be specified as decimal, or if prefixed with 0x, then hexadecimal.


    This field is optional and defaults to the remainder of the FLASH region. Again it may be specified in decimal or hexadecimal.

    Some examples:


    This defines a block device that uses the entirety of FLASH region 0.


    This defines a block device which points inside FLASH region 1, starting at offset 0x20000 (128Kb) and extending for 64Kb.


    This defines a block device which points inside FLASH region 0, starting at offset 64Kb and continuing up to the end of the device.

    Obviously great care is required when constructing the device names as using the wrong specification may subsequently overwrite important areas of FLASH, such as RedBoot. Using the alternative via FIS names is preferable as these are less error-prone to configure, and also allows for the FLASH region to be relocated without requiring program recompilation.

Documentation license for this page: Open Publication License