From: Peter Zotov Date: Wed, 16 Feb 2011 11:28:20 +0000 (+0300) Subject: Reset CPU before and after flash writing. X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=32045151e9551de02979bf346414eba605f6a90b;p=fw%2Fstlink Reset CPU before and after flash writing. --- diff --git a/src/gdb-server.c b/src/gdb-server.c index af78ee2..1c9cd4c 100644 --- a/src/gdb-server.c +++ b/src/gdb-server.c @@ -223,6 +223,9 @@ static int flash_populate(stm32_addr_t addr, uint8_t* data, unsigned length) { static int flash_go(struct stlink* sl) { int error = -1; + // Some kinds of clock settings do not allow writing to flash. + stlink_reset(sl); + for(struct flash_block* fb = flash_root; fb; fb = fb->next) { #ifdef DEBUG printf("flash_do: block %08x -> %04x\n", fb->addr, fb->length); @@ -236,6 +239,8 @@ static int flash_go(struct stlink* sl) { } } + stlink_reset(sl); + error = 0; error: @@ -451,8 +456,6 @@ int serve(struct stlink* sl, int port) { } else { reply = strdup("OK"); } - - stlink_reset(sl); } if(reply == NULL)