Skip to main content
Associate III
February 5, 2025
Solved

Writing to a particular NVM address erases whole sector

  • February 5, 2025
  • 3 replies
  • 2247 views

Hi, 

We are trying to write some key values directly into a particular address of NVM from STM32Cubeprogrammer, but rest of the sector are also getting erased. Is there any way to prevent it? Tested with Cubeprogrammer CLI also, but facing the same issue.

Best answer by Andrew Neil

No.

As noted, that is the nature of Flash.

You'd have to do it in 3 steps:

  1. Read out the existing content;
  2. Erase the sector;
  3. Write the new content.

 

If you explain what you're actually trying to achieve, people may be able to suggest other ways to achieve that goal...

(you haven't said what chip you're using)

3 replies

Andrew Neil
Super User
February 5, 2025

By "NVM", do you mean Flash?

If so, that is the expected behaviour - you can only write to erased Flash.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
pho3nixAuthor
Associate III
February 5, 2025

Yes, I mean flash. 

 

Is there any other way to do it? So that other flash contents remain as it is. Only a particular selected area gets erased and written. 

Andrew Neil
Andrew NeilBest answer
Super User
February 5, 2025

No.

As noted, that is the nature of Flash.

You'd have to do it in 3 steps:

  1. Read out the existing content;
  2. Erase the sector;
  3. Write the new content.

 

If you explain what you're actually trying to achieve, people may be able to suggest other ways to achieve that goal...

(you haven't said what chip you're using)

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
pho3nixAuthor
Associate III
February 6, 2025

Sorry, I should have mentioned it.

I am using RAK3172 module (STM32WLE5CCU6) for LoRaWAN application.

For every LoRaWAN application, there needs three parameters which are DEVEUI,JOINEUI and APPKEY. Right now these are programmed from the firmware itself. But from production point of view we are looking for an efficient way. That's when this idea came into my mind.

Pavel A.
Super User
February 5, 2025

Recently ST released M95 EEPROMs, very suitable for this purpose. Please consider.

 

pho3nixAuthor
Associate III
February 6, 2025

Thank you for the suggestion! I’ll definitely look into it.