Embedded Systems Firmware Demystified

Flash memory is quickly becoming the standard non-volatile memory choice in embedded systems. Flash memory s versatility, price per byte, and density fall in the right range to make it a very good choice for most new embedded systems projects. Flash memory is non-volatile and in-system-writable memory. In other words, the content of the device remains intact even after power is removed. There are mechanisms, however, available to the firmware that support the ability to write and re-write data to the flash memory device.
Interfacing to flash devices comes with its share of headaches. Reading from flash memory is the same as reading from regular memory, but that s where the similarity ends. Flash devices vary in size from about 64KB to 8MB and densities increase regularly. Flash devices are broken up into sectors or blocks of memory space. Each sector is an erasable unit. When a sector is erased, the bits of data within that sector are all set to 1 (bytes = 0xff). Writing to the flash device (after it has been erased) is the process of changing a bit that is currently a 1 to a 0. After the bit is 0, the only way it can be set back to 1 is by erasing the entire sector that contains the byte. Both the erase and write operations involve a complicated handshake between the processor and the memory device.
On top of all of this, for most flash devices, while an operation...