2023-03-01 04:21 AM
Hi,
My project is based on STM32L15xx microcontroller. I know, that internal FLASH Read Protection may be enabled during programming an image by STMFlashLoader with --erp option. My question is: can I compile my image with internal FLASH read protection enabled by some tweak so that I don't have to use "--erp" option on downloading my image to the target?
Thanks in advance!
Solved! Go to Solution.
2023-03-01 06:24 AM
Hello @DLyum.1 ,
You need to Unlock the Flash and OB to enable the flash control register access.
Here is an example:
FLASH_OBProgramInitTypeDef obProgram = { 0 };
obProgram.OPTIONBYTE_RDP = OB_RDP_LEVEL_1;
FLASH_OB_RDPConfig
HAL_FLASHEx_OBGetConfig(&obProgram);
...
if (obProgram.RDPLevel == OB_RDP_LEVEL_1)
...
The function FLASH_OB_RDPConfig(); could be used.
Hope this helps!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-03-01 05:42 AM
Should be able to check the state of the option bytes, and change them.
2023-03-01 06:02 AM
Thank you!
The Option Bytes are described in PM0062 (Flash and EEPROM Programming Manual) application notes.
2023-03-01 06:24 AM
Hello @DLyum.1 ,
You need to Unlock the Flash and OB to enable the flash control register access.
Here is an example:
FLASH_OBProgramInitTypeDef obProgram = { 0 };
obProgram.OPTIONBYTE_RDP = OB_RDP_LEVEL_1;
FLASH_OB_RDPConfig
HAL_FLASHEx_OBGetConfig(&obProgram);
...
if (obProgram.RDPLevel == OB_RDP_LEVEL_1)
...
The function FLASH_OB_RDPConfig(); could be used.
Hope this helps!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-03-01 06:32 AM
Thank you!