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
Additionally it means that, courtesy of the
“devfs” pseudo-filesystem in the file I/O layer
CYGPKG_IO_FILEIO), functions like
write() etc. can even be used directly
on the FLASH devices.
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:
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_FISmust be enabled for this support.
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.
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.