aboutsummaryrefslogtreecommitdiff
path: root/contrib/loaders
diff options
context:
space:
mode:
authorAngus Gratton <gus@projectgus.com>2014-06-27 16:13:24 +1000
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2015-02-11 22:00:46 +0000
commit233f8859c0e5d0f6b94beba5435b56bda27c30e1 (patch)
tree283fd8d467f732ad66a1a23de184a2fdb54961d8 /contrib/loaders
parentb2dc1af59a4cead2bd9446256ef31658b2a5de61 (diff)
nrf51 - Add async loader. Performance on nrf51822QAA/stlink-v2 from ~3.5KiB/s to ~19.5KiB/s.
Change-Id: Ib0bf41a0cec85f0bd5728551f8ad7f6255e4ea04 Signed-off-by: Angus Gratton <gus@projectgus.com> [spamjunkeater@gmail.com: Cleanup buffer allocation, detect -1 for unknown pages] Signed-off-by: Erdem U. Altunyurt <spamjunkeater@gmail.com> Signed-off-by: Paul Fertser <fercerpav@gmail.com> Reviewed-on: http://openocd.zylin.com/2204 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Diffstat (limited to 'contrib/loaders')
-rw-r--r--contrib/loaders/flash/cortex-m0.S72
1 files changed, 72 insertions, 0 deletions
diff --git a/contrib/loaders/flash/cortex-m0.S b/contrib/loaders/flash/cortex-m0.S
new file mode 100644
index 00000000..a905a362
--- /dev/null
+++ b/contrib/loaders/flash/cortex-m0.S
@@ -0,0 +1,72 @@
+/***************************************************************************
+ * Copyright (C) 2014 by Angus Gratton *
+ * Derived from stm32f1x.S:
+ * Copyright (C) 2011 by Andreas Fritiofson *
+ * andreas.fritiofson@gmail.com *
+ * Copyright (C) 2013 by Roman Dmitrienko *
+ * me@iamroman.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. *
+ ***************************************************************************/
+ .text
+ .syntax unified
+ .cpu cortex-m0
+ .thumb
+ .thumb_func
+
+/* Written for NRF51822 (src/flash/nor/nrf51.c) however the NRF NVMC is
+ * very generic (CPU blocks during flash writes), so this is actually
+ * just a generic word-oriented copy routine for cortex-m0 (also
+ * suitable for cortex m0plus/m3/m4.)
+ *
+ * To assemble:
+ * arm-none-eabi-gcc -c cortex-m0.S
+ *
+ * To disassemble:
+ * arm-none-eabi-objdump -o cortex-m0.o
+ *
+ * Thanks to Jens Bauer for providing advice on some of the tweaks.
+ */
+
+ /* Params:
+ * r0 - byte count (in)
+ * r1 - workarea start
+ * r2 - workarea end
+ * r3 - target address
+ * Clobbered:
+ * r4 - rp
+ * r5 - wp, tmp
+ */
+
+wait_fifo:
+ ldr r5, [r1, #0] /* read wp */
+ cmp r5, #0 /* abort if wp == 0 */
+ beq exit
+ ldr r4, [r1, #4] /* read rp */
+ cmp r4, r5 /* wait until rp != wp */
+ beq wait_fifo
+
+ ldmia r4!, {r5} /* "*target_address++ = *rp++" */
+ stmia r3!, {r5}
+
+ cmp r4, r2 /* wrap rp at end of work area buffer */
+ bcc no_wrap
+ mov r4, r1
+ adds r4, #8 /* skip rp,wp at start of work area */
+no_wrap:
+ str r4, [r1, #4] /* write back rp */
+ subs r0, #4 /* decrement byte count */
+ bne wait_fifo /* loop if not done */
+exit:
+ bkpt #0