cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with reloading option bytes - STM32L452RE

WPuch
Associate II

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?

8 REPLIES 8
Uwe Bonnes
Principal III

Is your reset circuit at the NRST standart , 100 nF to ground. For me it sounds like your reset circuit is custom...

No reset circuit is OK. But all it seems that my code it faulty as always without problem invoke bootloader with reset+boot0 pin without powercycling.
Now i have no idea why my code starts fine after powercycle or reset if option bytes wasn't changed, but doesn't when option bytes were changed. But i will write a mail when i find it.
On 2019.06.10 20:49, ST Community wrote:
Well it seems it's not my program.
Made simple program: vectors table at the beginning, with stack address
and pointer to main.
main only sets RCC_AHB2ENR to turn on GPIO, setup GPIOB mode, and toggle
GPIO B0 in a loop.
Programmed using my programmer without enabling RDP - led blinks.
Programmed but with enabling RDP afterwards - doesn't blink. resetting
by NRST pin - doesn't blink.
powercycle - blinks fine. Resetting after powercycle - blinks fine.
Reset do work for sure.
what else can i check
One more test.
I used NUCLEO-L452RE board as is, powered through 3.3V pin (connector CN7 pin 16), ground to CN7/8, boot8 (CN7/7) to my DTR pin on UART to USB converter, RTS to CN7/14 (NRST) pin, UART TX to CN10/33 (PA10), UART RX to CN10/21 (PA9). Used my programmer.
Results are exactly the same. Programming without setting readout protection - works fine. Reset using NRST - reset properly. (The same reset+boot0 is used to enter programming mode anyway).
Programming with setting readout protection - hangs. Reset using NRST pin (through RTS output on usb-uart converter) - no effect.
But it is possible to enter programming mode again. And program again. But program doesn't run.
Powercycle - works fine. After powercycle reset works fine too.
There is no difference between evalboard and our board in this behaviour.
Is there something i have to do after issuing to bootloader command 0x82 (readout protect) and wait for 2 ACKs to make it work properly?
DKina.1
Associate

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...

WPuch
Associate II

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.

Prathamesh_Bhat
Associate II

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.

 

  1.  I change the option byte for read out protection level 1 and then read it back, and after resetting via the NRST pin, it still has the same value(No read out protection applied).

 

       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.

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