From 804a1a4f4390d5930282b3bc654c848e70acfae1 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Thu, 31 Mar 2022 13:46:29 -0400 Subject: [PATCH] stm32f4: Attach logic cleanup by making sure we only set the extra bits needed when writing DBGMCU_CR --- src/target/stm32f4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/target/stm32f4.c b/src/target/stm32f4.c index 5547660d..b73c3ee9 100644 --- a/src/target/stm32f4.c +++ b/src/target/stm32f4.c @@ -313,8 +313,8 @@ static bool stm32f4_attach(target *t) priv_storage->dbgmcu_cr = target_mem_read32(t, DBGMCU_CR); t->target_storage = (void*)priv_storage; /* Enable debugging during all low power modes*/ - target_mem_write32(t, DBGMCU_CR, DBGMCU_CR_DBG_SLEEP | - DBGMCU_CR_DBG_STANDBY | DBGMCU_CR_DBG_STOP); + target_mem_write32(t, DBGMCU_CR, priv_storage->dbgmcu_cr | + DBGMCU_CR_DBG_SLEEP | DBGMCU_CR_DBG_STANDBY | DBGMCU_CR_DBG_STOP); /* Free previously loaded memory map */ target_mem_map_free(t);