Skip to content

Commit 2b61f9d

Browse files
committed
Add call stack backtrace debug output on faults
1 parent 4c23372 commit 2b61f9d

14 files changed

Lines changed: 474 additions & 23 deletions

cores/nRF5/Arduino.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ void loop( void ) ;
160160
#ifdef __cplusplus
161161
#include "Uart.h"
162162
#include "rtos.h"
163+
void check_and_report_fault();
164+
void dump_call_stack();
163165
#endif // __cplusplus
164166

165167
#endif // Arduino_h

cores/nRF5/freertos/FreeRTOS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@
431431
#endif
432432

433433
#ifndef configRECORD_STACK_HIGH_ADDRESS
434-
#define configRECORD_STACK_HIGH_ADDRESS 0
434+
#define configRECORD_STACK_HIGH_ADDRESS 1
435435
#endif
436436

437437
#ifndef configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H

cores/nRF5/freertos/task.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,6 +3045,12 @@ TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
30453045
void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
30463046

30473047

3048+
/** [N-able ADDED] Backtrace capture code for fault handler **/
3049+
#if ( configRECORD_STACK_HIGH_ADDRESS == 1 )
3050+
uint32_t ulGetCurrentStackLowAddress(void);
3051+
uint32_t ulGetCurrentStackHighAddress(void);
3052+
#endif /* configRECORD_STACK_HIGH_ADDRESS */
3053+
30483054
/* *INDENT-OFF* */
30493055
#ifdef __cplusplus
30503056
}

cores/nRF5/freertos/tasks.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5393,3 +5393,24 @@ static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
53935393
#endif
53945394

53955395
#endif /* if ( configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H == 1 ) */
5396+
5397+
/** [N-able ADDED] Backtrace capture code for fault handler **/
5398+
#if ( configRECORD_STACK_HIGH_ADDRESS == 1 )
5399+
uint32_t ulGetCurrentStackLowAddress(void)
5400+
{
5401+
if (pxCurrentTCB != NULL)
5402+
{
5403+
return (uint32_t)pxCurrentTCB->pxStack;
5404+
}
5405+
return 0;
5406+
}
5407+
5408+
uint32_t ulGetCurrentStackHighAddress(void)
5409+
{
5410+
if (pxCurrentTCB != NULL)
5411+
{
5412+
return (uint32_t)pxCurrentTCB->pxEndOfStack;
5413+
}
5414+
return 0;
5415+
}
5416+
#endif /* configRECORD_STACK_HIGH_ADDRESS */

cores/nRF5/nordic/linker/nrf52833_s140_v7_adabl.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x74000 - 0x27000 - 0x4000
99
USER_STORE (rw) : ORIGIN = 0x74000 - 0x4000, LENGTH = 0x2000
1010
BOND_STORE (rw) : ORIGIN = 0x74000 - 0x2000, LENGTH = 0x2000
11-
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20000 - 0x6000
11+
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x20000 - 0x6000 - 0x100
1212
}

cores/nRF5/nordic/linker/nrf52833_serial_adabl.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 0x74000 - 0x1000 - 0x4000
99
USER_STORE (rw) : ORIGIN = 0x70000, LENGTH = 0x2000
1010
BOND_STORE (rw) : ORIGIN = 0x72000, LENGTH = 0x2000
11-
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x20000 - 0x8
11+
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x20000 - 0x8 - 0x100
1212
}
1313

1414

cores/nRF5/nordic/linker/nrf52833_xxaa.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MEMORY
99
USER_STORE (rw) : ORIGIN = 0x7C000, LENGTH = 0x2000
1010
BOND_STORE (rw) : ORIGIN = 0x7E000, LENGTH = 0x2000
1111
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000
12-
CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x20000
12+
CODE_RAM (rwx) : ORIGIN = 0x800000, LENGTH = 0x20000 - 0x100
1313
}
1414

1515

cores/nRF5/nordic/linker/nrf52840_dongle.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xDB000
99
USER_STORE (rw) : ORIGIN = 0xDC000, LENGTH = 0x2000
1010
BOND_STORE (rw) : ORIGIN = 0xDE000, LENGTH = 0x2000
11-
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x40000 - 0x8
11+
RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x40000 - 0x8 - 0x100
1212
}
1313

1414

cores/nRF5/nordic/linker/nrf52840_s140_v6_adabl.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xF4000 - 0x26000 - 0x4000
99
USER_STORE (rw) : ORIGIN = 0xF4000 - 0x4000, LENGTH = 0x2000
1010
BOND_STORE (rw) : ORIGIN = 0xF4000 - 0x2000, LENGTH = 0x2000
11-
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x40000 - 0x6000
11+
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x40000 - 0x6000 - 0x100
1212
}
1313

1414
INCLUDE "nrf52_common.ld"

cores/nRF5/nordic/linker/nrf52840_s140_v7_adabl.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ MEMORY
88
FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xF4000 - 0x27000 - 0x4000
99
USER_STORE (rw) : ORIGIN = 0xF4000 - 0x4000, LENGTH = 0x2000
1010
BOND_STORE (rw) : ORIGIN = 0xF4000 - 0x2000, LENGTH = 0x2000
11-
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x40000 - 0x6000
11+
RAM (rwx) : ORIGIN = 0x20006000, LENGTH = 0x40000 - 0x6000 - 0x100
1212
}
1313

1414
INCLUDE "nrf52_common.ld"

0 commit comments

Comments
 (0)