From ce9f2666e92763635437466611f2daf9189a9ab8 Mon Sep 17 00:00:00 2001 From: Fabien Le Mentec Date: Sun, 16 Oct 2011 16:29:28 -0500 Subject: [PATCH] [update] flash tool, missing SWD mode entering and core reset --- flash/Makefile | 2 ++ flash/main.c | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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); -- 2.30.2