Skip to content

Commit 3bd40d3

Browse files
authored
Merge pull request #14624 from 0xc0170/fix-14432
error: use __INITIAL_SP from cmsis instead of RTX one
2 parents 47b19eb + 3003a17 commit 3bd40d3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

platform/source/mbed_error.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "platform/internal/mbed_error_hist.h"
3030
#include "drivers/MbedCRC.h"
3131
#include "mbed_rtx.h"
32+
#include "cmsis_compiler.h"
3233
#ifdef MBED_CONF_RTOS_PRESENT
3334
#include "rtx_os.h"
3435
#endif
@@ -66,6 +67,8 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
6667
static bool is_reboot_error_valid = false;
6768
#endif
6869

70+
extern uint32_t __INITIAL_SP;
71+
6972
//Helper function to halt the system
7073
static MBED_NORETURN void mbed_halt_system(void)
7174
{
@@ -518,7 +521,7 @@ static void print_stack_dump(uint32_t stack_start, uint32_t stack_size, uint32_t
518521
// PSP mode. Then SP_reg is more correct.
519522
psp_sp = mfc->SP_reg;
520523
}
521-
uint32_t msp_size = MAX(0, (int)INITIAL_SP - (int)msp_sp);
524+
uint32_t msp_size = MAX(0, (int)__INITIAL_SP - (int)msp_sp);
522525
print_stack_dump_core(msp_sp, msp_size, msp_sp, "MSP");
523526

524527
stack_sp = psp_sp;

0 commit comments

Comments
 (0)