Skip to main content
Visitor II
August 26, 2024
Solved

How to preserve EEPROM space when programming STM32L072CZ

  • August 26, 2024
  • 2 replies
  • 1747 views

We have a part on our custom board which includes a STM32L072CZ.  The part was shipped with obsolete firmware, and we are trying to upgrade the firmware with the new image provided by the manufacturer.  We first tried to upgrade the firmware using Segger's J-Flash utility and a J-Link Plus.  We were able to reprogram the firmware, but in the process it apparently wiped out the 6k of EEPROM.  J-FLash's target selection shows the STM32L072CZ as having 198k of flash, but it should be 192k of flash.  I'm guessing the additional 6k is the EEPROM.

The manufacturer suggested we try STM32CubeProgrammer.  This utility connects using the J-Link, and it correctly recognizes the target.  Since this particular target has already had the EEPROM wiped out when using J-Flash, I would like to confirm that using STM32CubeProgrammer will preserve the EEPROM.  Are there any steps I need to take within STM32Cube Programmer to preserve the EEPROM or does it recognize the target as having 192k, and will not overwrite the EEPROM?  If I first erase before programming, does it erase the EEPROM space also?

    This topic has been closed for replies.
    Best answer by xpress_embedo

    Hi,

    I can suggest something with J-Link and J-Flash tool.

    When I created a new project with the suggested micro using JFlash, I got the two memory ranges.

    xpress_embedo_0-1724646824340.png

    It looks like that

    0x8000000 - 0x802FFFF :right_arrow: is for application code
    0x8080000 - 0x80817FF :right_arrow: is for saving data similar to EEPROM and is of 6KB

    In J-Flash Project you can go to "Project Setting" :right_arrow: "Flash", you can uncheck the memory ranges you don't want to program.

    xpress_embedo_1-1724646943668.png

    As you can see the "check box", just uncheck and use the project, then J-Link will not erase the memory ranges that are not selected.

    Just make sure to not use "Erase Chip", it will still erase the complete chip, instead of the use "Erase Sector"

    Hope this helps

     

    2 replies

    Visitor II
    August 26, 2024

    Hi,

    I can suggest something with J-Link and J-Flash tool.

    When I created a new project with the suggested micro using JFlash, I got the two memory ranges.

    xpress_embedo_0-1724646824340.png

    It looks like that

    0x8000000 - 0x802FFFF :right_arrow: is for application code
    0x8080000 - 0x80817FF :right_arrow: is for saving data similar to EEPROM and is of 6KB

    In J-Flash Project you can go to "Project Setting" :right_arrow: "Flash", you can uncheck the memory ranges you don't want to program.

    xpress_embedo_1-1724646943668.png

    As you can see the "check box", just uncheck and use the project, then J-Link will not erase the memory ranges that are not selected.

    Just make sure to not use "Erase Chip", it will still erase the complete chip, instead of the use "Erase Sector"

    Hope this helps

     

    tkobetAuthor
    Visitor II
    August 26, 2024

    I was wondering if something like that would be possible, but was not familiar enough with J-Flash to know.  I had looked up the address space of the EEPROM area, so was moving in the right direction, but your response definitely sped things up.  I should have known better than to do an erase chip.  I excluded the 6k EEPROM area from the eras as you suggested and programming a different chip worked correctly.  So thanks very much for the help.

    Graduate II
    August 26, 2024

    Perhaps save the original content first so it's not lost as you evaluate?

    If you mass erase you might lose everything.

    If the image/ object you're try to write contains data for the EEPROM address, a selective erase will likely still result in the loss of.the original content. They might have a secondary method of sending / programming device specific settings and serialization. 

    tkobetAuthor
    Visitor II
    August 26, 2024

    You are correct, the mass erase did wipe out everything, so that was a bad move on my part.  J-Flash lists the part as having 198k of flash, which was confusing, but bad judgement from being in a hurry was a larger issue.  Turns out the image does not include the EEPROM area, so we're able to successfully update firmware now.  Thanks for the info.

    Visitor II
    August 26, 2024

    Removing RDP will erase eeprom. In any other sutuation, content od EEPROM will be preserve.