Store the masked chip_id in the stlink structure. Should fix unexpected
[fw/stlink] / flash / main.c
index 39910b63665ad388c658951ad43bf6db7639571b..d61b22bd06f424978482b83e3ebfe2f07d69cc3b 100644 (file)
@@ -91,14 +91,14 @@ int main(int ac, char** av)
   if (o.devname != NULL) /* stlinkv1 */
   {
     sl = stlink_v1_open(50);
-    sl->verbose = 50;
     if (sl == NULL) goto on_error;
+    sl->verbose = 50;
   }
   else /* stlinkv2 */
   {
     sl = stlink_open_usb(50);
-    sl->verbose = 50;
     if (sl == NULL) goto on_error;
+    sl->verbose = 50;
   }
 
   if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
@@ -107,8 +107,6 @@ int main(int ac, char** av)
   if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE)
     stlink_enter_swd_mode(sl);
 
-  stlink_reset(sl);
-
   if (o.do_read == 0) /* write */
   {
     err = stlink_fwrite_flash(sl, o.filename, o.addr);
@@ -134,8 +132,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);
   }