How to resolve "HardFault exception" issue when Trustzone activated on STM32H573VIT6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-29 11:58 PM
Hi guys! Good day and hope you are doing well.
I am currently working with STM32H573VIT6. I have enabled the Trustzone by using STM32CubeProgrammer (i.e., from the "Option bytes" feature). After that I am having an issue of "Hardfault exception" during debugging(FYI, I am using IAR as IDE). I have got the following logs from the debug log.
- Mon May 29, 2023 16:46:55: Breakpoint hit: Code @ startup_stm32h573xx.s:235.1, type: default (auto)
- Mon May 29, 2023 16:46:55: HardFault exception.
- Mon May 29, 2023 16:46:55: The processor has escalated a configurable-priority exception to HardFault.
- Mon May 29, 2023 16:46:55:
- Mon May 29, 2023 16:46:55: A bus fault has occurred on an instruction prefetch (CFSR.IBUSERR, BFAR).
- Mon May 29, 2023 16:46:55:
- Mon May 29, 2023 16:46:55: Attribution unit violation:
- Mon May 29, 2023 16:46:55: An attempt was made to access parts of the address space that are marked as Secure with NS-Req for the transaction set to Non-secure.
- Mon May 29, 2023 16:46:55: At address 0xfffffff8.
- Mon May 29, 2023 16:46:55:
- Mon May 29, 2023 16:46:55: Could not determine the location where the exception occurred.
- Mon May 29, 2023 16:46:55:
- Mon May 29, 2023 16:46:55: See the call stack for more information.
From the log, it seems that probably the reason is: "An attempt was made to access parts of the address space that are marked as Secure with NS-Req for the transaction set to Non-secure at address 0xfffffff8".
Can someone help me where I am doing something wrong so that these errors are appearing? Is it that I did not set some parameters on "Option bytes" (by using STM32CubeProgrammer. See the attachment for details) or something else I need to check? By the way, I did not able to find "RDP level" in "Option bytes" feature.
Anyway, I will be very grateful for any advices.
Thanks in advance.
N.B: Please find the screenshots in attachment section.
Solved! Go to Solution.
- Labels:
-
DEBUG
-
IAR
-
STM32CubeProgrammer
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-30 2:05 AM - edited 2023-11-20 4:23 AM
Hi @GTest.1
As you enable trust zone, your project should be divided into to parts
- secure or NSC firmware
- Non-secure firmware
First secure code will be executed and then it will jump to non-secure firmware.
I thing if you have used sample code then one bank is used for secure firmware and another bank is for non-secure. So check
Hard fault occurred due to improper memory allocation of secure and non secure. It also occurred many other reasons.
as per your configuration it look like your both bank is configured as secure. Kindly update
SECWM2_START value = 0x01
SECWM2_END value = 0x00
apply and save and try to debug.
SECWM2_START value > SECWM2_END value required to configure bank2 as non-secure.
Check your jump address in secure firmware. it should be start of your bank2 address
Regards,
VIJAY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-30 2:05 AM - edited 2023-11-20 4:23 AM
Hi @GTest.1
As you enable trust zone, your project should be divided into to parts
- secure or NSC firmware
- Non-secure firmware
First secure code will be executed and then it will jump to non-secure firmware.
I thing if you have used sample code then one bank is used for secure firmware and another bank is for non-secure. So check
Hard fault occurred due to improper memory allocation of secure and non secure. It also occurred many other reasons.
as per your configuration it look like your both bank is configured as secure. Kindly update
SECWM2_START value = 0x01
SECWM2_END value = 0x00
apply and save and try to debug.
SECWM2_START value > SECWM2_END value required to configure bank2 as non-secure.
Check your jump address in secure firmware. it should be start of your bank2 address
Regards,
VIJAY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-05-30 4:39 AM
@vijay_03 Thanks a lot for your elaborate clarification. Really appreciate that! I have changed the values as you suggested and it works perfectly. Again thanks a lot!
