AnsweredAssumed Answered

Program Flash with Secure AHB Controller enabled

Question asked by Simon Ott on May 22, 2019
Latest reply on May 31, 2019 by Alice_Yang

What is the proper way to read and write data from and to the flash?

I assumed that the FLASH API should be used, so I used those functions to read and write data to and from the flash (FLASH_Init, FLASH_Program, FLASH_Erase, ...). This worked fine, as long as the Secure AHB Controller is not enabled.


However, as soon as I enable the Secure AHB Controller, the LPC55S69 runs into a bus fault when calling FLASH_Init. I can see that the error is caused on AHB layer zero by the CPU (bus master 0) which is running secure privileged and that it is a read address on location 0x3004310 that causes the security violation. The address is obviously in the ROM area where the FLASH API is located, but I am not sure why I cannot access this region at all. Explicitely programming the security level of the ROM (AHB_SECURE_CTRL->SEC_CTRL_FLASH_ROM[0].SEC_CTRL_ROM_MEM_RULE[0] and so on) to any security level does not have any effect.


My only goal is to store some data structures persistently (while the Secure AHB Controller is enabled). So my question is if I am doing something wrong in general (use the wrong API etc.) or how can I prevent the security error when accessing the FLASH API.