Re: Bootloader - erase flash memory

From: jetmarc (jetmarc_at_hotmail.com)
Date: 11/17/04


Date: 17 Nov 2004 04:02:07 -0800


> how you can erase the flash with assembly code?
> What exactly is the principle of erasing memory? Is it to set every bit to
> zero or exactly does that mean?

Erasing flash means setting every bit to 1. Programming flash means to
set an arbitrary number of bits to 0. Bits cannot be "programmed" from
0 back to 1, except by erasing (possible only for a whole page at once).

So, to write your firmware into the flash, you have to first erase the
flash, and then program your firmware.

To avoid accidential writes, most flash chips need a special programming
sequence (and a special erase sequence as well). Usually the sequence
begins with writing 0xAAAA to address 0xAAAA, followed by writing 0x5555
to address 0x5554, and then writing a command (eg "ERASE") to address
0xAAAA. These writes are purely virtual and dont overwrite your firmware
addresses 0x5554 or 0xaaaa. They make the flash listen to your command.

Read the data*** of your flash, or copy off a working flash driver to
make your project going.

Marc