aboutsummaryrefslogtreecommitdiff
path: root/src/stm32f1.c
diff options
context:
space:
mode:
authorGareth McMullin2015-03-08 12:55:59 -0700
committerGareth McMullin2015-03-19 07:48:47 -0700
commitc2462a6788c119edd9995fa46f1316a9c0431e0b (patch)
treeef75072d2228b362f535efcf3839b7d56aa3253a /src/stm32f1.c
parente380ced5171dc3c9098005924f61051a43b79428 (diff)
Add cortexm generic stub call, and use in stm32f1 driver.
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)