Hallo
Hat einer von euch es schon mal geschafft, die STM ReadOutProtection vom
Code aus zu aktivieren?
Ich habe nun schon ein Paar Stunden ins Debugging, Fehlersuche, Google
investiert und bin zu dem Schluss gekommen, dass der Code aus der STM
StdPeriphLib 3.4.0 einfach nicht funktioniert.
1 | #include "stm32f10x.h"
|
2 | int main(void)
|
3 | {
|
4 | FLASH_ReadOutProtection(ENABLE);
|
5 | while(1)
|
6 | {
|
7 | }
|
8 | }
|
Das mal als einfaches Beispiel. Ich kann die Funktion durchsteppen und
das OB->RDP - Register wird korrekt auf 0x00 gesetzt. Jedoch hat dies
keinen Effekt; selbst nach einem Power-Cycle ist der Flash noch per
ST-Link-Utility lesbar.
(Der Vollständigkeit halber hier noch der Code aus der StdPeriphLib)
1 | FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState)
|
2 | {
|
3 | FLASH_Status status = FLASH_COMPLETE;
|
4 | /* Check the parameters */
|
5 | assert_param(IS_FUNCTIONAL_STATE(NewState));
|
6 | status = FLASH_WaitForLastOperation(EraseTimeout);
|
7 | if(status == FLASH_COMPLETE)
|
8 | {
|
9 | /* Authorizes the small information block programming */
|
10 | FLASH->OPTKEYR = FLASH_KEY1;
|
11 | FLASH->OPTKEYR = FLASH_KEY2;
|
12 | FLASH->CR |= CR_OPTER_Set;
|
13 | FLASH->CR |= CR_STRT_Set;
|
14 | /* Wait for last operation to be completed */
|
15 | status = FLASH_WaitForLastOperation(EraseTimeout);
|
16 | if(status == FLASH_COMPLETE)
|
17 | {
|
18 | /* if the erase operation is completed, disable the OPTER Bit */
|
19 | FLASH->CR &= CR_OPTER_Reset;
|
20 | /* Enable the Option Bytes Programming operation */
|
21 | FLASH->CR |= CR_OPTPG_Set;
|
22 | if(NewState != DISABLE)
|
23 | {
|
24 | OB->RDP = 0x00;
|
25 | }
|
26 | else
|
27 | {
|
28 | OB->RDP = RDP_Key;
|
29 | }
|
30 | /* Wait for last operation to be completed */
|
31 | status = FLASH_WaitForLastOperation(EraseTimeout);
|
32 |
|
33 | if(status != FLASH_TIMEOUT)
|
34 | {
|
35 | /* if the program operation is completed, disable the OPTPG Bit */
|
36 | FLASH->CR &= CR_OPTPG_Reset;
|
37 | }
|
38 | }
|
39 | else
|
40 | {
|
41 | if(status != FLASH_TIMEOUT)
|
42 | {
|
43 | /* Disable the OPTER Bit */
|
44 | FLASH->CR &= CR_OPTER_Reset;
|
45 | }
|
46 | }
|
47 | }
|
48 | /* Return the protection operation Status */
|
49 | return status;
|
50 | }
|
Hat irgendwer eine Idee?