Skip to main content
Visitor II
May 5, 2024
Question

STM32F407 DFU and STM32CubeProgrammer - Problem to load a new program - Not Erase memory

  • May 5, 2024
  • 1 reply
  • 4478 views

Hello!


I'm trying to use a firmware DFU with the STM32F407 and Emulated EEPROM to change into DFU / App or App / DFU. The DFU address is in 0x08000000, the Emulated EEPROM address is in 0x08008000 and the Application address, on 0x0800C000.

 

All this steps works fine, the DFU connect with USB to the STM32CubeProgrammer and I can load a first code. Then it jump right to the Application, run it good, and I can go back to the DFU without problems. The problems comes when a trying to load another program after the first load previously.

 

I could find in the code of DFU, the function MEM_If_Erase_HS is never called so, it can't load a new program. The other functions, some are called like MEM_If_Write_HS (because load the first time the program) and MEM_If_Read_HS (because the verification is right). So, I don't understand or I can't find why is not called the function to erase the memory and program another code.

On the STM32CubeProgrammer, I have the error menssage:

12:10:04 : Memory Programming ...
12:10:04 : Opening and parsing file: Main_QB_STM_DFUFreeRTOS.bin
12:10:04 : File : Main_QB_STM_DFUFreeRTOS.bin
12:10:04 : Size : 39.74 KB
12:10:04 : Address : 0x0800C000
12:10:04 : Erasing memory corresponding to segment 0:
12:10:04 : Error: failed to erase memory

 

Has anyone had this or a similar problem to help me?

    This topic has been closed for replies.

    1 reply

    Super User
    May 5, 2024

    Hi,

    maybe you (your cpu) have some write protection on , check in  STM32CubeProgrammer :

    AScha3_0-1714925116568.png

     

    Check: erase is on:

    AScha3_1-1714925285512.png

     

    And try full chip erase , if still wrong.

    GAJOBARAuthor
    Visitor II
    May 5, 2024

    Hi AScha.3

    The first option, where I an find? The second option, I using in that way and I can found de error with that option. When I debug the code, it's never call the function MEM_If_Erase_HS so, it can't write the new code because it need all memory erased.

    Super User
    May 5, 2024

    Sorry, i dont understand now. 

    Your problem found/solved ? Then mark solution.

    If you do something with write protection, its another question (i assume : Emulated EEPROM is doing something..)

    But if you program with CubeProgrammer , you can set/reset flash (as i do also); whats wrong then ?