cancel
Showing results for 
Search instead for 
Did you mean: 

How to protect one flash memory page from being erase during jtag programming?

Mich1
Associate III

Hello,

In a previous post I request how to reserved a memory area to store user parameters (like INFO memory inside MSP340 devices):

https://community.st.com/s/question/0D50X00009XkaTtSAJ/msp430-information-memory-equivalent-inside-the-stm32

ST members suggested me to use the flash memory. This is ok but how can I prevent this memory area from being erased when I reprogram the STM32L4xx? (I use Atollic TrueStudio)

These parameter area contains :

  • PCB unique number: must never be erased even if reprogramming operation
  • application parameters: can be changed by uart application but not during reprogramming operation (no OTP area)

Do you have suggestions?

Best regards

Michel

3 REPLIES 3

In Keil, you simply make sure the areas used are outside the scope of other sectors, and then select the Debug:Flash Download:Download Function:Erase Sectors and it will selectively erase the sectors actually taken by the application code, and leave the configuration/calibration stuff alone

Pretty sure the STM32 Cube Programmer also provides for selectivity, and you can Mass Erase if you really want.

Here the stuff we want permanent goes in OTP. Configuration data is in a structure, with a CRC, and if the data is missing or invalid, the app provides defaults, and updates the configuration space with valid data.

#GetBetterTools

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andri
Associate II

Hello,

I also need to use the flash as an EEPROM. Is there a way to protect the EEPROM sectors in case the user performs a full chip erase from STM32CubeProgrammer?

Thanks for your help.

Not really, you can write protect sectors, but that will ultimately need to be enabled/disabled by your own code to update your EEPROM / Faux EEPROM depending on how you implement it. You really can't play logic games with what "Mass Erase" does, it's mostly a binary option.

If erasing *this* chip is a problem, put the data in *another chip* which STM32 Cube Programmer isn't aware of.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..