X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Ftarget%2Fcortex_m.c;h=81d6ccf4f5a4ed3d69212ed3f5072a13151f7f40;hb=6663a788a53ee38f2d6950fe7802eae7855e01f3;hp=74505a85e1b669168640eaae4cf0ec7fa1f8b9c3;hpb=39f3501afbf750d08da898317dc22742cc056f43;p=fw%2Fopenocd diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 74505a85e..81d6ccf4f 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -973,6 +973,14 @@ static int cortex_m3_assert_reset(struct target *target) return retval; } + /* If the processor is sleeping in a WFI or WFE instruction, the + * C_HALT bit must be asserted to regain control */ + if (cortex_m3->dcb_dhcsr & S_SLEEP) { + retval = mem_ap_write_u32(swjdp, DCB_DHCSR, DBGKEY | C_HALT | C_DEBUGEN); + if (retval != ERROR_OK) + return retval; + } + retval = mem_ap_write_u32(swjdp, DCB_DCRDR, 0); if (retval != ERROR_OK) return retval;