2015-07-02 08:53 AM
Hello all,
I am new to this forum but it has so far been a very good resource for me to learn how to work with the STM32F4 MCU.I have managed to enable RDP Level 1 using software but I was wondering if there was a way to do this using JTAG by directly accessing the registers. I am using Keil's uVision IDE and a J-Link emulator to program my MCU's Flash. When in debug mode, I am able to directly write to registers such as the GPIO_ODR by double clicking and setting the appropriate bits. When I try to do the same to the FLASH_OPTKEYR register to enter the two codes required to unlock the FLASH_OPTCR it does not seem to work. The reason why I am asking this is because I would like to have a technician enable the RDP Lvl 1 without having to change the source code when the cards are being sent out.Thanks!Michael #stm32-rdp-read-protection2015-07-02 10:31 AM
Yes, I'd suspect the debugger view is a bit invasive.
Keil should have a way to select the option bytes as a programming region (algorithm), and you might be able to program them via data in the .HEX file / linker output. Don't plan on giving test techs $5K Keil seats.Personally my preference would be for the code running in the device to recognize it needs to lock things down, or provide a menu/diagnostic that the tech or programming bench could activate along with serial/calibration data.2015-07-03 05:26 AM
Thanks Clive1,
I ended up discovering debug commands, which I have scripted in an .ini file which I can load into Keil. Unfortunately, Keil does not provide an option to run the ini file after the flash programming is complete so I am forced to first program the flash without the .ini and then enter debug mode with the .ini loaded which writes to the appropriate registers. You are probably right though, I may implement some secret button sequence which locks the flash since I don't have a user interface.2015-07-20 12:08 PM
Follow up:
I have decided to write a function in regular software to activate RDP Level 1. When I activate the function using by GUI (signal sent via SPI), my chip freezes until I perform a power cycle, after which Level 1 is activated. I would like to know if this is normal or if I am doing something wrong. Ideally, I would like my code to continue running after RDP has been enabled. At the very least, a soft reset should restart my code without having to power cycle since I would like to activate this option remotely.Thanks for any insight anyone has or if anyone is having a similar issue please let me know.2017-06-01 04:18 AM
The debug part of the mcu have to be unused for the time after last hardreset.
If debugging is enabled, the mcu crashes at the first instruction, which loads data from flash.