Hi,
I'm afraid this is too high-level description. It would require deeper investigation. First, I would check if you can successfully receive the data, then I would check how the flash functions are called (if parameters are correct) and then check what happens and what kind of error code is returned by flash functions. Without these details, I'm not able to help.
Regards,
Lukas