You cannot erase one or to bytes in flash.When you modify you have to erase the entire block.
First read a flash block into a array of 32 bytes.
Make your changes in that array.
Erase the flash block you last read and then rewrite the flash with the modified array.
I use these functions to write and read from flash.I found these functions on internet.
I know that this thread is rather old, but I think that for this question an observation should be made.
Using of one or more flash memory sector is widely used in microcontroller without EEPROM on board to store information that can be changed and should be available between power on. In order to emualate an EEPROM usually we can define an array of proper size, then the first step is to copy inside the array all the needed flash data then perform the data changing inside the array, perform the flash erase and then write back the data array to the flash.
This is the common usage but it deserve a real danger that it is good to know. Imagine what could happen if before writing the flash, after it has been erased, for some reason the micro-controller should reset itself, for example due to a power failure. All the data previously stored inside the flash sector will be definitely lost. This is the real pitfall of this method. So before approaching this way pay more attention to this fact. This means that the way can be used but some countermeasures should be taken, as simple example one may plan to reserve a location of the flash that shoud have always a know value different from 0, if for some reason this location are equal to 0 at the microcontroller startup you can run a disaster recovery procedure that in its simplest form may be to copy the default values from another flash sector to the flash sector used to emulate the EEPROM behavior. This is a very simple approach to gain some security against the drawback above described.
Just my 2 Cents.
Bye