2019-06-10 05:24 AM
I want to modify option bytes to set up readout protection. I am programming this device with my own programming tool (UART+BOOT0+RESET pin). Programming works fine using bootloader protocol. Setting readout protection doesn't. After setting it up it doesn't boot, reset doesn't work, only powercycle works.
We cannot powercycle on this device as it will have large hybrid capacitor already soldered before programming. "powercycling" by shorting it for a moment may result in explosion ;)
So i tried to add a function to firmware that set readout protection leve.
Writing option bytes to flash works just as described - no problem. But they need to be reloaded.
AS instruction states on page 92 option bytes are reloaded when
a) BOR reset happens or exit from standby/shutdown mode.
And yes powercycling do work.
b) setting OBL_LAUNCH bit in FLASH_CR. As instruction states it should force system reset.
But it forces system hang instead which can only be resolved by powercycling - which we cannot do.
How to reload option bytes after writing to flash and reset the system WITHOUT disconnecting power?
2019-06-10 11:49 AM
Is your reset circuit at the NRST standart , 100 nF to ground. For me it sounds like your reset circuit is custom...
2019-06-10 11:00 PM
2019-06-11 12:49 AM
2019-06-11 01:20 AM
2020-01-18 05:48 AM
I have a similar problem too. Using stm32f030rct6 in my project, I need write protection on first 2 sectors. I programmed corresponding option byte bits and when i tried to set option byte loading bit in flash_cr mcu is halted. Then I can only connect to mcu using ST-LINK Utility. When I checked option bytes under target -> option bytes, read protection level is changed to 1 from 0 and sectors are write protected.
If someone has an idea, please share...
2020-01-20 12:22 AM
Yes it's clearly chip bug. I've been on ST presentation and one thing they showed was about using protection levels.
Their program requested the powercycle after changing it.
But there is a workaround.
1) Write option bytes as you like
2) DO NOT set OBL_LAUNCH
3) Set up RTC so it will wake up after a second
4) Enter standby mode and wakeup by RTC.
4 will effectively reset everything after a second and it WILL work then properly.
I already use this method in our product - that already have tadiran lithium capacitor/battery soldered while it is first programmed in production.
You cannot powercycle without desoldering.
2024-10-15 02:06 AM
Problem with reloading option bytes - STM32L010K4T6
I've implemented Read Out Protection in the firmware running on an STM32L010K4T6 MCU, but I'm experiencing unexpected behaviour.
2. When I power cycle the device the option byte has a new modified value(Read out protection applied).
3. I have also tried with the a system reset but the result is same.
4. I try out through put MCU in standby mode and again wakeup through RTC interrupt, but it does not able reload option bytes and hang the MCU
We cannot power cycle this device as it is situated in the field. How can we reload option bytes after writing to flash and reset the system without disconnecting power?
Could you please provide the solutions?
How to reload option bytes using NRST pin by applying reset through it? Or any work around for the same.
2024-10-16 03:52 AM
Hi WPuch
I tried out as you mentioned above by waking up by RTC and not by setting OBL_LAUNCH
But it can't work on my MCU STM32l010 can you please have any of comments on this or can you please share you register configuration while going to sleep or program
2024-11-30 05:30 AM
The trick will not work if MCU is in debug mode.
You can check the DBG_STANDBY bit in DBG_CR register:
READ_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
it must be 0 for the correct restart to happen. you can use
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
spell to clear the bit