eCos Reference Manual
Prev |  | Next

# Chapter 27. The eCos FLASH Library

The FLASH library is an optional part of eCos, and is only applicable to some platforms.

The eCos FLASH library provides the following functionality:

1. Identifying installed device of a FLASH family.

2. Read, erasing and writing to FLASH blocks.

3. Validating an address is within the FLASH.

4. Determining the number and size of FLASH blocks.

There are two APIs with the flash library. The old API is retained for backwards compatibility reasons, but should slowly be replaced with the new API which is much more flexible and does not pollute the name space as much.

# Notes on using the FLASH library

FLASH devices cannot be read from when an erase or write operation is active. This means it is not possible to execute code from flash while an erase or write operation is active. It is possible to use the library when the executable image is resident in FLASH. The low level drivers are written such that the linker places the functions that actually manipulate the flash into RAM. However the library may not be interrupt safe. An interrupt must not cause execution of code that is resident in FLASH. This may be the image itself, or RedBoot. In some configurations of eCos, ^C on the serial port or debugging via Ethernet may cause an interrupt handler to call RedBoot. If RedBoot is resident in FLASH this will cause a crash. Similarly, if another thread invokes a virtual vector function to access RedBoot, eg to perform a `diag_printf()` a crash could result.

Thus with a ROM based image or a ROM based Redboot it is recommended to disable interrupts while erasing or programming flash. Using both a ROMRAM or RAM images and a ROMRAM or RAM RedBoot are safe and there is no need to disable interrupts.

Prev | Home | Next
FLASH Library | Up | Danger, Will Robinson! Danger!