Skip to content

Commit c352488

Browse files
author
Seppo Takalo
committed
Disable write buffering on debug builds.
In mbed_start_application() there was a code that was supposed to set DISDEFWBUF to one when running a debug build. However, this code was in the wrong place, as this function is only called from bootloader. Move the code to correct place so that standalone applications use it as well. For the reference of DISDEFWBUF bit, see http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/CHDCBHEE.html
1 parent 44add98 commit c352488

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

platform/source/mbed_application.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ void mbed_start_application(uintptr_t address)
7171
powerdown_scb(address);
7272
mbed_mpu_manager_deinit();
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-
8574
sp = *((void **)address + 0);
8675
pc = *((void **)address + 1);
8776
start_new_application(sp, pc);

platform/source/mbed_sdk_boot.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ void mbed_copy_nvic(void)
7777

7878
void mbed_init(void)
7979
{
80+
#ifdef MBED_DEBUG
81+
// Configs to make debugging easier
82+
#ifdef SCnSCB_ACTLR_DISDEFWBUF_Msk
83+
// Disable write buffer to make BusFaults (eg write to ROM via NULL pointer) precise.
84+
// Possible on Cortex-M3 and M4, not on M0, M7 or M33.
85+
// Would be less necessary if ROM was write-protected in MPU to give a
86+
// precise MemManage exception.
87+
SCnSCB->ACTLR |= SCnSCB_ACTLR_DISDEFWBUF_Msk;
88+
#endif
89+
#endif
8090
mbed_copy_nvic();
8191
mbed_sdk_init();
8292
#if DEVICE_USTICKER && MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT

rtos/source/TARGET_CORTEX/mbed_boot.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ uint32_t mbed_stack_isr_size = 0;
7373

7474
void mbed_init(void)
7575
{
76+
#ifdef MBED_DEBUG
77+
// Configs to make debugging easier
78+
#ifdef SCnSCB_ACTLR_DISDEFWBUF_Msk
79+
// Disable write buffer to make BusFaults (eg write to ROM via NULL pointer) precise.
80+
// Possible on Cortex-M3 and M4, not on M0, M7 or M33.
81+
// Would be less necessary if ROM was write-protected in MPU to give a
82+
// precise MemManage exception.
83+
SCnSCB->ACTLR |= SCnSCB_ACTLR_DISDEFWBUF_Msk;
84+
#endif
85+
#endif
7686
mbed_mpu_manager_init();
7787
mbed_cpy_nvic();
7888
mbed_sdk_init();

0 commit comments

Comments
 (0)