Skip to main content
Associate II
October 8, 2024
Solved

Need help on writing into secure flash in STM32U575

  • October 8, 2024
  • 2 replies
  • 1849 views

I am working on STM32U575 to write and read from Secure flash. I referred   STM32Cube_FW_U5_V1.4.0\Projects\NUCLEO-U575ZI-Q\Examples\FLASH\FLASH_EraseProgram_TrustZone\

but I was facing following issue

Shaffi_0-1728377891530.png

Can you please help me resolving it. Do we have an document/link explaining read/write access to secure flash and memory map for the same.

Regards,

Shafi

Best answer by STea

Hello @Shaffi ,

are you sure you are setting the correct option byte configuration mentinned in the Readme of the project ?

 - User Option Bytes requirement (with STM32CubeProgrammer tool)

        - TZEN = 1                            System with TrustZone-M enabled
        - SECWM1_PSTRT=0x0  SECWM1_PEND=0x7F  All 128 pages of internal Flash Bank1 set as secure
        - SECWM2_PSTRT=0x1  SECWM2_PEND=0x0   No page of internal Flash Bank2 set as secure, hence Bank2 non-secure
you should set the Tzen bit first to be able to see the secure watermark configuration 
STea_0-1728553699503.png

then the view of SECWM programming should be visible

STea_1-1728553760671.png

then using IAR set the project secure as active and rebuild it 
then rebuild the NS project (this is not done from your side that is why you get this error)

STea_2-1728553857152.png

you should be good to go afterwords.

STea_3-1728554263076.png

Regards

2 replies

ShaffiAuthor
Associate II
October 8, 2024

I am able to port the project using stm32cubeIde and able to compile and run on NUCLEO-U575 dev kit. But the example code isn't working as it is not able to read data against the data written into it.

project:STM32Cube_FW_U5_V1.4.0\Projects\NUCLEO-U575ZI-Q\Examples\FLASH\FLASH_EraseProgram_TrustZone\FLASH_EraseProgram_TrustZone_Secure
Data written 0x0102030405060708, 0x1112131415161718

Date Read 0xd1062800fdb9f7ff, 0xf451680106c4f8df.

Any help is highly appreciated.

Regards,

Shafi

ShaffiAuthor
Associate II
October 9, 2024

Hello ST,

The example code doesn't work in NUCLEO U575 board. Can you please help me in resolving this issue.

Regards,

Shafi  

STeaBest answer
ST Employee
October 10, 2024

Hello @Shaffi ,

are you sure you are setting the correct option byte configuration mentinned in the Readme of the project ?

 - User Option Bytes requirement (with STM32CubeProgrammer tool)

        - TZEN = 1                            System with TrustZone-M enabled
        - SECWM1_PSTRT=0x0  SECWM1_PEND=0x7F  All 128 pages of internal Flash Bank1 set as secure
        - SECWM2_PSTRT=0x1  SECWM2_PEND=0x0   No page of internal Flash Bank2 set as secure, hence Bank2 non-secure
you should set the Tzen bit first to be able to see the secure watermark configuration 
STea_0-1728553699503.png

then the view of SECWM programming should be visible

STea_1-1728553760671.png

then using IAR set the project secure as active and rebuild it 
then rebuild the NS project (this is not done from your side that is why you get this error)

STea_2-1728553857152.png

you should be good to go afterwords.

STea_3-1728554263076.png

Regards

ShaffiAuthor
Associate II
October 11, 2024

Hello STea,

First of all Thank you for your response, it worked for me after enabling TZEN bit. I am able to Read and write from Secure flash.
But I had an another issue when I wanted to disable Trustzone bit So first I changed the RDP from AA to DC in STM32Programmer software and clicked on Apply then I powercycled the board  and pressed connect It showed DEV_TARGET_NOT_HALTED. The settings were mode set to Normal and Reset mode set to Software reset.

Shaffi_0-1728645672856.png

Can you please help to progam my board again.

Regards,

Shafi