Hardfault when linking OpenThread library

Hi community,

I’m having a weird hardfault when I’m linking the OpenThread library to RIOT. After running GDB, I noticed the hardfault is before accessing main() function (so shouldn’t be a problem of the port itself).

RIOT is crashing in this line 1. Here’s the content of hardfault:

2016-06-17 13:40:42,716 - INFO # Context before hardfault: 2016-06-17 13:40:42,718 - INFO # r0: 0x00000000 2016-06-17 13:40:42,719 - INFO # r1: 0x00000655 2016-06-17 13:40:42,721 - INFO # r2: 0x00000000 2016-06-17 13:40:42,722 - INFO # r3: 0x000058c4 2016-06-17 13:40:42,724 - INFO # r12: 0x00000000 2016-06-17 13:40:42,726 - INFO # lr: 0x00021ea7 2016-06-17 13:40:42,727 - INFO # pc: 0x000058c4 2016-06-17 13:40:42,729 - INFO # psr: 0x40000000 2016-06-17 13:40:42,729 - INFO # 2016-06-17 13:40:42,729 - INFO # Misc 2016-06-17 13:40:42,731 - INFO # EXC_RET: 0xfffffff9 2016-06-17 13:40:42,735 - INFO # Attempting to reconstruct state for debugging… 2016-06-17 13:40:42,736 - INFO # In GDB: 2016-06-17 13:40:42,737 - INFO # set $pc=0x58c4 2016-06-17 13:40:42,738 - INFO # frame 0 2016-06-17 13:40:42,739 - INFO # bt

The OpenThread library is in C++, I programmed the hooks in C and C++ but I get the same hardfault.

Any clue? Cheers

What platform are you running this on? Could you post your .map file? (preferably as a link to gist or pastebin or similar, since they tend to be very large)

Best regards, Joakim

Hi Jose,

the cause of the HardFault can still be your port. You need to check your static initializers, i.e. constructors of the classes you initialize in global storage. Those will be executed before main() is called. Pay attention: the order in which those constructors are called is undefined.

Depending on your architecture the cause can be something not so obvious like unaligned memory access, so e.g. check dereferencing pointers.

Cheers, Daniel