You can write to DataFlash while executing from either Bootflash or ProgramFlash, or you can write to either Bootflash or ProgramFlash while executing from the other one, but not within the same bank, as stated. You don't have to be executing in RAM, but you cannot be executing in the flash bank that you are trying to erase/program.