This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HardFault_Handler for Segger Embedded Studio?

Hej, I stumbled upon a linker error saying

Output/serial_pca10040 nrf52832_xxaa/Obj/hardfault_handler_gcc.o: In function `HardFault_Handler_Continue':
hardfault_handler_gcc.c:(.text.HardFault_Handler+0x30): undefined reference to `__StackTop'
hardfault_handler_gcc.c:(.text.HardFault_Handler+0x34): undefined reference to `__StackLimit'

which I solved by adding a hardfault_handler_ses.c in components\libraries\hardfault\nrf52\handler with changes in two lines (lines 62, 63 compared to hardfault_handler_gcc.c in SDK 13)

"   ldr   r1, =__StackTop                   \n"
"   ldr   r2, =__StackLimit                 \n"

to

"   ldr   r1, =__stack_end__                \n"
"   ldr   r2, =__stack_start__              \n"

given that Segger Embedded Studio automatically provides the symbols SYMBNAME_start and SYMBNAME_end to the linker.

So dear SES specialists out there: Is that a sane solution or is there a more elegant way to this?

Related