0

Hardfault for simple freeRTOS application

himanshu pande gravatar image

asked 2017-03-20 16:01:33 +0200

updated 2017-03-21 07:26:41 +0200

Following is a simple application that I have created. It has no softdevice and the configuration is very similar to blinky freeRTOS example.

Source code:

main.c

All tasks are activated once but then I get a hardfault and it is rather tedious to debug this on gcc/eclipse environment as I get no stack trace for the hard fault.

Kindly let me know what could be wrong?

EDIT : All functions RT_RE_xxxxxxxxxx are blank functions.

edit retag flag offensive close delete report spam

Comments

Here is some further insight into the issue as I refer this FreeRTOS_Debug link.

HARDFAULT:ERROR:START OF FULL LOG

HARDFAULT:ERROR:R0 R1 R2 R3 R12 : 0x0 0x20001950 0x10000 0x200020c8 0xa5a5a5a5 HARDFAULT:ERROR:LR PC PSR BFSR : 0x8 0x8 0x6000000b 0x200 HARDFAULT:ERROR:CFSR HFSR DFSR AFSR MMAR BFAR : 0x20000 0x40000000 0x0 0x0 0xe000ed34 0xe000ed38

HARDFAULT:ERROR:END OF FULL LOG

himanshu pande ( 2017-03-21 11:42:26 +0200 )editconvert to answer

What chipset and SDK version are you using?

Petter Myhre ( 2017-03-22 15:55:25 +0200 )editconvert to answer

I think there is code on the web for a hard fault handler that gives more information about the fault by putting the PC and other info (even a full stack trace?) in memory where you can examine it from the debugger. Does the hard fault handler from Nordic (in their /library directory of the SDK?) give more information than the default hard fault handler? Its not simple and it is tedious, but it is possible to examine the stack from the debugger.

butch ( 2017-03-22 16:58:43 +0200 )editconvert to answer

I have already added that code to hard fault handler which generated additional log like stacked registers and trap related registers in cortex m4.

himanshu pande ( 2017-03-23 09:46:53 +0200 )editconvert to answer

1 answer

Sort by » oldest newest most voted
0
himanshu pande gravatar image

answered 2017-03-23 09:50:02 +0200

updated 2017-03-24 11:13:53 +0200

I have got the software working. It was with the compiler options.

I had following compiler option other than blinky freeRTOS project:

  1. CFLAGS += -DSOFTDEVICE_PRESENT

I removed this option and the tasks arrive without glitches.

(Similarly for ASMFLAGS)

So, in conclusion, do not enable softdevice if your project doesn't use it.

edit flag offensive delete publish link more

Comments

seems like you are getting memory corruption in the stack. Set the heap size to 0 and increase the stack by 1KB and enable back these options to see what happens.

Aryan ( 2017-03-23 22:14:38 +0200 )editconvert to answer

How is the option -D__STACK_SIZE related to configTOTAL_HEAP_SIZE parameter in FreeRTOS?

himanshu pande ( 2017-03-24 10:56:56 +0200 )editconvert to answer

Hi Aryan, I did lot of mix and match with all the above options and its CFLAGS += -DSOFTDEVICE_PRESENT option that causes the trap. Rest all options don't affect the system at all. Is this a bug or is this normal behavior? i.e. dont enable softdevice when we don't use it.

himanshu pande ( 2017-03-24 11:11:34 +0200 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

User menu

    or sign up

Recent questions

Question Tools

1 follower

Stats

Asked: 2017-03-20 16:01:33 +0200

Seen: 92 times

Last updated: Mar 24