Application hard fault when restart debug

Share code examples or discuss embedded software, including device drivers, interrupt handlers, middleware and application code.

Moderators: Markus Girdland, Mattias Norlander

vramirez
Posts: 0
Joined: Mon May 23, 2016 4:50 am

Application hard fault when restart debug

Postby vramirez » Mon May 23, 2016 7:03 am

Hi,
my application is running on STM32F405 chip. I made the skeleton with CubeMX aplication The aplication uses freeRTOS and CMSIS-RTOS layer. Iam testing it on STM32 F4 Discovery board.

The aplication create some threads.
It runs well in debug mode, but when I restart the debug mode with IDE "restart" button, it crashes and goes to:
Default_Handler:
Infinite_Loop:
b Infinite_Loop
.....

of startup_stm32f405xx.s file.

(I have compiled it with Keil proffesional license, and everything is ok, there is no crash).

If I remove one of the threads (it does no matter which one, whatever), then it runs well again. And, for example, if I remove the code of my Interrupts, it runs ok again, as well.

I tried to resolve this problem by modifying the heap size, the stack sizes.... I have also implemented the vApplicationStackOverflowHook() function, but it never is called.

The SCB->CFSR content is: 0x0001
flag IACCVIOL is set, so Instruction access violation flag is set.
The SCB->HFSR content is: 0x4000
FORCED: Indicas forced Hard Fault.
The SCB->SHPR1, ec content is: 0x0000

This is the Debug window content, when application crashes:

AppControl.elf
AppControl.elf
Thread <main> (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)
UsageFault_Handler() at startup_stm32f405xx.s:129 0x8007d98
<signal handler called>() at 0xfffffff9
0xfffffffe
__libc_init_array() at 0x8007dd2
LoopFillZerobss() at startup_stm32f405xx.s:113 0x8007d7a
gdb
ST-LINK



Could somebody tell me the right way to resolve this problem?
(I have free version of Atollic TrueStudio)

Thanks in advance,

Valentin

frank_ee
Posts: 55
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

Re: Application hard fault when restart debug

Postby frank_ee » Fri Jul 21, 2017 11:10 pm

Hello,

Check the CPU clock frequency to see if it's valid.

Ander
Posts: 3
Joined: Tue Oct 10, 2017 11:03 am

Re: Application hard fault when restart debug

Postby Ander » Tue Oct 10, 2017 11:45 am

Hi,

I have a similar problem.

STM32F767ZIT - full version of Atollic, FreeRTOS.

Project has been working for months, recently added lwip, (had to do some tweaks because of configSUPPORT_STATIC_ALLOCATION)
lwip seems to work fine, can serve a simple page, connect, reconnect, link handling, etc.

Since then, the restart on the IDE restarts the debugger, but from there it only goes to default handler as with vramirez, no matter how many times I restart, it always crashes when I press Resume (F8) -> have to reprogram to get it going again.

It worked perfectly up until now, but now it consistently doesn't work.
Single stepping through from the restart position seems to work for a while but jumps to default handler seemingly at random...

Fault analyzer reports Hard fault detected, (Bus, memory management or memory fault - FORCED), Precise data violation (PERCISERR), and when I press the code button, it pops up that no source file available for address 0x8021826

Disassembly jumps to somewhere within ITM_SendChar()

Any help would be appreciated

EDIT:
when I remove the printf() statements before the scheduler starts, it seems to work again, but would love to know why...

frank_ee
Posts: 55
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

Re: Application hard fault when restart debug

Postby frank_ee » Thu Oct 19, 2017 5:46 pm

Did you make any progress on this problem? Do you have enough stack allocation for all tasks?

Ander
Posts: 3
Joined: Tue Oct 10, 2017 11:03 am

Re: Application hard fault when restart debug

Postby Ander » Thu Oct 19, 2017 7:21 pm

Hi,

I removed the printf's that were called before the scheduler started and it's never done that again.

The text from those printf's never appeared on the SWV console anyway - I didn't look into it further, haven't had time, but I suspect the ITM part wasn't ready (or initialised yet) to receive printf's yet - although once the scheduler is running (after the board initialisations, ... when lwip starts) all the lwip debug texts come through fast & furious, no problem.

Ander
Posts: 3
Joined: Tue Oct 10, 2017 11:03 am

Re: Application hard fault when restart debug

Postby Ander » Thu Oct 19, 2017 7:24 pm

I did look at the stacks - they seemed ok - the ones that were close to the top, I doubled, but it made no difference - so I assumed it wasn't that.


Return to “Embedded target code development discussions”

Who is online

Users browsing this forum: No registered users and 1 guest