STM32U585: USB DFU programming fails with TZEN=1 — "Not flash Memory: No erase done"
I was advised by ST Online Support to post this technical question in the ST Community.
Hello ST Community,
I am developing a product using the STM32U585RET6 with TrustZone enabled (TZEN=1).
I am experiencing a problem when attempting to program the Non-Secure firmware using the built-in USB DFU system bootloader.
Programming works correctly via ST-LINK/V3, but fails via USB DFU using both the STM32CubeProgrammer GUI and CLI.
I would appreciate your advice on whether this operation is officially supported and how to resolve the issue.
1. Development Environment
MCU: STM32U585RET6
Flash memory: 2 MB
TrustZone: Enabled (TZEN=1)
RDP: Level 0
Development environment: STM32CubeIDE
Programming tool: STM32CubeProgrammer v2.22.0
Programming interface: USB DFU (built-in system bootloader)
DFU Device ID: 0x482
USB VID/PID: 0x0483 / 0xDF11
USB speed: Full Speed
The firmware is divided into Secure and Non-Secure applications.
Our objective is to update only the Non-Secure firmware via USB DFU, without modifying the Secure firmware or Option Bytes.
2. Flash and TrustZone Configuration
The relevant Option Bytes are configured as follows:
TZEN = 1
RDP = Level 0
NSBOOTADD0 = 0x08010000
SECWM1_PSTRT = 0x00
SECWM1_PEND = 0x01
The Non-Secure firmware starts at address 0x08010000, which is outside the Secure Flash region.
3. Problem Description
When programming the Non-Secure firmware through USB DFU, STM32CubeProgrammer reports the following:
Memory Programming ...
File : M3ST_Rev11_NonSecure.bin
Size : 281.16 KB
Address : 0x08010000
Erasing memory corresponding to segment 0:
Not flash Memory : No erase done
Download in Progress:
File download complete
Verifying...
Error: Data mismatch found at address 0x0804F983
(byte = 0x0D instead of 0x2D)
Error: Download verification failed
The detailed log shows that the Flash erase operation is skipped and completes in 0 ms.
The same behavior occurs with both ELF and BIN firmware files.
The issue is also reproducible using the standard STM32CubeProgrammer CLI command:
STM32_Programmer_CLI.exe -c port=USB1 -w M3ST_Rev11_NonSecure.bin 0x08010000 -v
However, programming the same Non-Secure firmware via ST-LINK/V3 works correctly, and the application runs normally.
4. USB DFU Memory Descriptors
I examined the USB descriptors of the built-in DFU bootloader using USB Device Tree Viewer.
The following memory descriptors are reported:
Alternate Setting 0:
@Internal Flash /0x08000000/256*08Kg
Alternate Setting 1:
@Option Bytes /0x40022040/01*64 e
Alternate Setting 2:
@OTP Memory /0x0BFA0000/01*512 e
According to the descriptors, the internal Flash starts at 0x08000000, with 256 pages of 8 KB each.
However, the Flash erase page list displayed by STM32CubeProgrammer starts at 0x0C000000, using the Secure Flash alias addresses.
When programming the Non-Secure firmware at 0x08010000, CubeProgrammer reports:
Not flash Memory : No erase done
I suspect there may be an inconsistency in the Flash memory mapping or address translation when TrustZone is enabled.
5. Flash Readback Test
I also tested reading Flash memory through USB DFU.
Both of the following addresses can be read successfully:
0x08010000
0x0C010000
Both return identical data.
When reading from 0x0C010000, CubeProgrammer displays:
Warning: Translated to 0x8010000
to be accessible by the Bootloader interface
This suggests that CubeProgrammer translates the Secure Flash alias address into the corresponding Non-Secure Flash address for read operations.
However, Flash erase operations appear not to work correctly.
6. Questions
I would appreciate clarification on the following points.
Q1. Is USB DFU programming officially supported with TZEN=1?
On STM32U585RET6 with TZEN=1 and RDP Level 0, is it officially supported to erase and program the Non-Secure Flash region (0x08010000 and above) using the built-in USB DFU system bootloader?
Q2. Why is Flash erase skipped?
Why does STM32CubeProgrammer report "Not flash Memory : No erase done" even though the USB DFU memory descriptor identifies the internal Flash at 0x08000000?
Could this be related to the Secure/Non-Secure Flash address mapping or address translation?
Q3. What is the recommended programming procedure?
What is the officially recommended method to erase, program, and verify only the Non-Secure firmware while keeping TZEN=1?
Are any special settings, address specifications, DFU alternate settings, or Option Bytes configurations required?
Q4. Is this a known issue in STM32CubeProgrammer v2.22.0?
Is this behavior a known limitation or bug in STM32CubeProgrammer v2.22.0?
If so, is there a workaround or a recommended version that resolves the issue?
7. Product Requirements
Our product is designed so that end users can update the Non-Secure firmware via USB after shipment.
We would like to maintain the following conditions:
Keep TrustZone enabled (TZEN=1).
Do not modify the Secure firmware.
Do not modify the Option Bytes during firmware updates.
Update only the Non-Secure firmware.
Use the official STM32CubeProgrammer GUI or CLI.
Avoid implementing a custom DFU bootloader or using non-standard programming tools if possible.
We would particularly appreciate an ST-recommended procedure for updating Non-Secure firmware via the built-in USB DFU bootloader while maintaining TZEN=1.
Detailed STM32CubeProgrammer logs, USB descriptor information, and Option Bytes settings are available if needed.
Thank you very much for your assistance.
Best regards.
