Skip to main content
Associate II
February 28, 2025
Solved

cubeprogrammer can not find masserase function

  • February 28, 2025
  • 4 replies
  • 1888 views

I created an external flash STLDR file for my board, with STM32H750VB chip and W25Q64 QSPI FLASH. After copying the STLDR file to the cubeprographer directory, it can perform normal external flash read/write and sector erase functions. However, when selecting full chip erase, the cubeprographer prompts me "please select external loader before performing external full chip erase". But I am sure that my code contains the correct int MassErase (void) function, and I used the readelf command in Ubuntu environment to read the STLDR file I created, which also includes the MassErase function. But it seems that this function cannot be correctly detected by the cubeprographer. How can I locate the cause and solve this problem?
Wishing you peace

Best answer by Tesla DeLorean

The .STLDR you attached looks reasonable enough

Not sure the linker script is entirely correct. It describes the FLASH at 0x08000000 and the StorageInfo structure is placed there.

4 replies

Tesla DeLorean
Guru
February 28, 2025

>>How can I locate the cause and solve this problem?

Hard to know with the detail presented, you look to be looking in the right places.

Perhaps attach the .ELF / .STLDR, or a structure dump via OBJDUMP, OBJCOPY, or whatever.

Perhaps the address or attributes of the function? The case?

Perhaps compare the structure of how your's dumps vis-a-v all the other examples in the ExternalLoader subdirectory.

Screen shots of error, showing loader that's loaded, the Log at Verbosity Level 3..

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Associate II
March 1, 2025

thank you for your replay!

this is my Screen shots and error message

keanlee0721_0-1740839208415.png

This stldr file can help me perform external flash read, write, and fast erase functions, but full chip erase cannot be used.

I saved the output of objdump and readelf commands in CMDobjdump.txt and CMDreadlef.txt files. It can be found that the masserase function exists in both files. However, when executing external full chip erase, the error shown in the figure above is always prompted. I put part of these two files here for easy display, as well as my cubeide project. By the way, the cubeide I use is the Linux version, and the development environment is ubuntu22.04.5LTS.
This problem has bothered me for a week
Thank you again for your reply

keanlee0721_1-1740840189367.png

keanlee0721_2-1740840215903.png

 this is source code screen shots

keanlee0721_3-1740840351250.png

about of the cubeprogrammer

keanlee0721_4-1740840853885.png

about of the cubeide

keanlee0721_5-1740840920803.png

keanlee0721_6-1740841405832.png

 

 

Tesla DeLorean
Guru
March 1, 2025

I'll take a look. Make sure the most current version of your loader is in the STM32 Cube Programmer External Loader directory

This is the one I built as a constrast

https://github.com/cturvey/stm32extldr/blob/main/h7_w25q64/CLIVEONE-W25Q64_STM32H7XX-PB2-PB6-PD11-PD12-PE2-PD13.stldr

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Visitor II
June 27, 2025

Win11 laptop, Micron MT25QL01GBBB on NUCLEO-U5A5ZJ-Q board.

STM32CubeProgrammer v2.18.0.

Loads program (into internal flash) and GUI (TouchGFX) assets into the external flash. Can "Erase selected sectors" but displays "Please select external loader before performing external full chip erase". Using v1.16.0 of STM32CubeIDE. Tried:

"int __attribute__((used)) MassErase(void)"

... no joy.

The MassErase present in the ELF, the name is present in the .symtab with proper address (I guess that's how STM32CubeProgrammer finds the entry addresses).

IMHO the message really means that STM32CubeProgrammer cannot find the address, see the traces below, it really does not attempt to do anything:

 

Successful sector erase:

13:22:47:081 : r ap 0 @0x0BF99EFE 0x00000001 bytes Data 0xFFFFFF92
13:22:47:084 : Flash sector erase ...
13:22:47:085 : r ap 0 @0x40022040 0x00000004 bytes Data 0x1FEFF8AA
13:22:47:085 : Swap Bank enabled: sector indexes swapped
13:22:47:090 : r ap 0 @0x40022040 0x00000004 bytes Data 0x1FEFF8AA
13:22:47:090 : Flash erase...
13:22:47:093 : halt ap 0
13:22:47:093 : w ap 0 reg 15 PC (0x20000000)
13:22:47:093 : w ap 0 reg 17 MSP (0x20000500)
13:22:47:093 : w ap 0 reg 16 xPSR (0x01000000)
13:22:47:096 : w ap 0 @0x2001C720 : 0x00000200 bytes, Data 0x00000000...
13:22:47:097 : w ap 0 @0x20000000 : 0x00000004 bytes, Data 0x0000BE00...
13:22:47:465 : w ap 0 @0x20000004 : 0x0001C2F8 bytes, Data 0x000082B4...
13:22:47:465 : Init flashloader...
13:22:47:465 : halt ap 0
13:22:47:465 : w ap 0 reg 0 R0 0x00000001
13:22:47:465 : w ap 0 reg 1 R1 0x00000000
13:22:47:465 : w ap 0 reg 2 R2 0x00000000
13:22:47:465 : w ap 0 reg 3 R3 0x00000000
13:22:47:465 : w ap 0 reg 4 R4 0x00000000
13:22:47:465 : w ap 0 reg 5 R5 0x00000000
13:22:47:466 : w ap 0 reg 6 R6 0x00000000
13:22:47:466 : w ap 0 reg 7 R7 0x00000000
13:22:47:466 : w ap 0 reg 8 R8 0x00000000
13:22:47:466 : w ap 0 reg 9 R9 0x00000000
13:22:47:466 : w ap 0 reg 10 R10 0x00000000
13:22:47:466 : w ap 0 reg 11 R11 0x00000000
13:22:47:466 : w ap 0 reg 12 R12 0x00000000
13:22:47:466 : w ap 0 reg 13 SP 0x00000000
13:22:47:466 : w ap 0 reg 14 LR 0x20000001
13:22:47:466 : w ap 0 reg 15 PC 0x20008349
13:22:47:466 : w ap 0 reg 16 xPSR 0x01000000
13:22:47:466 : w ap 0 reg 17 MSP 0x2001C6F8
13:22:47:466 : w ap 0 reg 18 PSP 0x00000000
13:22:47:466 : run ap 0
13:22:47:798 : halt ap 0
13:22:47:798 : r ap 0 reg 0 R0 0x00000001
13:22:47:798 : Loader sector erase...
13:22:47:799 : w ap 0 reg 0 R0 0x77CF0000
13:22:47:800 : w ap 0 reg 1 R1 0x77CF0000
13:22:47:800 : w ap 0 reg 2 R2 0x00000002
13:22:47:801 : w ap 0 reg 3 R3 0x00000000
13:22:47:801 : w ap 0 reg 4 R4 0x00000000
13:22:47:801 : w ap 0 reg 5 R5 0x00000000
13:22:47:801 : w ap 0 reg 6 R6 0x00000000
13:22:47:801 : w ap 0 reg 7 R7 0x00000000
13:22:47:801 : w ap 0 reg 8 R8 0x00000000
13:22:47:801 : w ap 0 reg 9 R9 0x00000000
13:22:47:802 : w ap 0 reg 10 R10 0x00000000
13:22:47:802 : w ap 0 reg 11 R11 0x00000000
13:22:47:802 : w ap 0 reg 12 R12 0x00000000
13:22:47:804 : w ap 0 reg 13 SP 0x00000000
13:22:47:804 : w ap 0 reg 14 LR 0x20000001
13:22:47:805 : w ap 0 reg 15 PC 0x2000847D
13:22:47:805 : w ap 0 reg 16 xPSR 0x01000000
13:22:47:806 : w ap 0 reg 17 MSP 0x2001C6F8
13:22:47:807 : w ap 0 reg 18 PSP 0x00000000
13:22:47:807 : run ap 0
13:22:47:821 : halt ap 0
13:22:47:821 : r ap 0 reg 0 R0 0x00000001
13:22:47:821 : Existing specified sectors are erased successfully Protected sectors are not erased

Unsuccessful Mass Erase:

 14:05:29:441 : UPLOADING ...
14:05:29:441 : Size : 1024 Bytes
14:05:29:441 : Address : 0x8000000
14:05:29:441 : Read progress:
14:05:29:442 : Reading data...
14:05:29:444 : r ap 0 @0x40022040 0x00000004 bytes Data 0x1FEFF8AA
14:05:29:444 : r ap 0 @0x40022050 0x00000004 bytes Data 0x00000000
14:05:29:444 : r ap 0 @0x40022040 0x00000004 bytes Data 0x1FEFF8AA
14:05:29:445 : r ap 0 @0x08000000 0x00000400 bytes Data 0x20270000
14:05:29:445 : Data read successfully
14:05:29:445 : Time elapsed during the read operation is: 00:00:00.004 

Visitor II
June 27, 2025

Upgraded to STM32CubeProgrammer v2.19.0. Same behavior.

Tesla DeLorean
Guru
June 28, 2025

Need to work on the Linker Script so isr_vector gets placed on 0x200 aligned boundary (notionally 0x20000200)

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Visitor II
June 30, 2025

Not sure what the ISR vector table gets to do with all that. I had problems with interrupts (messing up already difficult debug) so I disabled and adjusted the code that it works completely without them. I am not exactly sure though at which moment of the story I did that. Let me see if that makes a diff (I doubt it :) ).

Associate II
July 10, 2025

STM32CubeProgrammer GUI External Loader Full Chip Erase Failure Issue

I'm experiencing an issue with External Loaders created using CubeIDE when using STM32CubeProgrammer GUI:

Problem Description:

  • STM32CubeProgrammer GUI fails to execute "Full chip erase" with custom External Loader
  • Error message: "Please select external loader before performing external full chip erase"
  • Issue occurs on both STM32CubeProgrammer v2.19.0 and v2.20.0

However, CLI works perfectly:

STM32_Programmer_CLI.exe -c port=SWD freq=4000 -el .\MyExternalLoader.stldr -e all
-------------------------------------------------------------------
 STM32CubeProgrammer v2.19.0 
-------------------------------------------------------------------
ST-LINK SN : xxx
ST-LINK FW : V3J15M7B5S1
Board : STLINK-V3SET
Voltage : 3.26V
SWD freq : 3300 KHz
Connect mode: Normal
Reset mode : Software reset
Device ID : 0x450
Revision ID : Rev V
Device name : STM32H7xx
Flash size : 128 KBytes
Device type : MCU
Device CPU : Cortex-M7
BL Version : 0x91
Mass erase ...
Mass erase successfully achieved
  • CLI executes mass erase successfully
  • Flash memory is properly erased to 0xFF (verified)

My Analysis: I suspect this might be a compatibility issue between STM32CubeProgrammer GUI and External Loaders built with CubeIDE (GCC toolchain). Official ST External Loaders appear to be built with IAR Embedded Workbench for ARM (EWARM), which may create binaries with different structures that the GUI specifically expects.

Could this be a bug where STM32CubeProgrammer GUI only recognizes MassErase functionality in EWARM-built binaries?

What are your thoughts on this issue?