aboutsummaryrefslogtreecommitdiff
path: root/flashstub/stm32f1.c
diff options
context:
space:
mode:
Diffstat (limited to 'flashstub/stm32f1.c')
-rw-r--r--flashstub/stm32f1.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/flashstub/stm32f1.c b/flashstub/stm32f1.c
index 8370114..2268eee 100644
--- a/flashstub/stm32f1.c
+++ b/flashstub/stm32f1.c
@@ -18,6 +18,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libopencm3/stm32/flash.h"
+#include "stub.h"
+
+#define SR_ERROR_MASK 0x14
void __attribute__((naked))
stm32f1_flash_write_stub(uint16_t *dest, uint16_t *src, uint32_t size)
@@ -29,6 +32,10 @@ stm32f1_flash_write_stub(uint16_t *dest, uint16_t *src, uint32_t size)
while (FLASH_SR & FLASH_SR_BSY)
;
}
- asm("bkpt");
+
+ if (FLASH_SR & SR_ERROR_MASK)
+ stub_exit(1);
+
+ stub_exit(0);
}