- armv7m_run_algorithm now requires all algorithms to use
   a software breakpoint at their exit address
 - updated all algorithms to support this

Signed-off-by: Spencer Oliver <[email protected]>
---
 src/flash/nor/at91sam3.c  |    4 +---
 src/flash/nor/lpc2000.c   |    2 +-
 src/flash/nor/stellaris.c |    3 +--
 src/flash/nor/stm32x.c    |    3 +--
 src/target/armv7m.c       |   23 +++++------------------
 5 files changed, 9 insertions(+), 26 deletions(-)

seemed crazy to not make use of the armv7m bkpt instruction.
tested on stm32 and luminary

Cheers
Spen
>From 1aaa0e0a2a16340bcda81e9b0a8541d565be66f7 Mon Sep 17 00:00:00 2001
From: Spencer Oliver <[email protected]>
Date: Wed, 13 Jan 2010 11:32:12 +0000
Subject: [PATCH] ARMv7: use software breakpoints for algorithms

 - armv7m_run_algorithm now requires all algorithms to use
   a software breakpoint at their exit address
 - updated all algorithms to support this

Signed-off-by: Spencer Oliver <[email protected]>
---
 src/flash/nor/at91sam3.c  |    4 +---
 src/flash/nor/lpc2000.c   |    2 +-
 src/flash/nor/stellaris.c |    3 +--
 src/flash/nor/stm32x.c    |    3 +--
 src/target/armv7m.c       |   23 +++++------------------
 5 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c
index 5dacf6f..699f493 100644
--- a/src/flash/nor/at91sam3.c
+++ b/src/flash/nor/at91sam3.c
@@ -2046,9 +2046,7 @@ sam3_page_write_opcodes[] = {
        0x10,0xf0,0x01,0x0f,
        //  41 0024 FBD0                beq     .L4
        0xfb,0xd0,
-       //  42                  .done:
-       //  43 0026 FEE7                b       .done
-       0xfe,0xe7
+       0x00,0xBE                               /* bkpt #0 */
 };
 
 
diff --git a/src/flash/nor/lpc2000.c b/src/flash/nor/lpc2000.c
index ae0a384..ac76493 100644
--- a/src/flash/nor/lpc2000.c
+++ b/src/flash/nor/lpc2000.c
@@ -267,7 +267,7 @@ static int lpc2000_iap_call(struct flash_bank *bank, int 
code, uint32_t param_ta
                                target_buffer_set_u32(target, jump_gate,
                                                ARMV4_5_T_BX(12));
                                target_buffer_set_u32(target, jump_gate + 4,
-                                               ARMV4_5_T_B(0xfffffe));
+                                               ARMV5_T_BKPT(0));
                                break;
                        case lpc2000_v1:
                        case lpc2000_v2:
diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c
index 8d35f9b..8083f60 100644
--- a/src/flash/nor/stellaris.c
+++ b/src/flash/nor/stellaris.c
@@ -805,8 +805,7 @@ static const uint8_t stellaris_write_code[] =
        0x04,0x36,                      /* adds r6, r6, #4 */
        0x96,0x42,                      /* cmp  r6, r2 */
        0xF4,0xD1,                      /* bne  mainloop */
-                                               /* exit: */
-       0xFE,0xE7,                      /* b exit */
+       0x00,0xBE,              /* bkpt #0 */
 /* pFLASH_CTRL_BASE: */
        0x00,0xD0,0x0F,0x40,    /* .word        0x400FD000 */
 /* FLASHWRITECMD: */
diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c
index 75dcf3b..d45df9c 100644
--- a/src/flash/nor/stm32x.c
+++ b/src/flash/nor/stm32x.c
@@ -459,8 +459,7 @@ static int stm32x_write_block(struct flash_bank *bank, 
uint8_t *buffer, uint32_t
                0x01, 0xD1,                                     /* bne  exit */
                0x01, 0x3A,                                     /* subs r2, r2, 
#1 */
                0xED, 0xD1,                                     /* bne  write */
-                                                                       /* 
exit: */
-               0xFE, 0xE7,                                     /* b exit */
+               0x00, 0xBE,                             /* bkpt #0 */
                0x10, 0x20, 0x02, 0x40,         /* STM32_FLASH_CR:      .word 
0x40022010 */
                0x0C, 0x20, 0x02, 0x40          /* STM32_FLASH_SR:      .word 
0x4002200C */
        };
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 233fb95..3972df5 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -338,6 +338,9 @@ int armv7m_run_algorithm(struct target *target,
        int retval = ERROR_OK;
        uint32_t context[ARMV7M_NUM_REGS];
 
+       /* NOTE: armv7m_run_algorithm requires that each algorithm uses a 
software breakpoint
+        * at the exit point */
+
        if (armv7m_algorithm_info->common_magic != ARMV7M_COMMON_MAGIC)
        {
                LOG_ERROR("current target isn't an ARMV7M target");
@@ -395,22 +398,8 @@ int armv7m_run_algorithm(struct target *target,
                armv7m->core_cache->reg_list[ARMV7M_CONTROL].valid = 1;
        }
 
-       /* REVISIT speed things up (3% or so in one case) by requiring
-        * algorithms to include a BKPT instruction at each exit point.
-        * This eliminates overheads of adding/removing a breakpoint.
-        */
-
-       /* ARMV7M always runs in Thumb state */
-       if ((retval = breakpoint_add(target, exit_point, 2, BKPT_SOFT)) != 
ERROR_OK)
-       {
-               LOG_ERROR("can't add breakpoint to finish algorithm execution");
-               return ERROR_TARGET_FAILURE;
-       }
-
        retval = armv7m_run_and_wait(target, entry_point, timeout_ms, 
exit_point, armv7m);
 
-       breakpoint_remove(target, exit_point);
-
        if (retval != ERROR_OK)
        {
                return retval;
@@ -582,8 +571,7 @@ int armv7m_checksum_memory(struct target *target,
                                                                /* ncomp: */
                0x429C,                                 /* cmp  r4, r3 */
                0xD1E9,                                 /* bne  nbyte */
-                                                               /* end: */
-               0xE7FE,                                 /* b    end */
+               0xBE00,                         /* bkpt #0 */
                0x1DB7, 0x04C1                  /* CRC32XOR:    .word 
0x04C11DB7 */
        };
 
@@ -647,8 +635,7 @@ int armv7m_blank_check_memory(struct target *target,
                0xEA02, 0x0203,         /* and  r2, r2, r3 */
                0x3901,                         /* subs r1, r1, #1 */
                0xD1F9,                         /* bne  loop */
-               /* end: */
-               0xE7FE,                         /* b    end */
+               0xBE00,                 /* bkpt #0 */
        };
 
        /* make sure we have a working area */
-- 
1.6.5.1.1367.gcd48

_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to