Skip to main content
Explorer II
January 15, 2025
Question

STM32u545: writing to Non Secure flash region from secure code

  • January 15, 2025
  • 1 reply
  • 573 views

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

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    January 23, 2025

    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