cancel
Showing results for 
Search instead for 
Did you mean: 

STM32u545: writing to Non Secure flash region from secure code

bvenkatesh
Associate

Hi,
I am trying to erase and write to stm32u545 flash.
The memory partition is such that, I am dividing each Flash bank 256kb into secure and non secure regions.
first 8 pages are secure and rest of the bank are non secure.
I am running my code from Bank 1 and experimenting on writing to secure and non secure sections in bank 2.
My code is running as secure code and I am able to write/erase to first 8 pages successfully.
When I try to erase 9th page [Non -Secure], I am encountering TZIC illegal access error.
I know that I am trying to access non secure page from secure, so what settings do I need to ensure that I can access it?
I have options bytes configured correctly based on my memorymap. SAU is disabled and TZEN =1.

 

Thanks,

Bharath

1 REPLY 1
ELABI.1
ST Employee

Hi @bvenkatesh,

You can refer to the reference manual RM0456, specifically section 7.7 Flash memory and FLASH registers access control, where you will find the explanation of access to the flash memory

ELABI1_0-1737622530816.png

and also refer to this application note AN5347, which shows that you have to use NSC register to erase Non -Secure pages.

 

ELABI1_1-1737622695899.png

Thank you.

ELABI.1

 

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.