From: Fabien Le Mentec Date: Sun, 16 Oct 2011 21:29:28 +0000 (-0500) Subject: [update] flash tool, missing SWD mode entering and core reset X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=ce9f2666e92763635437466611f2daf9189a9ab8;p=fw%2Fstlink [update] flash tool, missing SWD mode entering and core reset --- diff --git a/flash/Makefile b/flash/Makefile index fe0dff7..aee2f37 100644 --- a/flash/Makefile +++ b/flash/Makefile @@ -1,3 +1,5 @@ +CC=gcc + CFLAGS+=-g CFLAGS+=-DCONFIG_USE_LIBUSB CFLAGS+=-DCONFIG_USE_LIBSG diff --git a/flash/main.c b/flash/main.c index c8b15e0..5233405 100644 --- a/flash/main.c +++ b/flash/main.c @@ -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);