Problem with UART in secure and unprivileged mode U5
- January 28, 2025
- 3 replies
- 1163 views
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:
- The UUSART1F bit is activated, indicating an illegal access event.
- Upon verification, the USART is correctly configured in the desired mode: the secure bit is set to 1, and I am in non-privileged mode.
Mode Transition:
- The switch from privileged to non-privileged mode works, as the ARM control bit (in the CONTROL register) is correctly set to 1.
Behavior of the MMFSR (Memory Management Fault Status Register):
- During the HardFault, the DACCVIOL bit (data access violation indicator) is set to 1.
- This bit indicates that the processor attempted to load or store data at a memory address not authorized for this operation.
- The MMAR register contains the faulting address, and the PC register points to the instruction that caused the error.
Hypothesis
It seems the problem is related to a memory access violation in non-privileged mode. This could be caused by:
- Incorrect configuration of USART permissions in the GTZC;
- Or an access restriction related to rights management in non-privileged mode.
Actions Already Taken
- Verification of the SFR and GTZC registers: the USART seems correctly configured.
- Validation of the transition from secure privileged to non-privileged mode.
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.
