2015-06-24 05:28 AM
I am working with the
Discovery development board
STM32F407 microcontroller and building using Eclipse/GNU. I trying to reprogram sector 0 (address range: 0x0800 0000 - 0x0800 3FFF; 16 Kbytes total) from within my application, but 6 memory locations does not seem to program properly:
Programming failed at address 0x8000004. Value we would like to write 0x05. Value actually written 0x01Programming failed at address 0x8000401. Value we would like to write 0xFC. Value actually written 0x48Programming failed at address 0x8000403. Value we would like to write 0x20. Value actually written 0x00Programming failed at address 0x8000404. Value we would like to write 0x5D. Value actually written 0x50Programming failed at address 0x8000408. Value we would like to write 0x61. Value actually written 0x00Programming failed at address 0x8000409. Value we would like to write 0x06. Value actually written 0x00All my calls to HAL_FLASH_Program returns HAL_OK. Here are excerpts from my .dump file:08000000 <__startUpVector>: 8000000: 2001fc00 andcs pc, r1, r0, lsl #24 8000004: 08000401 stmdaeq r0, {r0, sl}void __attribute__ ((section(''.jumpToApplication''),used)) __jumpToApplication(void){ JMP(0x08010004); 8000400: 4b01 ldr r3, [pc, #4] ; (8000408 <__jumpToApplication+0x8>) 8000402: 469f mov pc, r3 8000404: 4770 bx lr 8000406: bf00 nop 8000408: 08010004 stmdaeq r1, {r2}I'd be most grateful for any help on this matter. Thanks in advance.2015-06-24 05:39 AM
It seems the sector is not erased properly:
Programming failed at address 0x8000004. Value before programming 0x01. Value we would like to write 0x05. Value actually written 0x01Programming failed at address 0x8000401. Value before programming 0x4B. Value we would like to write 0xFC. Value actually written 0x48Programming failed at address 0x8000403. Value before programming 0x46. Value we would like to write 0x20. Value actually written 0x00Programming failed at address 0x8000404. Value before programming 0x70. Value we would like to write 0x5D. Value actually written 0x50Programming failed at address 0x8000408. Value before programming 0x04. Value we would like to write 0x61. Value actually written 0x00Programming failed at address 0x8000409. Value before programming 0x00. Value we would like to write 0x06. Value actually written 0x00What could cause the FLASH_Erase_Sector-function to fail to properly erase the sector?2015-06-24 06:04 AM
What could cause the FLASH_Erase_Sector-function to fail to properly erase the sector?
Ignoring error and status conditions returned by the controller, and not clearing those conditions before starting? Controller needs to be unlock, Sector should not be write protected.2015-06-24 06:17 AM
Thanks, I forgot to call HAL_FLASH_Unlock() before erasing. The reason only 6 memory locations failed to program was that only those 6 memory location were programmed before I tried to rewrite the sector. So it all makes sense now.