Changes: [PATCH 1/2] - move dsp563xx_target_create and dsp563xx_target_create function - separate register cache initialization to dsp563xx_build_reg_cache function - add dsp563xx_examine function and print out correct dsp variant
[PATCH 2/2] - fix wrong target status return value on jtag communication errors - check the static pattern in jtag status to verify that the value is almost correct, this check fail if no target is present Regards, Mathias
>From 10c511d919ad5e9ea1c5c82ba4e845fd6357d945 Mon Sep 17 00:00:00 2001 From: Mathias K. <[email protected]> Date: Wed, 16 Feb 2011 15:00:06 +0100 Subject: [PATCH 1/2] - move dsp563xx_target_create and dsp563xx_target_create function - separate register cache initialization to dsp563xx_build_reg_cache function - add dsp563xx_examine function and print out correct dsp variant --- src/target/dsp563xx.c | 132 ++++++++++++++++++++++++++++++------------------ 1 files changed, 82 insertions(+), 50 deletions(-) diff --git a/src/target/dsp563xx.c b/src/target/dsp563xx.c index 603ccd8..04ac7d4 100644 --- a/src/target/dsp563xx.c +++ b/src/target/dsp563xx.c @@ -328,21 +328,6 @@ static int dsp563xx_write_core_reg(struct target *target, int num) return ERROR_OK; } -static int dsp563xx_target_create(struct target *target, Jim_Interp * interp) -{ - struct dsp563xx_common *dsp563xx = calloc(1, sizeof(struct dsp563xx_common)); - - if (!dsp563xx) - return ERROR_INVALID_ARGUMENTS; - - dsp563xx->jtag_info.tap = target->tap; - target->arch_info = dsp563xx; - dsp563xx->read_core_reg = dsp563xx_read_core_reg; - dsp563xx->write_core_reg = dsp563xx_write_core_reg; - - return ERROR_OK; -} - static int dsp563xx_get_core_reg(struct reg *reg) { struct dsp563xx_core_reg *dsp563xx_reg = reg->arch_info; @@ -379,6 +364,48 @@ static int dsp563xx_set_core_reg(struct reg *reg, uint8_t * buf) return ERROR_OK; } +static const struct reg_arch_type dsp563xx_reg_type = { + .get = dsp563xx_get_core_reg, + .set = dsp563xx_set_core_reg, +}; + +static void dsp563xx_build_reg_cache(struct target *target) +{ + struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target); + + struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache); + struct reg_cache *cache = malloc(sizeof(struct reg_cache)); + struct reg *reg_list = malloc(sizeof(struct reg) * DSP563XX_NUMCOREREGS); + struct dsp563xx_core_reg *arch_info = malloc(sizeof(struct dsp563xx_core_reg) * DSP563XX_NUMCOREREGS); + int i; + + /* Build the process context cache */ + cache->name = "dsp563xx registers"; + cache->next = NULL; + cache->reg_list = reg_list; + cache->num_regs = DSP563XX_NUMCOREREGS; + (*cache_p) = cache; + dsp563xx->core_cache = cache; + + for (i = 0; i < DSP563XX_NUMCOREREGS; i++) + { + arch_info[i].num = dsp563xx_regs[i].id; + arch_info[i].name = dsp563xx_regs[i].name; + arch_info[i].size = dsp563xx_regs[i].bits; + arch_info[i].eame = dsp563xx_regs[i].eame; + arch_info[i].instr_mask = dsp563xx_regs[i].instr_mask; + arch_info[i].target = target; + arch_info[i].dsp563xx_common = dsp563xx; + reg_list[i].name = dsp563xx_regs[i].name; + reg_list[i].size = dsp563xx_regs[i].bits; + reg_list[i].value = calloc(1, 4); + reg_list[i].dirty = 0; + reg_list[i].valid = 0; + reg_list[i].type = &dsp563xx_reg_type; + reg_list[i].arch_info = &arch_info[i]; + } +} + static int dsp563xx_read_register(struct target *target, int num, int force); static int dsp563xx_write_register(struct target *target, int num, int force); @@ -771,48 +798,52 @@ static void dsp563xx_invalidate_x_context(struct target *target, uint32_t addr_s } } -static const struct reg_arch_type dsp563xx_reg_type = { - .get = dsp563xx_get_core_reg, - .set = dsp563xx_set_core_reg, -}; +static int dsp563xx_target_create(struct target *target, Jim_Interp * interp) +{ + struct dsp563xx_common *dsp563xx = calloc(1, sizeof(struct dsp563xx_common)); + + if (!dsp563xx) + return ERROR_INVALID_ARGUMENTS; + + dsp563xx->jtag_info.tap = target->tap; + target->arch_info = dsp563xx; + dsp563xx->read_core_reg = dsp563xx_read_core_reg; + dsp563xx->write_core_reg = dsp563xx_write_core_reg; + + return ERROR_OK; +} static int dsp563xx_init_target(struct command_context *cmd_ctx, struct target *target) { - /* get pointers to arch-specific information */ - struct dsp563xx_common *dsp563xx = target_to_dsp563xx(target); + LOG_DEBUG("%s", __FUNCTION__); - struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache); - struct reg_cache *cache = malloc(sizeof(struct reg_cache)); - struct reg *reg_list = malloc(sizeof(struct reg) * DSP563XX_NUMCOREREGS); - struct dsp563xx_core_reg *arch_info = malloc(sizeof(struct dsp563xx_core_reg) * DSP563XX_NUMCOREREGS); - int i; + dsp563xx_build_reg_cache(target); - LOG_DEBUG("%s", __FUNCTION__); + return ERROR_OK; +} - /* Build the process context cache */ - cache->name = "dsp563xx registers"; - cache->next = NULL; - cache->reg_list = reg_list; - cache->num_regs = DSP563XX_NUMCOREREGS; - (*cache_p) = cache; - dsp563xx->core_cache = cache; +static int dsp563xx_examine(struct target *target) +{ + uint32_t chip; - for (i = 0; i < DSP563XX_NUMCOREREGS; i++) + if (target->tap->hasidcode == false) { - arch_info[i].num = dsp563xx_regs[i].id; - arch_info[i].name = dsp563xx_regs[i].name; - arch_info[i].size = dsp563xx_regs[i].bits; - arch_info[i].eame = dsp563xx_regs[i].eame; - arch_info[i].instr_mask = dsp563xx_regs[i].instr_mask; - arch_info[i].target = target; - arch_info[i].dsp563xx_common = dsp563xx; - reg_list[i].name = dsp563xx_regs[i].name; - reg_list[i].size = dsp563xx_regs[i].bits; - reg_list[i].value = calloc(1, 4); - reg_list[i].dirty = 0; - reg_list[i].valid = 0; - reg_list[i].type = &dsp563xx_reg_type; - reg_list[i].arch_info = &arch_info[i]; + LOG_ERROR("no IDCODE present on device"); + + return ERROR_INVALID_ARGUMENTS; + } + + if (!target_was_examined(target)) + { + target_set_examined(target); + + /* examine core and chip derivate number */ + chip = (target->tap->idcode>>12)&0x3ff; + /* core number 0 means DSP563XX */ + if ( ((chip>>5)&0x1f) == 0 ) + chip += 300; + + LOG_INFO("DSP56%03d device found",chip); } return ERROR_OK; @@ -937,7 +968,7 @@ static int dsp563xx_poll(struct target *target) if ((err = dsp563xx_debug_init(target)) != ERROR_OK) return err; - LOG_DEBUG("target->state: %s", target_state_name(target)); + LOG_DEBUG("target->state: %s (%x)", target_state_name(target),once_status); } } @@ -1571,4 +1602,5 @@ struct target_type dsp563xx_target = { .commands = dsp563xx_command_handlers, .target_create = dsp563xx_target_create, .init_target = dsp563xx_init_target, + .examine = dsp563xx_examine, }; -- 1.7.3.4
>From 6b9fd6833f710504cbed46725af7c3953940b0d6 Mon Sep 17 00:00:00 2001 From: Mathias K. <[email protected]> Date: Wed, 16 Feb 2011 15:05:37 +0100 Subject: [PATCH 2/2] - fix wrong target status return value on jtag communication errors - check the static pattern in jtag status to verify that the value is almost correct, this check fail if no target is present --- src/target/dsp563xx_once.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/target/dsp563xx_once.c b/src/target/dsp563xx_once.c index bb896c5..677e2f6 100644 --- a/src/target/dsp563xx_once.c +++ b/src/target/dsp563xx_once.c @@ -29,6 +29,9 @@ #include "dsp563xx.h" #include "dsp563xx_once.h" +#define JTAG_STATUS_STATIC_MASK 0x03 +#define JTAG_STATUS_STATIC_VALUE 0x01 + #define JTAG_STATUS_NORMAL 0x01 #define JTAG_STATUS_STOPWAIT 0x05 #define JTAG_STATUS_BUSY 0x09 @@ -100,19 +103,16 @@ int dsp563xx_once_target_status(struct jtag_tap *tap) uint8_t jtag_status; if ((err = dsp563xx_jtag_sendinstr(tap, &jtag_status, JTAG_INSTR_ENABLE_ONCE)) != ERROR_OK) - return err; + return TARGET_UNKNOWN; if ((err = jtag_execute_queue()) != ERROR_OK) - return err; + return TARGET_UNKNOWN; - if ((jtag_status & 1) != 1) - { + /* verify correct static status pattern */ + if ( (jtag_status & JTAG_STATUS_STATIC_MASK) != JTAG_STATUS_STATIC_VALUE ) return TARGET_UNKNOWN; - } if (jtag_status != JTAG_STATUS_DEBUG) - { return TARGET_RUNNING; - } return TARGET_HALTED; } -- 1.7.3.4
_______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
