Skip to content

Commit bd413f1

Browse files
committed
Disable write buffer in debug builds (M3/M4)
As part of work to improve the debugging of exceptions, have Mbed OS make an effort to make exceptions more precise in debug builds at the cost of performance. Related pyOCD work: pyocd/pyOCD#430
1 parent f04904c commit bd413f1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

platform/mbed_application.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ void mbed_start_application(uintptr_t address)
7171
powerdown_scb(address);
7272
mbed_mpu_free();
7373

74+
#ifdef MBED_DEBUG
75+
// Configs to make debugging easier
76+
#ifdef SCnSCB_ACTLR_DISDEFWBUF_Msk
77+
// Disable write buffer to make BusFaults (eg write to ROM via NULL pointer) precise.
78+
// Possible on Cortex-M3 and M4, not on M0, M7 or M33.
79+
// Would be less necessary if ROM was write-protected in MPU to give a
80+
// precise MemManage exception.
81+
SCnSCB->ACTLR |= SCnSCB_ACTLR_DISDEFWBUF_Msk;
82+
#endif
83+
#endif
84+
7485
sp = *((void **)address + 0);
7586
pc = *((void **)address + 1);
7687
start_new_application(sp, pc);

0 commit comments

Comments
 (0)