aboutsummaryrefslogtreecommitdiff
path: root/flashstub/stm32f1.c
diff options
context:
space:
mode:
authorGareth McMullin2015-03-08 15:02:38 -0700
committerGareth McMullin2015-03-19 21:49:09 -0700
commit8ddb186b35267e90832deb2db4b0c58f77de4b87 (patch)
tree58f6cf40b653374df7086cf6a4cff236a9eacd2c /flashstub/stm32f1.c
parent437aedda11a112407af7b3f7884090023944faef (diff)
Allow stub to return an error code.
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);
}