From 36a2e0e8c58d57fea7450b6cbe94e199593fa5b1 Mon Sep 17 00:00:00 2001
From: rebane <rebane@yoga.ee>
Date: Fri, 19 Aug 2016 08:48:44 +0300
Subject: [PATCH] separate cortex.ocd file

---
 Makefile          |  2 +-
 cortex/cortex.ocd | 10 ++++++++++
 rtl8710.ocd       |  9 ---------
 3 files changed, 11 insertions(+), 10 deletions(-)
 create mode 100644 cortex/cortex.ocd

diff --git a/Makefile b/Makefile
index c51a48b..4581f9a 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ clean:
 	rm -rf $(FILENAME_PREFIX).bin $(FILENAME_PREFIX).elf
 
 install:
-	openocd -f interface/stlink-v2-1.cfg -f rtl8710.ocd -c "init" -c "reset halt" -c "load_image $(FILENAME_PREFIX).bin $(ADDRESS) bin" -c "cortex_start $(ADDRESS)" -c "shutdown"
+	openocd -f interface/stlink-v2-1.cfg -f rtl8710.ocd -f cortex/cortex.ocd -c "init" -c "reset halt" -c "load_image $(FILENAME_PREFIX).bin $(ADDRESS) bin" -c "cortex_bootstrap $(ADDRESS)" -c "shutdown"
 
 reset:
 	openocd -f interface/stlink-v2-1.cfg -f rtl8710.ocd -c "init" -c "reset halt" -c "reset run" -c "shutdown"
diff --git a/cortex/cortex.ocd b/cortex/cortex.ocd
new file mode 100644
index 0000000..e1d1b47
--- /dev/null
+++ b/cortex/cortex.ocd
@@ -0,0 +1,10 @@
+proc cortex_bootstrap {start} {
+	# disable interrupts
+	reg faultmask 0x01
+	set vectors ""
+	mem2array vectors 32 $start 2
+	reg sp $vectors(0)
+	reg pc $vectors(1)
+	resume
+}
+
diff --git a/rtl8710.ocd b/rtl8710.ocd
index 1c0f2e4..f772c92 100644
--- a/rtl8710.ocd
+++ b/rtl8710.ocd
@@ -46,12 +46,3 @@ if {![using_hla]} {
    cortex_m reset_config sysresetreq
 }
 
-proc cortex_start {address} {
-	reg faultmask 0x01
-	set vectors ""
-	mem2array vectors 32 $address 2
-	reg sp $vectors(0)
-	reg pc $vectors(1)
-	resume
-}
-