Skip to main content
Visitor II
May 22, 2019
Question

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

  • May 22, 2019
  • 2 replies
  • 1482 views

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

    This topic has been closed for replies.

    2 replies

    Graduate II
    May 22, 2019

    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

    Graduate
    May 31, 2024

    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.

    Graduate II
    May 31, 2024

    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.