Merge pull request #197 from rene-dev/master
[fw/stlink] / src / stlink-sg.c
index 991bc878b5bb77ccb82ec8fd28bcb6ee73ed4fb6..53e93cce086c53471e2a3a7270f45a052f7cfb77 100644 (file)
@@ -85,7 +85,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/mman.h>
+#include "mmap.h"
 
 #include "stlink-common.h"
 #include "stlink-sg.h"
@@ -872,10 +872,14 @@ stlink_backend_t _stlink_sg_backend = {
     _stlink_sg_write_mem8,
     _stlink_sg_read_all_regs,
     _stlink_sg_read_reg,
+    NULL,                   /* read_all_unsupported_regs */
+    NULL,                   /* read_unsupported_regs */
+    NULL,                   /* write_unsupported_regs */
     _stlink_sg_write_reg,
     _stlink_sg_step,
     _stlink_sg_current_mode,
-    _stlink_sg_force_debug
+    _stlink_sg_force_debug,
+    NULL
 };
 
 static stlink_t* stlink_open(const int verbose) {
@@ -1014,10 +1018,11 @@ stlink_t* stlink_v1_open_inner(const int verbose) {
             "WTF? successfully opened, but unable to read version details. BROKEN!\n");
         return NULL;
     }
+
     return sl;
 }
 
-stlink_t* stlink_v1_open(const int verbose) {
+stlink_t* stlink_v1_open(const int verbose, int reset) {
     stlink_t *sl = stlink_v1_open_inner(verbose);
     if (sl == NULL) {
         fputs("Error: could not open stlink device\n", stderr);
@@ -1025,6 +1030,11 @@ stlink_t* stlink_v1_open(const int verbose) {
     }
     // by now, it _must_ be fully open and in a useful mode....
        stlink_enter_swd_mode(sl);
+    /* Now we are ready to read the parameters  */
+    if (reset) {
+        stlink_reset(sl);
+    }
+    stlink_load_device_params(sl);
     ILOG("Successfully opened a stlink v1 debugger\n");
     return sl;
 }