aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2017-11-23 11:17:53 +0100
committerTomas Vanek <vanekt@fbl.cz>2018-04-10 06:17:00 +0100
commita867e36f78be231bfdf5161ff7172bcf69aa6280 (patch)
treef818ad876f2617d4d6aee4494a86c4ba1788a63b /contrib
parenteb8912ec38c0fd6867d2b5a88b40549f791ce7bb (diff)
target armv7m: multi-block erase check
Tested on PSoC6 (Cortex-M0+ core), onboard KitProg2 in CMSIS-DAP mode, adapter_khz=1000. Plain read: flash read_bank 0 /dev/null takes 48 seconds. erase_check without this change: flash erase_check 0 takes horrible 149 seconds!! And the same command with the change applied takes 1.8 seconds. Quite a difference. Remove the erase-value=0 version of algorithm as the new one can check for any value. If the target is an insane slow clocked CPU (under 1MHz) algo timeouts. Blocks checked so far are returned and the next call uses increased timeout. Change-Id: Ic0899011256d2114112e67c0b51fab4f6230d9cd Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4298 Tested-by: jenkins Reviewed-by: Jonas Norling <jonas.norling@cyanconnode.com> Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/loaders/erase_check/Makefile2
-rw-r--r--contrib/loaders/erase_check/armv7m_0_erase_check.inc2
-rw-r--r--contrib/loaders/erase_check/armv7m_0_erase_check.s45
-rw-r--r--contrib/loaders/erase_check/armv7m_erase_check.inc4
-rw-r--r--contrib/loaders/erase_check/armv7m_erase_check.s48
5 files changed, 42 insertions, 59 deletions
diff --git a/contrib/loaders/erase_check/Makefile b/contrib/loaders/erase_check/Makefile
index 427fa0c0..1a0fd9e3 100644
--- a/contrib/loaders/erase_check/Makefile
+++ b/contrib/loaders/erase_check/Makefile
@@ -12,7 +12,7 @@ STM8_OBJCOPY ?= $(STM8_CROSS_COMPILE)objcopy
STM8_AFLAGS =
-arm: armv4_5_erase_check.inc armv7m_erase_check.inc armv7m_0_erase_check.inc
+arm: armv4_5_erase_check.inc armv7m_erase_check.inc
armv4_5_%.elf: armv4_5_%.s
$(ARM_AS) $(ARM_AFLAGS) $< -o $@
diff --git a/contrib/loaders/erase_check/armv7m_0_erase_check.inc b/contrib/loaders/erase_check/armv7m_0_erase_check.inc
deleted file mode 100644
index 76115ec1..00000000
--- a/contrib/loaders/erase_check/armv7m_0_erase_check.inc
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Autogenerated with ../../../src/helper/bin2char.sh */
-0x03,0x78,0x01,0x30,0x1a,0x43,0x01,0x39,0xfa,0xd1,0x00,0xbe,
diff --git a/contrib/loaders/erase_check/armv7m_0_erase_check.s b/contrib/loaders/erase_check/armv7m_0_erase_check.s
deleted file mode 100644
index 6b1e92a8..00000000
--- a/contrib/loaders/erase_check/armv7m_0_erase_check.s
+++ /dev/null
@@ -1,45 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2014 by Jeff Ciesielski *
- * jeffciesielski@gmail.com *
- * *
- * Based on the armv7m erase checker by: *
- * Copyright (C) 2010 by Spencer Oliver *
- * spen@spen-soft.co.uk *
- * *
- * 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. *
- * *
- ***************************************************************************/
-
-/*
- parameters:
- r0 - address in
- r1 - byte count
- r2 - mask - result out
-*/
-
- .text
- .syntax unified
- .cpu cortex-m0
- .thumb
- .thumb_func
-
- .align 2
-
-loop:
- ldrb r3, [r0]
- adds r0, #1
- orrs r2, r2, r3
- subs r1, r1, #1
- bne loop
-end:
- bkpt #0
-
- .end
diff --git a/contrib/loaders/erase_check/armv7m_erase_check.inc b/contrib/loaders/erase_check/armv7m_erase_check.inc
index 1fe25cd5..4ee96e19 100644
--- a/contrib/loaders/erase_check/armv7m_erase_check.inc
+++ b/contrib/loaders/erase_check/armv7m_erase_check.inc
@@ -1,2 +1,4 @@
/* Autogenerated with ../../../src/helper/bin2char.sh */
-0x03,0x78,0x01,0x30,0x1a,0x40,0x01,0x39,0xfa,0xd1,0x00,0xbe,
+0x02,0x68,0x12,0x42,0x0d,0xd0,0x43,0x68,0x1c,0x68,0x04,0x33,0x8c,0x42,0x05,0xd1,
+0x01,0x3a,0xf9,0xd1,0x01,0x24,0x04,0x60,0x08,0x30,0xf1,0xe7,0x00,0x24,0xfa,0xe7,
+0x00,0x00,0x00,0xbe,
diff --git a/contrib/loaders/erase_check/armv7m_erase_check.s b/contrib/loaders/erase_check/armv7m_erase_check.s
index 886e3e28..3303c877 100644
--- a/contrib/loaders/erase_check/armv7m_erase_check.s
+++ b/contrib/loaders/erase_check/armv7m_erase_check.s
@@ -20,9 +20,8 @@
/*
parameters:
- r0 - address in
- r1 - byte count
- r2 - mask - result out
+ r0 - pointer to struct { uint32_t size_in_result_out, uint32_t addr }
+ r1 - value to check
*/
.text
@@ -33,13 +32,42 @@
.align 2
-loop:
- ldrb r3, [r0]
- adds r0, #1
- ands r2, r2, r3
- subs r1, r1, #1
- bne loop
-end:
+BLOCK_SIZE_RESULT = 0
+BLOCK_ADDRESS = 4
+SIZEOF_STRUCT_BLOCK = 8
+
+start:
+block_loop:
+ ldr r2, [r0, #BLOCK_SIZE_RESULT] /* get size */
+ tst r2, r2
+ beq done
+
+ ldr r3, [r0, #BLOCK_ADDRESS] /* get address */
+
+word_loop:
+ ldr r4, [r3] /* read word */
+ adds r3, #4
+
+ cmp r4, r1
+ bne not_erased
+
+ subs r2, #1
+ bne word_loop
+
+ movs r4, #1 /* block is erased */
+save_result:
+ str r4, [r0, #BLOCK_SIZE_RESULT]
+ adds r0, #SIZEOF_STRUCT_BLOCK
+ b block_loop
+
+not_erased:
+ movs r4, #0
+ b save_result
+
+/* Avoid padding at .text segment end. Otherwise exit point check fails. */
+ .skip ( . - start + 2) & 2, 0
+
+done:
bkpt #0
.end