cancel
Showing results for 
Search instead for 
Did you mean: 

connecting SWO pin is causing Hard Fault Exception(unaligned memory access)

LZhan.1
Associate

Hi,

I got a strange behavior during debugging my bare metal application on STM32F745ZGTx. The emulator is ST-Link V2, with "B 2018 02" printed on the back. The Hard Fault exception (unaligned memory access) is triggered randomly. I mean, the PC causing problem is not at the same place, but randomly. The trouble-shooting steps I have taken:

  1. Originally I suspect it is related to the power supply or PLL clock. So I enabled the Brown-out reset and switched to internal HSI. But the problem is still there.
  2. Then I suspect the IDE. I tried both Keil and IAR. The problem is seen on both IDEs.
  3. I upgraded my ST-link firmware. The issue is still there.
  4. Removing SWO connection, but keep the source intact, and keep the SWDIO/SWCLK. This time, the problem is gone.

So it seems the SWO connection is causing the problem. But I am sure the connection is fine, as I can saw the printf content when SWO is connected.

Do you have any idea about the problem? Please see the attached pictures for the crash, and the attached ioc file for my configuration. Thanks in advance.

BR

/Li

Add one more point: I tried to disable the ITM redirect IO and disabled the printf code directly. In such case, if the SWO pin from ST-Link V2 is still connected to the target, the problem will rise too.

10 REPLIES 10
davideo
Associate II

I thought perhaps the xPortPendSVHandler was being interrupted by a higher priority interrupt, but I have reduced all code execution down to just the IdleTask and the SysTick interrupt as shown here in the Interrupt log:

...

21s 866820.48 us SysTick Leave ---- 0.67 us
21s 867819.79 us SysTick Enter ----
21s 867820.46 us SysTick Leave ---- 0.67 us
21s 868819.78 us SysTick Enter ----
21s 868820.45 us SysTick Leave ---- 0.67 us
21s 869819.76 us SysTick Enter ----
21s 869820.42 us SysTick Leave ---- 0.66 us
21s 870055.88 us HardFault Enter ----

I'm not using printf. The original poster LZhan.1 is.