Find the flash controller by position since it is before the core,
not after it.

This fixes the problem that str9xpec enable_turbo (or any other 
str9xpec command) did not work. (See my post in 
http://forum.sparkfun.com/viewtopic.php?f=18&t=25542)

Signed-off-by: Santeri Salko <santeri.sa...@gmail.com>
---
 src/flash/nor/str9xpec.c |    3 ++-
 src/jtag/core.c          |    2 +-
 src/jtag/jtag.h          |    1 +
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/flash/nor/str9xpec.c b/src/flash/nor/str9xpec.c
index 18761c2..c06e6d1 100644
--- a/src/flash/nor/str9xpec.c
+++ b/src/flash/nor/str9xpec.c
@@ -306,7 +306,8 @@ FLASH_BANK_COMMAND_HANDLER(str9xpec_flash_bank_command)
        arm7_9 = armv4_5->arch_info;
        jtag_info = &arm7_9->jtag_info;
 
-       str9xpec_info->tap = bank->target->tap;
+       /* The core is the next tap after the flash controller in the chain */
+       str9xpec_info->tap = 
jtag_tap_by_position(jtag_info->tap->abs_chain_position - 1);
        str9xpec_info->isc_enable = 0;
 
        str9xpec_build_block_list(bank);
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 0c222db..d7e1cce 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -216,7 +216,7 @@ void jtag_tap_add(struct jtag_tap *t)
 }
 
 /* returns a pointer to the n-th device in the scan chain */
-static inline struct jtag_tap *jtag_tap_by_position(unsigned n)
+struct jtag_tap *jtag_tap_by_position(unsigned n)
 {
        struct jtag_tap *t = jtag_all_taps();
 
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index df01537..6709cf7 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -173,6 +173,7 @@ struct jtag_tap* jtag_all_taps(void);
 const char *jtag_tap_name(const struct jtag_tap *tap);
 struct jtag_tap* jtag_tap_by_string(const char* dotted_name);
 struct jtag_tap* jtag_tap_by_jim_obj(Jim_Interp* interp, Jim_Obj* obj);
+struct jtag_tap* jtag_tap_by_position(unsigned abs_position);
 struct jtag_tap* jtag_tap_next_enabled(struct jtag_tap* p);
 unsigned jtag_tap_count_enabled(void);
 unsigned jtag_tap_count(void);
-- 
1.7.0.4

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to