From 9ef6d28cb5751c0cf589136181569f585059a8bc Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Tue, 13 Dec 2011 18:41:07 +0100 Subject: [PATCH] Modify shutdown seqeunce. Now a F107 in sleep mode reacts on the reset pin after running stlink --- flash/main.c | 3 +-- src/stlink-common.c | 1 + src/stlink-common.h | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/flash/main.c b/flash/main.c index 609a6f7..106e52c 100644 --- a/flash/main.c +++ b/flash/main.c @@ -135,8 +135,7 @@ int main(int ac, char** av) on_error: if (sl != NULL) { - stlink_reset(sl); - stlink_run(sl); + stlink_exit_debug_mode(sl); stlink_close(sl); } diff --git a/src/stlink-common.c b/src/stlink-common.c index 8bc2a8b..74c5bcc 100644 --- a/src/stlink-common.c +++ b/src/stlink-common.c @@ -359,6 +359,7 @@ void stlink_close(stlink_t *sl) { void stlink_exit_debug_mode(stlink_t *sl) { DLOG("*** stlink_exit_debug_mode ***\n"); + stlink_write_debug32(sl, DHCSR, DBGKEY); sl->backend->exit_debug_mode(sl); } diff --git a/src/stlink-common.h b/src/stlink-common.h index a9834a4..a1442f3 100644 --- a/src/stlink-common.h +++ b/src/stlink-common.h @@ -112,6 +112,11 @@ extern "C" { /* using chip id for F4 ident, since core id is same as F1 */ #define STM32F4_CHIP_ID 0x413 +/* Cortex™-M3 Technical Reference Manual */ +/* Debug Halting Control and Status Register */ +#define DHCSR 0xe000edf0 +#define DBGKEY 0xa05f0000 + /* Enough space to hold both a V2 command or a V1 command packaged as generic scsi*/ #define C_BUF_LEN 32 -- 2.30.2