Skip to content

Commit 7bf2fbd

Browse files
author
Cruz Monrreal
authored
Merge pull request #8655 from kjbracey-arm/debug-wb-off
Disable write buffer in debug builds (M3/M4)
2 parents 2697913 + bd413f1 commit 7bf2fbd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmsis/TARGET_CORTEX_M/core_cm3.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ typedef struct
668668
#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */
669669

670670
/* Auxiliary Control Register Definitions */
671-
671+
#if defined (__CM3_REV) && (__CM3_REV >= 0x200U)
672672
#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */
673673
#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */
674674

@@ -677,6 +677,7 @@ typedef struct
677677

678678
#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */
679679
#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */
680+
#endif
680681

681682
/*@} end of group CMSIS_SCnotSCB */
682683

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)