2025-01-28 07:11 AM
I am encountering an issue in the development of the TrustZone application related to the UART in secure non-privileged mode.
I want to switch to non-privileged mode when in secure and privileged mode. This transition works correctly. However, I have noticed that the UART does not work in non-privileged mode, even though it functions in privileged mode.
When I execute the code, it consistently ends up in the HardFaultHandler(). After debugging, I identified that the error occurs on line 227 of the main file, specifically during the call to the HAL_UART_Receive() function.
To configure the peripherals, I used the GTZC.
Detailed Analysis
Event detected in the SFR register:
Mode Transition:
Behavior of the MMFSR (Memory Management Fault Status Register):
Hypothesis
It seems the problem is related to a memory access violation in non-privileged mode. This could be caused by:
Actions Already Taken
I am trying to determine why the processor considers the access to the USART as illegal in non-privileged mode. Here is the code enclosed
Thank you in advance for your assistance.
2025-01-28 07:59 AM
Hello @ECoud.1 ,
according to your investigation it look like the memory you are trying to access is not setup to authorize non privilege access.
If address is in flash, you will need to setup FLASH_PRIVBB. But default value allows non privilege access.
If access is in RAM, you need to setup GTZC to allow non privilege access to the concerned area.
Best regards
Jocelyn
2025-01-28 10:08 AM
Thank you for your response. Could you provide more details on how to configure the flash? I’ve read the datasheet, but I’m having difficulty understanding how to program it, especially since you mentioned that the default configuration allows non-privileged access. However, this doesn’t seem to be the case for me.
I’ve also configured the GTZC for the peripherals I want to use. I have a similar application running without TrustZone, and it works fine. Perhaps there’s some configuration I’m missing?
What I’m trying to achieve is encryption and decryption of data using the four modes of the Cortex-M33, but I haven’t been able to find tutorials or clear information on how to implement it.