cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L496 NRST pin doesn't work after writing to flash memory

kekon
Associate III

Hello,

I came across the following problem: whenever firmware writes some data to flash memory, the NRST pin doesn't work. I mean, when low level is asserted on NRST pin the device starts to run software not at 0x0800... address but at 0x1FFF.... The same happens in the debugger: when I press "Reset the chip..." button. I get the message: "Break at address "0x1fff5236" with no debug information available, or outside of program code."

The data is written to flash memory page which is  not used by the running program code. Data is correctly written and no error is shown in the FLASH->SR register. I didn't change any option bytes. The device runs at 80 MHz, BOOT0 pin is grounded. What am I doing wrong ?

6 REPLIES 6
TDK
Super User

It's booting into the bootloader. The NRST pin is working fine.

Reasons for it entering the bootloader can be found in AN2606. The most common mistake is the BOOT0 pin is floating, but if that's correct, either option bits are set up to boot into it or the main flash was empty when the chip was powered up.

TDK_0-1776175194629.png

If this is the first time you're programming the chip, you will need to power cycle it to reset the "main flash memory empty" flag. Not just reset, but power cycle.

If you feel a post has answered your question, please click "Accept as Solution".
kekon
Associate III

The option bytes are set as follows:

 

kekon_0-1776235588987.png

 

SMSAD.1
ST Employee

Hello kekon

 

Refer to the errata sheet ES0318 STM32L431xx/432xx/433xx/442xx/443xx device errata for details.
Your problem is described in section 2.2.11: F
LASH_ECCR corrupted upon reset or power‑down occurring during flash memory program or erase operation :


Description
Reset or power-down occurring during a flash memory location program or erase operation, followed by a read of
the same memory location, may lead to a corruption of the FLASH_ECCR register content.
Workaround
Under such condition, erase the page(s) corresponding to the flash memory location.

 

Br,

SMSAD.1

Hello SMSAD.1

I read the errata sheet. There is no reset or power down occuring during flash write operation. The FLASH_ECCR register has a value of 0 directly after page erase and page write. The BOOT0 pin is grounded. It seems that the problem is caused by something else but I'm still unable to solve it.

 

 

 

Shirley.Ye
ST Employee

you can check if reset handler / vector table becomes invalid after your flash write

It seems I found the solution.

I added the following source code line after page erase function and after programming 8-byte block:

 

FLASH->SR = 0xFFFFFFFF;

 

That made the NRST pin work properly. Previously, I reset only single bits in the FLASH->SR register but that didn't help.