When loading a file to SRAM or Flash, set the Stack pointer with the initial

SP value and the Program counter with the reset value from the Vector
table. Then run reset function
pull/49/head
Uwe Bonnes 2012-01-19 14:17:22 +01:00
rodzic 4c206c3b7c
commit 41e7c16cf2
1 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -799,6 +799,11 @@ int stlink_fwrite_sram
/* success */
error = 0;
/* set stack*/
stlink_write_reg(sl, stlink_read_debug32(sl, addr ),13);
/* Set PC to the reset routine*/
stlink_write_reg(sl, stlink_read_debug32(sl, addr + 4),15);
stlink_run(sl);
on_error:
unmap_file(&mf);
@ -1514,6 +1519,11 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) {
mf.len -= num_empty;
}
err = stlink_write_flash(sl, addr, mf.base, mf.len);
/* set stack*/
stlink_write_reg(sl, stlink_read_debug32(sl, addr ),13);
/* Set PC to the reset routine*/
stlink_write_reg(sl, stlink_read_debug32(sl, addr + 4),15);
stlink_run(sl);
unmap_file(&mf);
return err;
}