cancel
Showing results for 
Search instead for 
Did you mean: 

How to erase external flash using STM32_Programmer_CLI.exe and flash loader?

Dong_Dong
Associate

MCU : STM32U5G9ZJT6Q
External Flash : MX25LM51245G
SPI Interface : HSPI1

 

When I use STM32_Programmer_CLI.exe I cannot erase the external flash.

Board info:

dev_info.png

 

 

 

 

 

 

I get following error from STM32_Programmer_CLI.exe:

 

STM32_Programmer_CLI.exe -c port=SWD -el "C:\Users\USER\Desktop\Workspace\External_Loader\MX25LM51245G_STM32U5G9ZJ\Project\EWARM\Debug\Exe\MX25LM51245G_STM32U5G9ZJ.stldr" -e all

-------------------------------------------------------------------
STM32CubeProgrammer v2.20.0
-------------------------------------------------------------------

ST-LINK SN : 56FF70067287555130422267
ST-LINK FW : V2J46S7
Board : --
Voltage : 3.21V
SWD freq : 4000 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x476
Revision ID : Rev Z
Device name : STM32U5Fx/5Gx
Flash size : 4 MBytes
Device type : MCU
Device CPU : Cortex-M33
BL Version : 0x90
Debug in Low Power mode enabled


Mass erase ...

Error: Mass erase operation failed.Please verify flash protection

 

How can I do that please?

I looked forums and communities and I have to say the info is rather hopeless.

2 REPLIES 2
Imen.D
ST Employee

Hello @Dong_Dong ,

Is TZEN enabled?

This may be a known issue and limitation for STM32U5 when TZEN is enabled: 

STM32CubeProgrammer errata 2.20.x

  • STM32L5 and STM32U5 microcontrollers: Unable to read, write, or erase the external flash memory when TZEN is enabled.
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

TZEN is disabled....

 

https://community.st.com/t5/stm32-mcus/how-to-implement-and-use-your-own-external-flash-loader-an/ta-p/597752

I created an External Loader with reference to that document.

Did I misorganize the file?


https://github.com/STMicroelectronics/stm32-mx25um51245g

Drivers related to flash memory referenced the file.

The "discovery" driver included the file "stm32u5g9j_xx".
Changed "MX66UW1G45G_xx" to "MX25LM51245G_xx".


https://github.com/Dong-Dongs/External_Loader

I will attach my project link together