From: Uwe Bonnes Date: Tue, 13 Dec 2011 17:41:07 +0000 (+0100) Subject: Modify shutdown seqeunce. Now a F107 in sleep mode reacts on the reset pin after... X-Git-Url: https://git.gag.com/?p=fw%2Fstlink;a=commitdiff_plain;h=9ef6d28cb5751c0cf589136181569f585059a8bc Modify shutdown seqeunce. Now a F107 in sleep mode reacts on the reset pin after running stlink --- 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