This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32 flash erase lockup problem

This is a question to anyone who is expert in IAP programming.
I am experimenting with relocating code on a Keil MCBSTM32 board.
I have taken the "measure" example and have modified it so that through the menu system I can make a copy of it into the second part of the Flash starting at 0x8010000.
During the copy I modify the IVT so that they all point into the relocated code. Then I can jump into the the modified image resetting the IVT offset to the new position as I go.
This looks good as everything seems to run okay and it can report that its start address and main address is where I expect it to be.
Now here is where it goes wrong. I try to erase the original image ( from the new running image ) and it all locks up. Also if I start again and switch to the new image and back to the old one, the old image can not erase the new one. It can do this if I do not do the jump in and out again.
It locks up during the erase sequence during the Control register is set to STRT. e.g. FLASH->CR|= CR_PER_Set; FLASH->AR = Page_Address; FLASH->CR|= CR_STRT_Set; <--- locks here
I have checked that the CR has not got the lock bit set and also done unlocks before hand just in case.
At the moment I can think of two reasons why this may be.
1) There is still code ( maybe interupts ) running in those pages and the FPEC dies.
2) The FPEC thinks there is still code running in there and dies.
Any one got any ideas, it does not matter how off the wall they are. I'm stuck.

0