aboutsummaryrefslogtreecommitdiff
path: root/src/stm32f1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32f1.c')
-rw-r--r--src/stm32f1.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/stm32f1.c b/src/stm32f1.c
index 0e87c21..daba1b0 100644
--- a/src/stm32f1.c
+++ b/src/stm32f1.c
@@ -32,9 +32,12 @@
#include "general.h"
#include "adiv5.h"
#include "target.h"
+#include "cortexm.h"
#include "command.h"
#include "gdb_packet.h"
+#define SRAM_BASE 0x20000000
+
static bool stm32f1_cmd_erase_mass(target *t);
static bool stm32f1_cmd_option(target *t, int argc, char *argv[]);
@@ -257,15 +260,9 @@ static int stm32f1_flash_write(struct target_s *target, uint32_t dest,
memcpy((uint8_t *)&data[2] + offset, src, len);
/* Write stub and data to target ram and set PC */
- target_mem_write(target, 0x20000000, stm32f1_flash_write_stub, 0x2C);
target_mem_write(target, 0x2000002C, data, sizeof(data));
- target_pc_write(target, 0x20000000);
- if(target_check_error(target))
- return -1;
-
- /* Execute the stub */
- target_halt_resume(target, 0);
- while(!target_halt_wait(target));
+ cortexm_run_stub(target, SRAM_BASE, stm32f1_flash_write_stub, 0x2C,
+ 0, 0, 0, 0);
/* Check for error */
if (target_mem_read32(target, FLASH_SR) & SR_ERROR_MASK)