Modify shutdown seqeunce. Now a F107 in sleep mode reacts on the reset pin after...
authorUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Tue, 13 Dec 2011 17:41:07 +0000 (18:41 +0100)
committerUwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
Tue, 13 Dec 2011 17:41:07 +0000 (18:41 +0100)
flash/main.c
src/stlink-common.c
src/stlink-common.h

index 609a6f7d3b7b549afe2953077656d3535ed7dfb3..106e52c2917a9d9605f3103b78136b3ed03aac44 100644 (file)
@@ -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);
   }
 
index 8bc2a8bf02b0a84d0f409f7bf52487a8aa7af2c2..74c5bcc7c4fa65e5e403b25f03f338321d7164d6 100644 (file)
@@ -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);
 }
 
index a9834a476ca10b51b1ee4e98735850035ebf7e4f..a1442f366cd3ab0738e9522c0aa9921dc3cbe2d7 100644 (file)
@@ -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