Merge pull request #36 from UweBonnes/master
[fw/stlink] / flash / main.c
index 39910b63665ad388c658951ad43bf6db7639571b..106e52c2917a9d9605f3103b78136b3ed03aac44 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)
@@ -108,6 +108,7 @@ int main(int ac, char** av)
     stlink_enter_swd_mode(sl);
 
   stlink_reset(sl);
+  stlink_load_device_params(sl);
 
   if (o.do_read == 0) /* write */
   {
@@ -134,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);
   }