cancel
Showing results for 
Search instead for 
Did you mean: 

How to resolve "HardFault exception" issue when Trustzone activated on STM32H573VIT6

GTest.1
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions
vijay_03
Associate II

Hi @GTest.1​ 

As you enable trust zone, your project should be divided into to parts

  1. secure or NSC firmware
  2. 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


_legacyfs_online_stmicro_images_0693W00000bl7XTQAY.png
_legacyfs_online_stmicro_images_0693W00000bl7XOQAY.png 

Hard fault occurred due to improper memory allocation of secure and non secure. It also occurred many other reasons.


_legacyfs_online_stmicro_images_0693W00000bl7YvQAI.pngas 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.


_legacyfs_online_stmicro_images_0693W00000bl7aSQAQ.pngCheck your jump address in secure firmware. it should be start of your bank2 address

Regards,

VIJAY

View solution in original post

2 REPLIES 2
vijay_03
Associate II

Hi @GTest.1​ 

As you enable trust zone, your project should be divided into to parts

  1. secure or NSC firmware
  2. 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


_legacyfs_online_stmicro_images_0693W00000bl7XTQAY.png
_legacyfs_online_stmicro_images_0693W00000bl7XOQAY.png 

Hard fault occurred due to improper memory allocation of secure and non secure. It also occurred many other reasons.


_legacyfs_online_stmicro_images_0693W00000bl7YvQAI.pngas 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.


_legacyfs_online_stmicro_images_0693W00000bl7aSQAQ.pngCheck your jump address in secure firmware. it should be start of your bank2 address

Regards,

VIJAY

@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!