Skip to content

Disable write buffer in debug builds (M3/M4) #8655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmsis/TARGET_CORTEX_M/core_cm3.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ typedef struct
#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */

/* Auxiliary Control Register Definitions */

#if defined (__CM3_REV) && (__CM3_REV >= 0x200U)
#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */
#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */

Expand All @@ -677,6 +677,7 @@ typedef struct

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

/*@} end of group CMSIS_SCnotSCB */

Expand Down
11 changes: 11 additions & 0 deletions platform/mbed_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ void mbed_start_application(uintptr_t address)
powerdown_scb(address);
mbed_mpu_free();

#ifdef MBED_DEBUG
// Configs to make debugging easier
#ifdef SCnSCB_ACTLR_DISDEFWBUF_Msk
// Disable write buffer to make BusFaults (eg write to ROM via NULL pointer) precise.
// Possible on Cortex-M3 and M4, not on M0, M7 or M33.
// Would be less necessary if ROM was write-protected in MPU to give a
// precise MemManage exception.
SCnSCB->ACTLR |= SCnSCB_ACTLR_DISDEFWBUF_Msk;
#endif
#endif

sp = *((void **)address + 0);
pc = *((void **)address + 1);
start_new_application(sp, pc);
Expand Down