I'm trying to enable STM32 readout protection via Keil Ulink. I defined a ROM1 area starting from 0x1FFFF800 up to 0x1FFFF80F. I created a new c module containing two lines only:
#include <RTL.h> const U32 optionByte[] = {0x00FF00FF};
I put optionByte[0] = optionByte[0] into main to force linker to include it. I added the "STM32F10x Flash Options" into "Programming Algorithm".
I enabled the "Erase Sectors" option instead "Erase Full Chip" as suggested in http://www.keil.com/support/docs/3454.htm
If I burn the device, uVision told programming was done, but the device doesn't work. Obiuvsly, I cannot check why via JTAG, because the device is read protected. If I disable the option programming, the device works.
I'd like to know if it's possible to enable the readout protection via Ulink under uVision.
Thanks,
Lorenzo
Great!
I tried to find the STM32 option module without no success. Now, I've found it with your help. Thank you!!!!!
PS: now everything works fine.
Flash readout protection is configured with the first 2 bytes only (RDP and negated RDP). Next two bytes are used for user configuration. So writing 4 bytes just to enable readout protection can already have side effects.
Anyway I suggest you try out the reference example in MDK-ARM installation in folder Keil\ARM\Boards\Keil\MCBSTM32\Blinky which has a target "MCBSTM32 + OPT" that demonstrates how to use Flash options (in STM32F10xOPT.s).
That instruction is not converted to any machine instruction code, even with no optimization (O0). This is a trick to force linker to include this object.
Are you sure that it is safe to do optionByte[0] = optionByte[0]? A ROM area isn't writeable so the processor may throw an exception.
View all questions in Keil forum