From 35b3c95299a97c05078f7dd662d66c89a356869d Mon Sep 17 00:00:00 2001 From: oharboe Date: Fri, 4 Apr 2008 13:47:38 +0000 Subject: [PATCH] - reverted some of the changes that possibly broke arm926ejs. Waiting for a bit more info before I can tell with confidence whether or not this would have any effect. - worked on error propagation and output for flash git-svn-id: svn://svn.berlios.de/openocd/trunk@539 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/flash/ecos.c | 7 ++--- src/flash/flash.c | 18 ++++++------ src/helper/command.c | 10 ++++++- src/helper/command.h | 14 ++++++++++ src/target/Makefile.am | 3 +- src/target/arm11.c | 4 +-- src/target/arm7_9_common.c | 47 ++++++++++++++++++++++---------- src/target/cortex_m3.c | 2 +- src/target/ecos/at91eb40a.elf | Bin 0 -> 36832 bytes src/target/target.c | 9 +++--- src/target/target/at91eb40a.cfg | 4 ++- src/target/target/zy1000.cfg | 3 +- src/target/xscale.c | 2 +- 13 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 src/target/ecos/at91eb40a.elf diff --git a/src/flash/ecos.c b/src/flash/ecos.c index f467b74d8c..8b64b2d713 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -211,10 +211,9 @@ int loadDriver(ecosflash_flash_bank_t *info) int retval; if ((retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt)) != ERROR_OK) { - LOG_ERROR("image_read_section failed with error code: %i", retval); free(buffer); image_close(&image); - return ERROR_FLASH_BANK_INVALID; + return retval; } target_write_buffer(target, image.sections[i].base_address, buf_cnt, buffer); image_size += buf_cnt; @@ -303,7 +302,7 @@ int eCosBoard_erase(ecosflash_flash_bank_t *info, u32 address, u32 len) if (flashErr != 0x0) { LOG_ERROR("Flash erase failed with %d (%s)\n", flashErr, flash_errmsg(flashErr)); - return ERROR_JTAG_DEVICE_ERROR; + return ERROR_FAIL; } return ERROR_OK; @@ -362,7 +361,7 @@ int eCosBoard_flash(ecosflash_flash_bank_t *info, void *data, u32 address, u32 l if (flashErr != 0x0) { LOG_ERROR("Flash prog failed with %d (%s)\n", flashErr, flash_errmsg(flashErr)); - return ERROR_JTAG_DEVICE_ERROR; + return ERROR_FAIL; } } return ERROR_OK; diff --git a/src/flash/flash.c b/src/flash/flash.c index 9607725834..850dcd4cb5 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -618,13 +618,12 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm if (argc < 1) { return ERROR_COMMAND_SYNTAX_ERROR; - } if (!target) { LOG_ERROR("no target selected"); - return ERROR_OK; + return ERROR_FAIL; } duration_start_measure(&duration); @@ -649,7 +648,6 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm } retval = flash_write(target, &image, &written, auto_erase); - if (retval != ERROR_OK) { image_close(&image); @@ -659,9 +657,9 @@ int handle_flash_write_image_command(struct command_context_s *cmd_ctx, char *cm duration_stop_measure(&duration, &duration_text); if (retval == ERROR_OK) { - command_print(cmd_ctx, "wrote %u byte from file %s in %s (%f kb/s)", - written, args[0], duration_text, - (float)written / 1024.0 / ((float)duration.duration.tv_sec + ((float)duration.duration.tv_usec / 1000000.0))); + command_print(cmd_ctx, "wrote %u byte from file %s in %s (%f kb/s)", + written, args[0], duration_text, + (float)written / 1024.0 / ((float)duration.duration.tv_sec + ((float)duration.duration.tv_usec / 1000000.0))); } free(duration_text); @@ -923,7 +921,7 @@ int flash_erase_address_range(target_t *target, u32 addr, u32 length) /* write (optional verify) an image to flash memory of the given target */ int flash_write(target_t *target, image_t *image, u32 *written, int erase) { - int retval; + int retval=ERROR_OK; int section; u32 section_offset; @@ -1039,14 +1037,14 @@ int flash_write(target_t *target, image_t *image, u32 *written, int erase) if (retval != ERROR_OK) { - return retval; /* abort operation */ - } + return retval; /* abort operation */ + } if (written != NULL) *written += run_size; /* add run size to total written counter */ } - return ERROR_OK; + return retval; } int handle_flash_auto_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) diff --git a/src/helper/command.c b/src/helper/command.c index 7d24d81d9e..ef5673336f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -298,6 +298,7 @@ void command_print(command_context_t *context, char *format, ...) int find_and_run_command(command_context_t *context, command_t *commands, char *words[], int num_words, int start_word) { command_t *c; + int retval = ERROR_COMMAND_SYNTAX_ERROR; if (unique_length_dirty) { @@ -321,6 +322,7 @@ int find_and_run_command(command_context_t *context, command_t *commands, char * if (!c->handler) { command_print(context, "No handler for command"); + retval = ERROR_COMMAND_SYNTAX_ERROR; break; } else @@ -330,6 +332,12 @@ int find_and_run_command(command_context_t *context, command_t *commands, char * { command_print(context, "Syntax error:"); command_print_help_line(context, c, 0); + } else if (retval != ERROR_OK) + { + /* we do not print out an error message because the command *should* + * have printed out an error + */ + LOG_DEBUG("Command failed with error code %d", retval); } return retval; } @@ -347,7 +355,7 @@ int find_and_run_command(command_context_t *context, command_t *commands, char * } command_print(context, "Command %s not found", words[start_word]); - return ERROR_OK; + return retval; } int command_run_line(command_context_t *context, char *line) diff --git a/src/helper/command.h b/src/helper/command.h index 3acb8b1821..6e6af75eb8 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -34,6 +34,20 @@ typedef struct command_context_s enum command_mode mode; struct command_s *commands; int current_target; + /* Execute a command. + * + * If the command fails, it *MUST* return a value != ERROR_OK + * (many commands break this rule, patches welcome!) + * + * This is *especially* important for commands such as writing + * to flash or verifying memory. The reason is that those commands + * can be used by programs to determine if the operation succeded + * or not. If the operation failed, then a program can try + * an alternative approach. + * + * Returning ERROR_COMMAND_SYNTAX_ERROR will have the effect of + * printing out the syntax of the command. + */ int (*output_handler)(struct command_context_s *context, char* line); void *output_handler_priv; } command_context_t; diff --git a/src/target/Makefile.am b/src/target/Makefile.am index 83379381c3..3f00352582 100644 --- a/src/target/Makefile.am +++ b/src/target/Makefile.am @@ -23,7 +23,8 @@ nobase_dist_pkglib_DATA = xscale/debug_handler.bin event/at91eb40a_reset.script target/at91r40008.cfg target/lpc2148.cfg target/lpc2294.cfg target/sam7s256.cfg \ target/sam7x256.cfg target/str710.cfg target/str912.cfg target/nslu2.cfg target/pxa255_sst.cfg \ target/pxa255.cfg target/zy1000.cfg event/zy1000_reset.script event/at91sam9260_reset.script target/at91sam9260.cfg \ - target/wi-9c.cfg event/wi-9c_reset.script event/pxa255_reset.script target/stm32.cfg target/xba_revA3.cfg event/xba_revA3.script + target/wi-9c.cfg event/wi-9c_reset.script event/pxa255_reset.script target/stm32.cfg target/xba_revA3.cfg event/xba_revA3.script \ + ecos/at91eb40a.elf diff --git a/src/target/arm11.c b/src/target/arm11.c index adcbe74912..ea88d5c0b7 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -732,8 +732,8 @@ int arm11_halt(struct target_s *target) if (target->state == TARGET_HALTED) { - LOG_WARNING("target was already halted"); - return ERROR_OK; + LOG_DEBUG("target was already halted"); + return ERROR_OK; } if (arm11->trst_active) diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 63767ae307..4e14497de0 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -733,8 +733,18 @@ int arm7_9_poll(target_t *target) return ERROR_OK; } +/* + Some -S targets (ARM966E-S in the STR912 isn't affected, ARM926EJ-S + in the LPC3180 and AT91SAM9260 is affected) completely stop the JTAG clock + while the core is held in reset. It isn't possible to program the halt + condition once reset was asserted, hence a hook that allows the target to set + up its reset-halt condition prior to asserting reset. +*/ + int arm7_9_assert_reset(target_t *target) { + armv4_5_common_t *armv4_5 = target->arch_info; + arm7_9_common_t *arm7_9 = armv4_5->arch_info; LOG_DEBUG("target->state: %s", target_state_strings[target->state]); if (!(jtag_reset_config & RESET_HAS_SRST)) @@ -743,10 +753,32 @@ int arm7_9_assert_reset(target_t *target) return ERROR_FAIL; } + /* + * Some targets do not support communication while TRST is asserted. We need to + * set up the reset vector catch here. + * + * If TRST is in use, then these settings will be reset anyway, so setting them + * here is harmless. + */ + if (arm7_9->has_vector_catch) + { + /* program vector catch register to catch reset vector */ + embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_VEC_CATCH], 0x1); + } + else + { + /* program watchpoint unit to match on reset vector address */ + embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK], 0x3); + embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK], 0x0); + embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 0x100); + embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_MASK], 0xf7); + } + /* we can't know what state the target is in as we might e.g. * be resetting after a power dropout, so we need to issue a tms/srst */ + /* assert SRST and TRST */ /* system would get ouf sync if we didn't reset test-logic, too */ jtag_add_reset(1, 1); @@ -766,10 +798,6 @@ int arm7_9_assert_reset(target_t *target) target->state = TARGET_RESET; jtag_add_sleep(50000); - /* at this point we TRST *may* be deasserted */ - arm7_9_prepare_reset_halt(target); - - armv4_5_invalidate_core_regs(target); return ERROR_OK; @@ -909,15 +937,6 @@ int arm7_9_soft_reset_halt(struct target_s *target) return ERROR_OK; } -int arm7_9_prepare_reset_halt(target_t *target) -{ - if ((target->reset_mode!=RESET_HALT)&&(target->reset_mode!=RESET_INIT)) - { - return ERROR_OK; - } - return arm7_9_halt(target); -} - int arm7_9_halt(target_t *target) { armv4_5_common_t *armv4_5 = target->arch_info; @@ -928,7 +947,7 @@ int arm7_9_halt(target_t *target) if (target->state == TARGET_HALTED) { - LOG_WARNING("target was already halted"); + LOG_DEBUG("target was already halted"); return ERROR_OK; } diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index 406a00af47..19b0a758bd 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -429,7 +429,7 @@ int cortex_m3_halt(target_t *target) if (target->state == TARGET_HALTED) { - LOG_WARNING("target was already halted"); + LOG_DEBUG("target was already halted"); return ERROR_OK; } diff --git a/src/target/ecos/at91eb40a.elf b/src/target/ecos/at91eb40a.elf new file mode 100644 index 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TvZeL8W`|9uUnQA=eY%|W^fJ}s9z@Lu31&%JurQ%XVP0=8gZ*?3NaHgLog>f z7puqvFoVCiqjaB#7{<~7zA==nZ*%-Q*t1*=XM^rdvD$zaL)@YEL+%+rQJZb&Z@>+_ za}8hq2J)jed)t_C{GTH)knOlegLrnw)5D-vGRl3gytAw1`g(4$N70~!Mep9G{+K;d#+D7fb}rU@ zPeIQ;oR{lRcXzkiTh3PUYPeh+RS%cC9xgqqFpn~YfDG3&<>JwDc65z|%GwZRxr30| zlRsV<%Bym|R4m&SHBvmGju%Jl?9n{Y7mF%iE*HzHOBGA`a@H;s$J9`9v^0{pu}q&I zJDwdWN$YiHGQxIBDP4QC4@ z`JBoQ+xhY;K`<{DAffESC{~N(wmOl8Z(ubH*17OPnlia!z7o1$887h-HJ7Qz2Suc- zuy^Z(5pr+!Q5gP*R>!j{ETjJ`0^OBk6}xO_2dUf6KW|g_r%(dAhexuNV~3v`&zDdB z%S;&UhX=znTr1g#@WX@S!_-|a<`CJ`9sM0do_8ZJkhuTF(+XLRQT!evszz-feBlZF z-xqcCLG(>I{(psAe`AfirX1?_iX8uT=Vsv}(tMh7pIIZvzd5;~u&z8!xxR)RtKk0w zxOK!=#8&JcYRIvV?n_Zym5O}g_bgfq8mnl^ZL#puc$#*H@y@!q@eY<<`$Y56`Wkma LxzRO(O}T#p=vFk| literal 0 HcmV?d00001 diff --git a/src/target/target.c b/src/target/target.c index f90834d1bd..7673f5d22a 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2053,14 +2053,13 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch if (argc < 1) { - command_print(cmd_ctx, "usage: verify_image [offset] [type]"); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } if (!target) { LOG_ERROR("no target selected"); - return ERROR_OK; + return ERROR_FAIL; } duration_start_measure(&duration); @@ -2078,9 +2077,9 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch image.start_address_set = 0; - if (image_open(&image, args[0], (argc == 3) ? args[2] : NULL) != ERROR_OK) + if ((retval=image_open(&image, args[0], (argc == 3) ? args[2] : NULL)) != ERROR_OK) { - return ERROR_OK; + return retval; } image_size = 0x0; diff --git a/src/target/target/at91eb40a.cfg b/src/target/target/at91eb40a.cfg index 3d5eb14ee2..658c6d0cc5 100644 --- a/src/target/target/at91eb40a.cfg +++ b/src/target/target/at91eb40a.cfg @@ -14,7 +14,6 @@ reset_config srst_only srst_pulls_trst jtag_device 4 0x1 0xf 0xe #target configuration -#target arm7tdmi target arm7tdmi little reset_init 0 arm7tdmi-s_r4 # speed up memory downloads @@ -24,6 +23,9 @@ arm7_9 dcc_downloads enable # OpenOCD does not have a flash driver for for AT91FR40162S target_script 0 reset event/at91eb40a_reset.script +#flash driver +flash bank ecosflash 0x01000000 0x200000 2 2 0 ecos/at91eb40a.elf + # required for usable performance. Used for lots of # other things than flash programming. working_area 0 0x00000000 0x20000 nobackup diff --git a/src/target/target/zy1000.cfg b/src/target/target/zy1000.cfg index 5a2fab6821..b082ca240c 100644 --- a/src/target/target/zy1000.cfg +++ b/src/target/target/zy1000.cfg @@ -14,7 +14,6 @@ reset_config srst_only srst_pulls_trst jtag_device 4 0x1 0xf 0xe #target configuration -#target arm7tdmi target arm7tdmi little reset_init 0 arm7tdmi-s_r4 # at CPU CLK <32kHz this must be disabled @@ -22,7 +21,7 @@ arm7 fast_memory_access enable arm7_9 dcc_downloads enable -flash bank ecosflash 0x01000000 0x200000 2 2 0 /rom/at91eb40a.elf +flash bank ecosflash 0x01000000 0x200000 2 2 0 ecos/at91eb40a.elf target_script 0 reset event/zy1000_reset.script # required for usable performance. Used for lots of diff --git a/src/target/xscale.c b/src/target/xscale.c index 1d379f5918..b9a367ad6d 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -1263,7 +1263,7 @@ int xscale_halt(target_t *target) if (target->state == TARGET_HALTED) { - LOG_WARNING("target was already halted"); + LOG_DEBUG("target was already halted"); return ERROR_OK; } else if (target->state == TARGET_UNKNOWN) -- 2.30.2