[update] flash tool, missing SWD mode entering and core reset
authorFabien Le Mentec <texane@gmail.com>
Sun, 16 Oct 2011 21:29:28 +0000 (16:29 -0500)
committerFabien Le Mentec <texane@gmail.com>
Sun, 16 Oct 2011 21:29:28 +0000 (16:29 -0500)
flash/Makefile
flash/main.c

index fe0dff7ce4aeddd49850db3223d7a99043ffc0bb..aee2f3726d6ed83c58b45de5595ef02efac8947a 100644 (file)
@@ -1,3 +1,5 @@
+CC=gcc
+
 CFLAGS+=-g
 CFLAGS+=-DCONFIG_USE_LIBUSB
 CFLAGS+=-DCONFIG_USE_LIBSG
index c8b15e0b9631d62c846c740ae93ba90c6f7f7d26..5233405f06698f0ab4b2990a72285c06a24cb8a1 100644 (file)
@@ -14,7 +14,7 @@ int main(int ac, char** av)
   stlink_t* sl = NULL;
   stm32_addr_t addr;
   const char* path;
-  int err;
+  int err = -1;
 
   if (ac == 4) /* stlinkv1 */
   {
@@ -37,6 +37,11 @@ int main(int ac, char** av)
 
   if (sl == NULL) goto on_error;
 
+  if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
+    stlink_exit_dfu_mode(sl);
+  stlink_enter_swd_mode(sl);
+  stlink_reset(sl);
+
   err = stlink_fwrite_flash(sl, path, addr);
   if (err == -1)
   {
@@ -44,6 +49,9 @@ int main(int ac, char** av)
     goto on_error;
   }
 
+  /* success */
+  err = 0;
+
  on_error:
   if (sl != NULL) stlink_close(sl);