2014-10-15 05:52 AM
Hello,
I would like to know if it is possible to change the value of the register FLASH_OPTCR by mapping a variable on it and to set the value in constant ? I think this is not possible because we need to respect a predefined sequence to unlock the register but I can always ask for the question :) Example of what I want :const u32 u32_FlashOptcr @ 0x40023C14 = 0xFFFFFFFF;
Thanks,
Fabien.
2014-10-15 06:12 AM
Hi
''I would like to know if it is possible to change the value of the register FLASH_OPTCR by mapping a variable on it and to set the value in constant ? I think this is not possible because we need to respect a predefined sequence to unlock the register'' You are correct - you cannot just load it with a single constant value. There are APIs for doing this in the peripheral library : stm32f4xx_flash.c FLASH_OB_Unlock() FLASH_OB_WRPConfig() FLASH_OB_Lock()2014-10-15 06:22 AM
Thanks for the response.
I know about the APIs, but the purpose of my idea was to protect the flash by just flashing a software, and to not make other manipulation with other sofwtare like ''STM32 ST-LINK Utility'' to change the option bytes.2014-10-15 06:35 AM
''the purpose of my idea was to protect the flash by just flashing a software, and to not make other manipulation with other sofwtare like ''STM32 ST-LINK Utility'' to change the option bytes.''
I do not understand - maybe it is your english. The ST-Link will automatically un-lock any write protected sectors and re-lock them afterwards. So the ST-Link can over-ride the write protect bits anyway!2014-10-15 07:48 AM
The options and flash can be programmed by user code, you don't have to use ST-LINK Utilities, or external tools/interfaces, to achieve this.
2014-10-15 07:55 AM
Sorry for my english :(
I just see the ''Automatic Mode'' in st-link utility and I think it will do the job :)I will try to use the st-link utility with command line to unlock flash, program and relock the flash.Thanks.