Skip to main content
Associate III
March 31, 2026
Solved

CubeProgrammer erase wrong sector on STM32H563VGT6 (1MB Flash) device

  • March 31, 2026
  • 1 reply
  • 496 views

Hi,

When I downloaded a .hex file to my STM32H563VGT6 (1MB Flash) using STM32CubeProgrammer v2.20.0, I encountered an issue where it would erase the wrong sector. For example, as shown in the image below, it was supposed to erase sectors (76..91) and sector 115, but I found that the contents of sector 27 is erased.

I also try to "Erase selected sectors" (76..116) manually, but sector 27 still be erased.

However, I did not have this problem when downloading the same .hex file using an STM32H563ZIT6 (2MB Flash).
cube_download.jpg

Best answer by Aziz BRIGUI

Hi @Snaku,

The fix in STM32CubeProgrammer is planned, when that's done, you'll be able to resolve this by connecting in under reset mode (That way OEMiROT_boot won't be executed and won't interfere with STM32CubeProgrammer detecting the correct flash size => The correct sector indexes).

If I reproduce with OEMiROT_boot on my side and find a change to make that will resolve the issue, I'll let you know. With that being said, on the tool side, the correct behavior is what's happening in hotplug mode (We're connecting to the target that's running an application and that's by definition the hotplug mode, I don't think the tool will open additional memory regions if the running application hides them).

In any case, don't hesitate to comment if you find anything to improve on CubeH5 front as well, I'll be happy to transfer the request.

Kind regards,

Aziz

1 reply

Aziz BRIGUI
Technical Moderator
March 31, 2026

Hi @Snaku,

Thanks for highlighting this.

The issue exists in STM32CubeProgrammer for H5 1M devices when TZEN is enabled and in modes other than Hotplug (We're aware of this and actively investigating. Internal tracking number: 0036604).

Could you try using hotplug mode?

Aziz

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
SnakuAuthor
Associate III
April 1, 2026

Hi Aziz,
Thank you for your response.  

As you mentioned, my TZEN setting is enabled.
However, even when I switch to Hot Plug mode to download .hex files, the problem persists.

Does this problem only exist in the STM32CubeProgramer GUI program? Does the STM32CubeProgramer CLI also have this issue? Are there any suggested workarounds?

Thank you.

Also, below are my option byte settings for your reference.

ob1.PNG

ob2.PNG

Aziz BRIGUI
Technical Moderator
April 1, 2026

Hi @Snaku,

I tried erasing sectors 76 through 91 and sector 115 to try to reproduce what you're seing, but as expected, sector 27 ended up being erased only in modes other than hotplug. I suppose since you're seing a different behavior it means that either some action you're doing when navigating inside STM32CubeProgrammer is halting the CPU, or the running firmware (Since in hotplug mode the CPU is running) is interfering with this operation.

Could you first try the CLI and check if other sectors are being erased? If you encounter the same behavior, could you please share your hex file, or an example with dummy data containing the same segments as your hex file?

Aziz

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.