I have been unsuccessful getting the function TargetInterface.pokeUint16(address, value); to write to FLASH memory.
My platform is STM32F103RB.
I have taken the following steps before attempting the write...
- Ensure HSI (the internal RC oscillator) is enabled.
- CLEAR the LOCK bit in the FLASH_CR register.
- Verify all WRPx bits are SET. (No write protection enabled)
- Verify RDP option byte = 0xA5. (Read protection disabled)
- SET the PG bit in FLASH_CR.
- Ensure the BSY bit is clear in the FLASH_SR register.
- Ensure the memory location being written contains 0xFFFF.
After all the above is done, a call such as...
fails, returning DEV_TARGET_CMD_ERR.
The function works fine when addressing RAM.
I'm wondering if it is attempting to verify the WRITE by performing a READ immediately following. If so, the READ would fail unless it is held-off until the BSY bit in FLASH_SR is CLEAR.
I would think this not the case, as it would cause issues with writing to memory-mapped registers as well.
The inability of TargetInterface.pokeUint16() to WRITE to FLASH explains why STM32F_Unprotect() doesn't work either.
Ref: "Removing read protection with STM32F_Unprotect()", posted on April 13, 2013.
Please sign in to leave a comment.