2015-08-11 09:26 AM
Im having an issue erasing pages of flash. During my bootloader application while receiving a block of data I erase the page and then write the data. During testing I have the messaging protocol setup to just read the data into ram and erase the page, without writing, an attempt to simplify debugging. The problem is not all pages are erased.
My bootloader resides at 0x0800000 with all the proper precautions regarding the interrupt table. Prior to testing the erase functionality the bootloader was function fine, included passing off to an application loaded previously. The app reside at 0x08001000.During erase testing, the bootloader attempts to erase the addresses 0x08001000, 0x08001400, 0x08001C00... 0x0800AC00.Only a small handfull of the pages are actually erased.What I've done to debug. I have verified that the pages are not write protected, I have also monitored the status register after each erase cycle. The status indicate EOP with no other issues.I have the flash latency set to 2. The unlock procedure has been verified.I have added additional NOP's after the register commands to erase a page with no result.The only thing of note is that the same pages are affected.I have also verified that my bootloader resides completely within 0x08000000 and 0x08001000.below is my page erase function:uint8_t erasePage(uint32_t pageAddress){ uint32_t *address; waitForOperation(); //set page erase bit FLASH->CR |= FLASH_CR_PER; __ASM volatile (''nop''); __ASM volatile (''nop''); __ASM volatile (''nop''); __ASM volatile (''nop''); FLASH->AR |= pageAddress; __ASM volatile (''nop''); __ASM volatile (''nop''); __ASM volatile (''nop''); __ASM volatile (''nop''); FLASH->CR |= FLASH_CR_STRT; waitForOperation(); FLASH->CR &= FLASH_CR_PER; __ASM volatile (''nop''); __ASM volatile (''nop''); __ASM volatile (''nop''); __ASM volatile (''nop''); //verify erase for(address = pageAddress; address < pageAddress + 1024; address += 4) { if(*address != 0xFFFFFFFF) { return 1; } } return 0;}I must be missing something non trivial. Any ideas are welcomed.Thanks #stm32 #flash #f1032015-08-11 10:28 AM
FLASH->AR |= pageAddress; // Won't this cause bits to stick all high eventually, perhaps you want to mask the bits
''Only a small handful of the pages are actually erased.''What does this mean in reality? Which pages are erased and which aren't, is there some pattern to it?2015-08-11 10:35 AM
WOW! What a ridiculous error! I feel the need to apologize for wasting your time on that one. Sorry. Too much coffee today.
2015-08-11 10:58 AM
No worries, some times it's hard to see the wood for the trees when you've been staring at it too long.