Hard fault handler issue (HardfaultHandler.S)

Hello All, 

I am developing an nRF52840 MCU base thread product. 

For this I am using nRF52840-Dev_kit for Development and SDK - nRF5_SDK_for_Thread_and_Zigbee_v4.0.0_dc7186b. 

For my project, I am going to use an external COAP server stack and this external stack is built on C++ libraries. And in SEGGER Embedded Studio for ARM 4.16 I am not able to find some .h files for example unistd.h, memory. h and many more. 

So, I decided to build the code from scratch and followed the https://wiki.segger.com/Use_an_external_Toolchain_with_Embedded_Studio link to build the code using an external toolchain. 

I followed the steps and was able to create the project successfully using mentioned steps from the link. 

Since my project depends on nordic stack/libraries and KNX_IoT COAP libraries. So before I make links to or add external COAP libraries (KNX_IoT libraries), I just included the Nordic thread libraries in my project. First added the freeRTOS and Thread libraries in the project. For this, I referred to the freeRTOS_coap_server example.

Code successfully built without any error so next, I did is tried to run the code on the nRF52840-Dev kit. But after thread_init(&thread_configuration); it enters into hard fault handler. 

Attached is the image of the hard fault file and code halt at the marked point. 

Also, sharing the project file for reference. Please find the attached files. 

testing2_20211007.zip

I tried several steps to debug and find the possible cause but I am not pointing to the exact issue. I tried by checking the SP register, going to step by step in assembly code. 

One thing I observed is SysTick_handler could be the problem but again I am not sure. Also, there are files differences between SDK inbuilt code and external built code.  Those are ses_startup_nrf52840.s, thumb_cr0.s, ses_nrf_commoon.s and system_nrf52840.c file which are present in built-in SDK code but in External code there is SEGGER_THUMB_Startup, startup_ARMCM_GCC.s files. 

And vector tables from both external and built-in SDK codes differ. But unable to narrow the cause for hard fault. 

It is very urgent for me to solve it because after this as I said I have to include external KNX libraries. 

Let me know what did wrong in building the project. 

Thanks in advance 

Regards

Rohit R

 

Parents Reply Children
No Data
Related