You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(16) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <zw...@ma...> - 2009-06-13 02:35:06
|
Author: zwelch Date: 2009-06-13 02:34:17 +0200 (Sat, 13 Jun 2009) New Revision: 2237 Modified: trunk/src/target/target.c Log: Improve handle_virt2phys_command argument parsing: - Use parse_u32 to ensure virtual address parses properly. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:34:10 UTC (rev 2236) +++ trunk/src/target/target.c 2009-06-13 00:34:17 UTC (rev 2237) @@ -2682,11 +2682,14 @@ if (argc != 1) return ERROR_COMMAND_SYNTAX_ERROR; - target_t *target = get_current_target(cmd_ctx); - u32 va = strtoul(args[0], NULL, 0); + u32 va; + int retval = parse_u32(args[0], &va); + if (ERROR_OK != retval) + return retval; u32 pa; - int retval = target->type->virt2phys(target, va, &pa); + target_t *target = get_current_target(cmd_ctx); + retval = target->type->virt2phys(target, va, &pa); if (retval == ERROR_OK) command_print(cmd_ctx, "Physical address 0x%08x", pa); |
From: <zw...@ma...> - 2009-06-13 02:35:03
|
Author: zwelch Date: 2009-06-13 02:34:03 +0200 (Sat, 13 Jun 2009) New Revision: 2235 Modified: trunk/src/target/target.c Log: Improve and simplify handle_bp_command and handle_rbp_command: - Bug fix: return syntax error if remove called without one argument. - Use parse_u32 to ensure address and length arguments parse properly. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:33:55 UTC (rev 2234) +++ trunk/src/target/target.c 2009-06-13 00:34:03 UTC (rev 2235) @@ -2541,9 +2541,16 @@ return ERROR_COMMAND_SYNTAX_ERROR; } - u32 addr = strtoul(args[0], NULL, 0); - u32 length = strtoul(args[1], NULL, 0); + u32 addr; + int retval = parse_u32(args[0], &addr); + if (ERROR_OK != retval) + return retval; + u32 length; + retval = parse_u32(args[1], &length); + if (ERROR_OK != retval) + return retval; + int hw = BKPT_SOFT; if (argc == 3) { @@ -2558,11 +2565,17 @@ static int handle_rbp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { + if (argc != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + u32 addr; + int retval = parse_u32(args[0], &addr); + if (ERROR_OK != retval) + return retval; + target_t *target = get_current_target(cmd_ctx); + breakpoint_remove(target, addr); - if (argc > 0) - breakpoint_remove(target, strtoul(args[0], NULL, 0)); - return ERROR_OK; } |
From: <zw...@ma...> - 2009-06-13 02:35:00
|
Author: zwelch Date: 2009-06-13 02:34:31 +0200 (Sat, 13 Jun 2009) New Revision: 2239 Modified: trunk/src/target/target.c Log: Factor load_image argument parsing to parse_load_image_command_args: - Make fast_load_image use the helper coverage the standard load_image. - Improve whitespace in the moved lines. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:34:24 UTC (rev 2238) +++ trunk/src/target/target.c 2009-06-13 00:34:31 UTC (rev 2239) @@ -2128,66 +2128,70 @@ } -static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int parse_load_image_command_args(char **args, int argc, + image_t *image, u32 *min_address, u32 *max_address) { - u8 *buffer; - u32 buf_cnt; - u32 image_size; - u32 min_address=0; - u32 max_address=0xffffffff; - int i; - int retval, retvaltemp; - - image_t image; - - duration_t duration; - char *duration_text; - - target_t *target = get_current_target(cmd_ctx); - - if ((argc < 1)||(argc > 5)) - { + if (argc < 1 || argc > 5) return ERROR_COMMAND_SYNTAX_ERROR; - } - /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */ + /* a base address isn't always necessary, + * default to 0x0 (i.e. don't relocate) */ if (argc >= 2) { u32 addr; - retval = parse_u32(args[1], &addr); + int retval = parse_u32(args[1], &addr); if (ERROR_OK != retval) return ERROR_COMMAND_SYNTAX_ERROR; - image.base_address = addr; - image.base_address_set = 1; + image->base_address = addr; + image->base_address_set = 1; } else - { - image.base_address_set = 0; - } + image->base_address_set = 0; + image->start_address_set = 0; - image.start_address_set = 0; - - if (argc>=4) + if (argc >= 4) { - retval = parse_u32(args[3], &min_address); + int retval = parse_u32(args[3], min_address); if (ERROR_OK != retval) return ERROR_COMMAND_SYNTAX_ERROR; } - if (argc>=5) + if (argc == 5) { - retval = parse_u32(args[4], &max_address); + int retval = parse_u32(args[4], max_address); if (ERROR_OK != retval) return ERROR_COMMAND_SYNTAX_ERROR; // use size (given) to find max (required) - max_address += min_address; + *max_address += *min_address; } - if (min_address>max_address) - { + if (*min_address > *max_address) return ERROR_COMMAND_SYNTAX_ERROR; - } + return ERROR_OK; +} + +static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + u8 *buffer; + u32 buf_cnt; + u32 image_size; + u32 min_address = 0; + u32 max_address = 0xffffffff; + int i; + int retvaltemp; + + image_t image; + + duration_t duration; + char *duration_text; + + int retval = parse_load_image_command_args(args, argc, + &image, &min_address, &max_address); + if (ERROR_OK != retval) + return retval; + + target_t *target = get_current_target(cmd_ctx); duration_start_measure(&duration); if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK) @@ -4316,46 +4320,17 @@ u32 min_address=0; u32 max_address=0xffffffff; int i; - int retval; image_t image; duration_t duration; char *duration_text; - if ((argc < 1)||(argc > 5)) - { - return ERROR_COMMAND_SYNTAX_ERROR; - } + int retval = parse_load_image_command_args(args, argc, + &image, &min_address, &max_address); + if (ERROR_OK != retval) + return retval; - /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */ - if (argc >= 2) - { - image.base_address_set = 1; - image.base_address = strtoul(args[1], NULL, 0); - } - else - { - image.base_address_set = 0; - } - - - image.start_address_set = 0; - - if (argc>=4) - { - min_address=strtoul(args[3], NULL, 0); - } - if (argc>=5) - { - max_address=strtoul(args[4], NULL, 0)+min_address; - } - - if (min_address>max_address) - { - return ERROR_COMMAND_SYNTAX_ERROR; - } - duration_start_measure(&duration); if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK) |
From: <zw...@ma...> - 2009-06-13 02:34:58
|
Author: zwelch Date: 2009-06-13 02:34:24 +0200 (Sat, 13 Jun 2009) New Revision: 2238 Modified: trunk/src/target/target.c Log: Improve handle_profile_command argument parsing: - Use parse_uint to ensure timeout value parses properly. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:34:17 UTC (rev 2237) +++ trunk/src/target/target.c 2009-06-13 00:34:24 UTC (rev 2238) @@ -2823,13 +2823,13 @@ { return ERROR_COMMAND_SYNTAX_ERROR; } - char *end; - timeval_add_time(&timeout, strtoul(args[0], &end, 0), 0); - if (*end) - { - return ERROR_OK; - } + unsigned offset; + int retval = parse_uint(args[0], &offset); + if (ERROR_OK != retval) + return retval; + timeval_add_time(&timeout, offset, 0); + command_print(cmd_ctx, "Starting profiling. Halting and resuming the target as often as we can..."); static const int maxSample=10000; @@ -2838,7 +2838,6 @@ return ERROR_OK; int numSamples=0; - int retval=ERROR_OK; /* hopefully it is safe to cache! We want to stop/restart as quickly as possible. */ reg_t *reg = register_get_by_name(target->reg_cache, "pc", 1); |
From: <zw...@ma...> - 2009-06-13 02:34:55
|
Author: zwelch Date: 2009-06-13 02:33:25 +0200 (Sat, 13 Jun 2009) New Revision: 2230 Modified: trunk/src/target/target.c Log: Improve handle_md_command argument handling: - Use parse_u32 and parse_uint for address and count, respectively. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:33:18 UTC (rev 2229) +++ trunk/src/target/target.c 2009-06-13 00:33:25 UTC (rev 2230) @@ -2046,16 +2046,23 @@ default: return ERROR_COMMAND_SYNTAX_ERROR; } - u32 address = strtoul(args[0], NULL, 0); + u32 address; + int retval = parse_u32(args[0], &address); + if (ERROR_OK != retval) + return retval; unsigned count = 1; if (argc == 2) - count = strtoul(args[1], NULL, 0); + { + retval = parse_uint(args[1], &count); + if (ERROR_OK != retval) + return retval; + } u8 *buffer = calloc(count, size); target_t *target = get_current_target(cmd_ctx); - int retval = target_read_memory(target, + retval = target_read_memory(target, address, size, count, buffer); if (ERROR_OK == retval) handle_md_output(cmd_ctx, target, address, size, count, buffer); |
From: <zw...@ma...> - 2009-06-13 02:34:48
|
Author: zwelch Date: 2009-06-13 02:33:18 +0200 (Sat, 13 Jun 2009) New Revision: 2229 Modified: trunk/src/target/target.c Log: Use parse_u32 in handle_resume_command and handle_step_command. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:33:11 UTC (rev 2228) +++ trunk/src/target/target.c 2009-06-13 00:33:18 UTC (rev 2229) @@ -1954,7 +1954,11 @@ * handle breakpoints, not debugging */ u32 addr = 0; if (argc == 1) - addr = strtoul(args[0], NULL, 0); + { + int retval = parse_u32(args[0], &addr); + if (ERROR_OK != retval) + return retval; + } return target_resume(target, 0, addr, 1, 0); } @@ -1971,7 +1975,11 @@ * handle breakpoints, debugging */ u32 addr = 0; if (argc == 1) - addr = strtoul(args[0], NULL, 0); + { + int retval = parse_u32(args[0], &addr); + if (ERROR_OK != retval) + return retval; + } target_t *target = get_current_target(cmd_ctx); return target->type->step(target, 0, addr, 1); |
From: <zw...@ma...> - 2009-06-13 02:34:42
|
Author: zwelch Date: 2009-06-13 02:33:01 +0200 (Sat, 13 Jun 2009) New Revision: 2227 Modified: trunk/src/target/target.c Log: Cleanup and fi handle_wait_halt_command: - Use unsigned type for delay variable. - Use parse_uint to ensure delay argument parses properly. - Bug fix: Return syntax error if more than one argument is given. - Bug fix: Return syntax error when argument fails to parse. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:32:54 UTC (rev 2226) +++ trunk/src/target/target.c 2009-06-13 00:33:01 UTC (rev 2227) @@ -1822,21 +1822,23 @@ static int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - int ms = 5000; + if (argc > 1) + return ERROR_COMMAND_SYNTAX_ERROR; - if (argc > 0) + unsigned ms = 5000; + if (1 == argc) { - char *end; - - ms = strtoul(args[0], &end, 0) * 1000; - if (*end) + int retval = parse_uint(args[0], &ms); + if (ERROR_OK != retval) { command_print(cmd_ctx, "usage: %s [seconds]", cmd); - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; } + // convert seconds (given) to milliseconds (needed) + ms *= 1000; } + target_t *target = get_current_target(cmd_ctx); - return target_wait_state(target, TARGET_HALTED, ms); } |
From: <zw...@ma...> - 2009-06-13 02:34:42
|
Author: zwelch Date: 2009-06-13 02:33:11 +0200 (Sat, 13 Jun 2009) New Revision: 2228 Modified: trunk/src/target/target.c Log: Cleanup and improve handle_halt_command: - Make argument check use parse_uint to ensure value parses properly. - Move variable declarations to location of first use. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:33:01 UTC (rev 2227) +++ trunk/src/target/target.c 2009-06-13 00:33:11 UTC (rev 2228) @@ -1889,23 +1889,20 @@ static int handle_halt_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - int retval; - target_t *target = get_current_target(cmd_ctx); - LOG_DEBUG("-"); - if ((retval = target_halt(target)) != ERROR_OK) - { + target_t *target = get_current_target(cmd_ctx); + int retval = target_halt(target); + if (ERROR_OK != retval) return retval; - } if (argc == 1) { - int wait; - char *end; - - wait = strtoul(args[0], &end, 0); - if (!*end && !wait) + unsigned wait; + retval = parse_uint(args[0], &wait); + if (ERROR_OK != retval) + return ERROR_COMMAND_SYNTAX_ERROR; + if (!wait) return ERROR_OK; } |
From: <zw...@ma...> - 2009-06-13 02:34:39
|
Author: zwelch Date: 2009-06-13 02:32:54 +0200 (Sat, 13 Jun 2009) New Revision: 2226 Modified: trunk/src/target/target.c Log: Use parse_uint in handle_reg_command to ensure reg number parses properly. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-13 00:32:40 UTC (rev 2225) +++ trunk/src/target/target.c 2009-06-13 00:32:54 UTC (rev 2226) @@ -1704,16 +1704,19 @@ /* access a single register by its ordinal number */ if ((args[0][0] >= '0') && (args[0][0] <= '9')) { - int num = strtoul(args[0], NULL, 0); + unsigned num; + int retval = parse_uint(args[0], &num); + if (ERROR_OK != retval) + return ERROR_COMMAND_SYNTAX_ERROR; + reg_cache_t *cache = target->reg_cache; - count = 0; while(cache) { int i; for (i = 0; i < cache->num_regs; i++) { - if (count++ == num) + if (count++ == (int)num) { reg = &cache->reg_list[i]; break; |
From: <zw...@ma...> - 2009-06-13 02:34:38
|
Author: zwelch Date: 2009-06-13 02:32:40 +0200 (Sat, 13 Jun 2009) New Revision: 2225 Modified: trunk/src/target/target.c Log: Use parse_uint in get_target to ensure target id is parsed properly. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-06-12 22:06:02 UTC (rev 2224) +++ trunk/src/target/target.c 2009-06-13 00:32:40 UTC (rev 2225) @@ -323,8 +323,6 @@ target_t *get_target(const char *id) { target_t *target; - char *endptr; - int num; /* try as tcltarget name */ for (target = all_targets; target; target = target->next) { @@ -335,12 +333,12 @@ } /* no match, try as number */ - num = strtoul(id, &endptr, 0); - if (*endptr != 0) + unsigned num; + if (parse_uint(id, &num) != ERROR_OK) return NULL; for (target = all_targets; target; target = target->next) { - if (target->target_number == num) + if (target->target_number == (int)num) return target; } |
From: <zw...@ma...> - 2009-06-13 00:06:07
|
Author: zwelch Date: 2009-06-13 00:06:02 +0200 (Sat, 13 Jun 2009) New Revision: 2224 Modified: trunk/src/helper/command.c trunk/src/helper/command.h trunk/src/jtag/tcl.c Log: David Brownell <da...@pa...>: Currently the "debug_level 3" command tracing ignores commands that could return values to TCL scripts (by plugging in to a slightly lower level of the interpreter stack). Fix that by abstracting the tracing command and starting to make some of those previously-untraced commands use this new mechanism. Modified: trunk/src/helper/command.c =================================================================== --- trunk/src/helper/command.c 2009-06-12 21:53:17 UTC (rev 2223) +++ trunk/src/helper/command.c 2009-06-12 22:06:02 UTC (rev 2224) @@ -61,6 +61,23 @@ extern command_context_t *global_cmd_ctx; +void script_debug(Jim_Interp *interp, const char *name, int argc, Jim_Obj *const *argv) +{ + int i; + + LOG_DEBUG("command - %s", name); + for (i = 0; i < argc; i++) { + int len; + const char *w = Jim_GetString(argv[i], &len); + + /* end of line comment? */ + if (*w == '#') + break; + + LOG_DEBUG("%s - argv[%d]=%s", name, i, w); + } +} + static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { /* the private data is stashed in the interp structure */ @@ -85,7 +102,7 @@ target_call_timer_callbacks_now(); LOG_USER_N("%s", ""); /* Keep GDB connection alive*/ - LOG_DEBUG("script_command - %s", c->name); + script_debug(interp, c->name, argc, argv); words = malloc(sizeof(char *) * argc); for (i = 0; i < argc; i++) @@ -102,7 +119,6 @@ { return JIM_ERR; } - LOG_DEBUG("script_command - %s, argv[%u]=%s", c->name, i, words[i]); } nwords = i; Modified: trunk/src/helper/command.h =================================================================== --- trunk/src/helper/command.h 2009-06-12 21:53:17 UTC (rev 2223) +++ trunk/src/helper/command.h 2009-06-12 22:06:02 UTC (rev 2224) @@ -123,4 +123,6 @@ DEFINE_PARSE_ULONG(u16, uint16_t, UINT16_MAX) DEFINE_PARSE_ULONG(u8, uint8_t, UINT8_MAX) +void script_debug(Jim_Interp *interp, const char *cmd, int argc, Jim_Obj *const *argv); + #endif /* COMMAND_H */ Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 21:53:17 UTC (rev 2223) +++ trunk/src/jtag/tcl.c 2009-06-12 22:06:02 UTC (rev 2224) @@ -1248,6 +1248,8 @@ endstate = TAP_IDLE; + script_debug(interp, "drscan", argc, args); + /* validate arguments as numbers */ e = JIM_OK; for (i = 2; i < argc; i+=2) @@ -1369,6 +1371,8 @@ return JIM_ERR; } + script_debug(interp, "pathmove", argc, args); + int i; for (i=0; i<argc-1; i++) { @@ -1403,6 +1407,8 @@ static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args) { + script_debug(interp, "flush_count", argc, args); + Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count())); return JIM_OK; |
From: <zw...@ma...> - 2009-06-12 23:53:20
|
Author: zwelch Date: 2009-06-12 23:53:17 +0200 (Fri, 12 Jun 2009) New Revision: 2223 Modified: trunk/doc/openocd.texi Log: David Brownell <da...@pa...>: Move the discussion of the "scan_chain" command up to go with the presentation of that topic in the TAP declaration chapter. This makes the presentation of the TAP and target lists be parallel, which will be something of an aid to understanding that they are different (and how). Modified: trunk/doc/openocd.texi =================================================================== --- trunk/doc/openocd.texi 2009-06-12 21:43:53 UTC (rev 2222) +++ trunk/doc/openocd.texi 2009-06-12 21:53:17 UTC (rev 2223) @@ -2132,22 +2132,43 @@ @section Scan Chains -OpenOCD uses a JTAG adapter (interface) to talk to your board, -which has a daisy chain of TAPs. -That daisy chain is called a @dfn{scan chain}. -Simple configurations may have a single TAP in the scan chain, -perhaps for a microcontroller. -Complex configurations might have a dozen or more TAPs: +TAPs are part of a hardware @dfn{scan chain}, +which is daisy chain of TAPs. +They also need to be added to +OpenOCD's software mirror of that hardware list, +giving each member a name and associating other data with it. +Simple scan chains, with a single TAP, are common in +systems with a single microcontroller or microprocessor. +More complex chips may have several TAPs internally. +Very complex scan chains might have a dozen or more TAPs: several in one chip, more in the next, and connecting to other boards with their own chips and TAPs. +You can display the list with the @command{scan_chain} command. +(Don't confuse this with the list displayed by the @command{targets} +command, presented in the next chapter. +That only displays TAPs for CPUs which are configured as +debugging targets.) +Here's what the scan chain might look like for a chip more than one TAP: + +@verbatim + TapName Enabled IdCode Expected IrLen IrCap IrMask Instr +-- ------------------ ------- ---------- ---------- ----- ----- ------ ----- + 0 omap5912.dsp Y 0x03df1d81 0x03df1d81 38 0 0 0x... + 1 omap5912.arm Y 0x0692602f 0x0692602f 4 0x1 0 0xc + 2 omap5912.unknown Y 0x00000000 0x00000000 8 0 0 0xff +@end verbatim + Unfortunately those TAPs can't always be autoconfigured, because not all devices provide good support for that. -(JTAG doesn't require supporting IDCODE instructions.) +JTAG doesn't require supporting IDCODE instructions, and +chips with JTAG routers may not link TAPs into the chain +until they are told to do so. + The configuration mechanism currently supported by OpenOCD requires explicit configuration of all TAP devices using -@command{jtag newtap} commands. -One like this would declare a tap and name it @code{chip1.cpu}: +@command{jtag newtap} commands, as detailed later in this chapter. +A command like this would declare one tap and name it @code{chip1.cpu}: @example jtag newtap chip1 cpu -irlen 7 -ircapture 0x01 -irmask 0x55 @@ -2180,6 +2201,29 @@ @option{str912}, to support more than one chip of each type. @xref{Config File Guidelines}. +At this writing there is only a single command to work with +scan chains, and there is no support for enumerating +TAPs or examining their attributes. + +@deffn Command {scan_chain} +Displays the TAPs in the scan chain configuration, +and their status. +The set of TAPs listed by this command is fixed by +exiting the OpenOCD configuration stage, +but systems with a JTAG router can +enable or disable TAPs dynamically. +In addition to the enable/disable status, the contents of +each TAP's instruction register can also change. +@end deffn + +@c FIXME! there should be commands to enumerate TAPs +@c and get their attributes, like there are for targets. +@c "jtag cget ..." will handle attributes. +@c "jtag names" for enumerating TAPs, maybe. + +@c Probably want "jtag eventlist", and a "tap-reset" event +@c (on entry to RESET state). + @section TAP Names When TAP objects are declared with @command{jtag newtap}, @@ -2202,7 +2246,7 @@ should not be counted upon. Update all of your scripts to use TAP names rather than numbers. Using TAP numbers in target configuration scripts prevents -reusing on boards with multiple targets. +reusing those scripts on boards with multiple targets. @end quotation @section TAP Declaration Commands @@ -4981,17 +5025,6 @@ to execute before they take effect. @end deffn -@deffn Command {scan_chain} -Displays the TAPs in the scan chain configuration, -and their status. -The set of TAPs listed by this command is fixed by -exiting the OpenOCD configuration stage, -but systems with a JTAG router can -enable or disable TAPs dynamically. -In addition to the enable/disable status, the contents of -each TAP's instruction register can also change. -@end deffn - @c tms_sequence (short|long) @c ... temporary, debug-only, probably gone before 0.2 ships |
From: <zw...@ma...> - 2009-06-12 23:43:57
|
Author: zwelch Date: 2009-06-12 23:43:53 +0200 (Fri, 12 Jun 2009) New Revision: 2222 Modified: trunk/src/jtag/core.c trunk/src/jtag/tcl.c Log: David Brownell <da...@pa...>: Partial fix to the "long IR length" problems. - Current code could handle up to 32 bit IR lengths with full functionality, if it didn't just reject may of them out of hand. So only reject clear errors, where the IR mask (or capture instruction) needs more than IrLen bits. - Longer IR lengths can only be handled in BYPASS mode for now. Example: TI's DSPs use 38-bit IR lengths. So we can't issue their IDCODE instructions... A more complete fix would be able to issue longer instructions; or minimally, would fail cleanly for the non-BYPASS case. Note that this *could* make some currently broken scripts fail, since the previous code accepted garbage values so long as they didn't use more than 16 bits. Modified: trunk/src/jtag/core.c =================================================================== --- trunk/src/jtag/core.c 2009-06-12 21:31:11 UTC (rev 2221) +++ trunk/src/jtag/core.c 2009-06-12 21:43:53 UTC (rev 2222) @@ -1073,6 +1073,7 @@ tap->expected_mask = malloc(tap->ir_length); tap->cur_instr = malloc(tap->ir_length); + /// @todo cope sanely with ir_length bigger than 32 bits buf_set_u32(tap->expected, 0, tap->ir_length, tap->ir_capture_value); buf_set_u32(tap->expected_mask, 0, tap->ir_length, tap->ir_capture_mask); buf_set_ones(tap->cur_instr, tap->ir_length); Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 21:31:11 UTC (rev 2221) +++ trunk/src/jtag/tcl.c 2009-06-12 21:43:53 UTC (rev 2222) @@ -296,7 +296,16 @@ return JIM_OK; } +static int is_bad_irval(int ir_length, jim_wide w) +{ + jim_wide v = 1; + v <<= ir_length; + v -= 1; + v = ~v; + return (w & v) != 0; +} + extern void jtag_tap_init(jtag_tap_t *tap); extern void jtag_tap_free(jtag_tap_t *tap); @@ -411,22 +420,28 @@ Jim_SetResult_sprintf( goi->interp, "option: %s bad parameter", n->name ); return e; } - if( (w < 0) || (w > 0xffff) ){ - /* wacky value */ - Jim_SetResult_sprintf( goi->interp, "option: %s - wacky value: %d (0x%x)", - n->name, (int)(w), (int)(w)); - return JIM_ERR; - } switch(n->value){ case NTAP_OPT_IRLEN: + if (w < (jim_wide) sizeof(pTap->ir_capture_value)) + LOG_WARNING("huge IR length %d", (int) w); pTap->ir_length = w; reqbits &= (~(NTREQ_IRLEN)); break; case NTAP_OPT_IRMASK: + if (is_bad_irval(pTap->ir_length, w)) { + LOG_ERROR("IR mask %x too big", + (int) w); + return ERROR_FAIL; + } pTap->ir_capture_mask = w; reqbits &= (~(NTREQ_IRMASK)); break; case NTAP_OPT_IRCAPTURE: + if (is_bad_irval(pTap->ir_length, w)) { + LOG_ERROR("IR capture %x too big", + (int) w); + return ERROR_FAIL; + } pTap->ir_capture_value = w; reqbits &= (~(NTREQ_IRCAPTURE)); break; |
From: <zw...@ma...> - 2009-06-12 23:31:15
|
Author: zwelch Date: 2009-06-12 23:31:11 +0200 (Fri, 12 Jun 2009) New Revision: 2221 Modified: trunk/src/flash/mflash.c trunk/src/flash/mflash.h Log: unsik Kim <don...@gm...>: Improve error handling in mflash driver. Modified: trunk/src/flash/mflash.c =================================================================== --- trunk/src/flash/mflash.c 2009-06-12 04:14:28 UTC (rev 2220) +++ trunk/src/flash/mflash.c 2009-06-12 21:31:11 UTC (rev 2221) @@ -141,7 +141,7 @@ } else if (gpio.port[0] == 'j') { gpio_con = S3C2440_GPJCON; } else { - LOG_ERROR("invalid port %d%s", gpio.num, gpio.port); + LOG_ERROR("mflash: invalid port %d%s", gpio.num, gpio.port); return ERROR_INVALID_ARGUMENTS; } @@ -173,7 +173,7 @@ } else if (gpio.port[0] == 'j') { gpio_dat = S3C2440_GPJDAT; } else { - LOG_ERROR("invalid port %d%s", gpio.num, gpio.port); + LOG_ERROR("mflash: invalid port %d%s", gpio.num, gpio.port); return ERROR_INVALID_ARGUMENTS; } @@ -198,12 +198,16 @@ static int mg_init_gpio (void) { + int ret; mflash_gpio_drv_t *gpio_drv = mflash_bank->gpio_drv; - gpio_drv->set_gpio_to_output(mflash_bank->rst_pin); - gpio_drv->set_gpio_output_val(mflash_bank->rst_pin, 1); + ret = gpio_drv->set_gpio_to_output(mflash_bank->rst_pin); + if (ret != ERROR_OK) + return ret; - return ERROR_OK; + ret = gpio_drv->set_gpio_output_val(mflash_bank->rst_pin, 1); + + return ret; } static int mg_dsk_wait(mg_io_type_wait wait, u32 time) @@ -212,13 +216,16 @@ target_t *target = mflash_bank->target; u32 mg_task_reg = mflash_bank->base + MG_REG_OFFSET; duration_t duration; + int ret; long long t=0; duration_start_measure(&duration); while (time) { - target_read_u8(target, mg_task_reg + MG_REG_STATUS, &status); + ret = target_read_u8(target, mg_task_reg + MG_REG_STATUS, &status); + if (ret != ERROR_OK) + return ret; if (status & mg_io_rbit_status_busy) { @@ -244,19 +251,13 @@ /* Now we check the error condition! */ if (status & mg_io_rbit_status_error) { - target_read_u8(target, mg_task_reg + MG_REG_ERROR, &error); + ret = target_read_u8(target, mg_task_reg + MG_REG_ERROR, &error); + if (ret != ERROR_OK) + return ret; - if (error & mg_io_rbit_err_bad_sect_num) { - LOG_ERROR("sector not found"); - return ERROR_FAIL; - } - else if (error & (mg_io_rbit_err_bad_block | mg_io_rbit_err_uncorrectable)) { - LOG_ERROR("bad block"); - return ERROR_FAIL; - } else { - LOG_ERROR("disk operation fail"); - return ERROR_FAIL; - } + LOG_ERROR("mflash: io error 0x%02x", error); + + return ERROR_MG_IO; } switch (wait) @@ -283,8 +284,8 @@ break; } - LOG_ERROR("timeout occured"); - return ERROR_FAIL; + LOG_ERROR("mflash: timeout occured"); + return ERROR_MG_TIMEOUT; } static int mg_dsk_srst(u8 on) @@ -312,74 +313,85 @@ target_t *target = mflash_bank->target; u32 mg_task_reg = mflash_bank->base + MG_REG_OFFSET; u8 value; + int ret; - if (mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL) != ERROR_OK) - return ERROR_FAIL; + ret = mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL); + if (ret != ERROR_OK) + return ret; value = mg_io_rval_dev_drv_master | mg_io_rval_dev_lba_mode |((sect_num >> 24) & 0xf); - target_write_u8(target, mg_task_reg + MG_REG_DRV_HEAD, value); - target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, (u8)cnt); - target_write_u8(target, mg_task_reg + MG_REG_SECT_NUM, (u8)sect_num); - target_write_u8(target, mg_task_reg + MG_REG_CYL_LOW, (u8)(sect_num >> 8)); - target_write_u8(target, mg_task_reg + MG_REG_CYL_HIGH, (u8)(sect_num >> 16)); + ret = target_write_u8(target, mg_task_reg + MG_REG_DRV_HEAD, value); + ret |= target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, (u8)cnt); + ret |= target_write_u8(target, mg_task_reg + MG_REG_SECT_NUM, (u8)sect_num); + ret |= target_write_u8(target, mg_task_reg + MG_REG_CYL_LOW, (u8)(sect_num >> 8)); + ret |= target_write_u8(target, mg_task_reg + MG_REG_CYL_HIGH, (u8)(sect_num >> 16)); - target_write_u8(target, mg_task_reg + MG_REG_COMMAND, cmd); + if (ret != ERROR_OK) + return ret; - return ERROR_OK; + return target_write_u8(target, mg_task_reg + MG_REG_COMMAND, cmd); } static int mg_dsk_drv_info(void) { target_t *target = mflash_bank->target; u32 mg_buff = mflash_bank->base + MG_BUFFER_OFFSET; + int ret; - if ( mg_dsk_io_cmd(0, 1, mg_io_cmd_identify) != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_dsk_io_cmd(0, 1, mg_io_cmd_identify)) != ERROR_OK) + return ret; - if ( mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL) != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL)) != ERROR_OK) + return ret; - LOG_INFO("read drive info."); + LOG_INFO("mflash: read drive info"); if (! mflash_bank->drv_info) mflash_bank->drv_info = malloc(sizeof(mg_drv_info_t)); target_read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1, (u8 *)&mflash_bank->drv_info->drv_id); + if (ret != ERROR_OK) + return ret; mflash_bank->drv_info->tot_sects = (u32)(mflash_bank->drv_info->drv_id.total_user_addressable_sectors_hi << 16) + mflash_bank->drv_info->drv_id.total_user_addressable_sectors_lo; - target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read); - - return ERROR_OK; + return target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read); } static int mg_mflash_rst(void) { - mg_init_gpio(); + int ret; - mg_hdrst(0); + if ((ret = mg_init_gpio()) != ERROR_OK) + return ret; - if (mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_hdrst(0)) != ERROR_OK) + return ret; - mg_hdrst(1); + if ((ret = mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK) + return ret; - if (mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_hdrst(1)) != ERROR_OK) + return ret; - mg_dsk_srst(1); + if ((ret = mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK) + return ret; - if (mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_dsk_srst(1)) != ERROR_OK) + return ret; - mg_dsk_srst(0); + if ((ret = mg_dsk_wait(mg_io_wait_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK) + return ret; - if (mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG) != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_dsk_srst(0)) != ERROR_OK) + return ret; + if ((ret = mg_dsk_wait(mg_io_wait_not_bsy, MG_OEM_DISK_WAIT_TIME_LONG)) != ERROR_OK) + return ret; + LOG_INFO("mflash: reset ok"); return ERROR_OK; @@ -387,13 +399,12 @@ static int mg_mflash_probe(void) { - if (mg_mflash_rst() != ERROR_OK) - return ERROR_FAIL; + int ret; - if (mg_dsk_drv_info() != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_mflash_rst()) != ERROR_OK) + return ret; - return ERROR_OK; + return mg_dsk_drv_info(); } static int mg_probe_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -418,59 +429,68 @@ u8 *buff_ptr = buff; duration_t duration; - if ( mg_dsk_io_cmd(sect_num, sect_cnt, mg_io_cmd_read) != ERROR_OK ) - return ERROR_FAIL; + if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, mg_io_cmd_read)) != ERROR_OK ) + return ret; address = mflash_bank->base + MG_BUFFER_OFFSET; duration_start_measure(&duration); for (i = 0; i < sect_cnt; i++) { - mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL); + ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL); + if (ret != ERROR_OK) + return ret; - target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); + ret = target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); + if (ret != ERROR_OK) + return ret; + buff_ptr += MG_MFLASH_SECTOR_SIZE; - target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read); + ret = target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read); + if (ret != ERROR_OK) + return ret; - LOG_DEBUG("%u (0x%8.8x) sector read", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE); + LOG_DEBUG("mflash: %u (0x%8.8x) sector read", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE); duration_stop_measure(&duration, NULL); if ((duration.duration.tv_sec * 1000 + duration.duration.tv_usec / 1000) > 3000) { - LOG_INFO("read %u'th sectors", sect_num + i); + LOG_INFO("mflash: read %u'th sectors", sect_num + i); duration_start_measure(&duration); } } - ret = mg_dsk_wait(mg_io_wait_rdy, MG_OEM_DISK_WAIT_TIME_NORMAL); - - return ret; + return mg_dsk_wait(mg_io_wait_rdy, MG_OEM_DISK_WAIT_TIME_NORMAL); } static int mg_mflash_read_sects(void *buff, u32 sect_num, u32 sect_cnt) { u32 quotient, residue, i; u8 *buff_ptr = buff; + int ret = ERROR_OK; quotient = sect_cnt >> 8; residue = sect_cnt % 256; for (i = 0; i < quotient; i++) { - LOG_DEBUG("sect num : %u buff : 0x%0lx", sect_num, + LOG_DEBUG("mflash: sect num : %u buff : 0x%0lx", sect_num, (unsigned long)buff_ptr); - mg_mflash_do_read_sects(buff_ptr, sect_num, 256); + ret = mg_mflash_do_read_sects(buff_ptr, sect_num, 256); + if (ret != ERROR_OK) + return ret; + sect_num += 256; buff_ptr += 256 * MG_MFLASH_SECTOR_SIZE; } if (residue) { - LOG_DEBUG("sect num : %u buff : %0lx", sect_num, + LOG_DEBUG("mflash: sect num : %u buff : %0lx", sect_num, (unsigned long)buff_ptr); - mg_mflash_do_read_sects(buff_ptr, sect_num, residue); + return mg_mflash_do_read_sects(buff_ptr, sect_num, residue); } - return ERROR_OK; + return ret; } static int mg_mflash_do_write_sects(void *buff, u32 sect_num, u32 sect_cnt, @@ -482,8 +502,8 @@ u8 *buff_ptr = buff; duration_t duration; - if ( mg_dsk_io_cmd(sect_num, sect_cnt, cmd) != ERROR_OK ) - return ERROR_FAIL; + if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, cmd)) != ERROR_OK ) + return ret; address = mflash_bank->base + MG_BUFFER_OFFSET; @@ -492,23 +512,24 @@ for (i = 0; i < sect_cnt; i++) { ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL); if (ret != ERROR_OK) - LOG_ERROR("mg_io_wait_drq time out"); + return ret; ret = target_write_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); if (ret != ERROR_OK) - LOG_ERROR("mem write error"); + return ret; + buff_ptr += MG_MFLASH_SECTOR_SIZE; ret = target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_write); if (ret != ERROR_OK) - LOG_ERROR("mg_io_cmd_confirm_write error"); + return ret; - LOG_DEBUG("%u (0x%8.8x) sector write", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE); + LOG_DEBUG("mflash: %u (0x%8.8x) sector write", sect_num + i, (sect_num + i) * MG_MFLASH_SECTOR_SIZE); duration_stop_measure(&duration, NULL); if ((duration.duration.tv_sec * 1000 + duration.duration.tv_usec / 1000) > 3000) { - LOG_INFO("wrote %u'th sectors", sect_num + i); + LOG_INFO("mflash: wrote %u'th sectors", sect_num + i); duration_start_measure(&duration); } } @@ -525,51 +546,57 @@ { u32 quotient, residue, i; u8 *buff_ptr = buff; + int ret = ERROR_OK; quotient = sect_cnt >> 8; residue = sect_cnt % 256; for (i = 0; i < quotient; i++) { - LOG_DEBUG("sect num : %u buff : %0lx", sect_num, + LOG_DEBUG("mflash: sect num : %u buff : %0lx", sect_num, (unsigned long)buff_ptr); - mg_mflash_do_write_sects(buff_ptr, sect_num, 256, mg_io_cmd_write); + ret = mg_mflash_do_write_sects(buff_ptr, sect_num, 256, mg_io_cmd_write); + if (ret != ERROR_OK) + return ret; + sect_num += 256; buff_ptr += 256 * MG_MFLASH_SECTOR_SIZE; } if (residue) { - LOG_DEBUG("sect num : %u buff : %0lx", sect_num, + LOG_DEBUG("mflash: sect num : %u buff : %0lx", sect_num, (unsigned long)buff_ptr); - mg_mflash_do_write_sects(buff_ptr, sect_num, residue, mg_io_cmd_write); + return mg_mflash_do_write_sects(buff_ptr, sect_num, residue, mg_io_cmd_write); } - return ERROR_OK; + return ret; } static int mg_mflash_read (u32 addr, u8 *buff, u32 len) { - u8 *sect_buff, *buff_ptr = buff; + u8 *buff_ptr = buff; + u8 sect_buff[MG_MFLASH_SECTOR_SIZE]; u32 cur_addr, next_sec_addr, end_addr, cnt, sect_num; + int ret = ERROR_OK; cnt = 0; cur_addr = addr; end_addr = addr + len; - sect_buff = malloc(MG_MFLASH_SECTOR_SIZE); - if (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK) { next_sec_addr = (cur_addr + MG_MFLASH_SECTOR_SIZE) & ~MG_MFLASH_SECTOR_SIZE_MASK; sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT; - mg_mflash_read_sects(sect_buff, sect_num, 1); + ret = mg_mflash_read_sects(sect_buff, sect_num, 1); + if (ret != ERROR_OK) + return ret; if (end_addr < next_sec_addr) { memcpy(buff_ptr, sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), end_addr - cur_addr); - LOG_DEBUG("copies %u byte from sector offset 0x%8.8x", end_addr - cur_addr, cur_addr); + LOG_DEBUG("mflash: copies %u byte from sector offset 0x%8.8x", end_addr - cur_addr, cur_addr); cur_addr = end_addr; } else { memcpy(buff_ptr, sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), next_sec_addr - cur_addr); - LOG_DEBUG("copies %u byte from sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr); + LOG_DEBUG("mflash: copies %u byte from sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr); buff_ptr += (next_sec_addr - cur_addr); cur_addr = next_sec_addr; } @@ -586,7 +613,8 @@ } if (cnt) - mg_mflash_read_sects(buff_ptr, sect_num, cnt); + if ((ret = mg_mflash_read_sects(buff_ptr, sect_num, cnt)) != ERROR_OK) + return ret; buff_ptr += cnt * MG_MFLASH_SECTOR_SIZE; cur_addr += cnt * MG_MFLASH_SECTOR_SIZE; @@ -594,47 +622,52 @@ if (cur_addr < end_addr) { sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT; - mg_mflash_read_sects(sect_buff, sect_num, 1); + ret = mg_mflash_read_sects(sect_buff, sect_num, 1); + if (ret != ERROR_OK) + return ret; + memcpy(buff_ptr, sect_buff, end_addr - cur_addr); - LOG_DEBUG("copies %u byte", end_addr - cur_addr); + LOG_DEBUG("mflash: copies %u byte", end_addr - cur_addr); } } - free(sect_buff); - - return ERROR_OK; + return ret; } static int mg_mflash_write(u32 addr, u8 *buff, u32 len) { - u8 *sect_buff, *buff_ptr = buff; + u8 *buff_ptr = buff; + u8 sect_buff[MG_MFLASH_SECTOR_SIZE]; u32 cur_addr, next_sec_addr, end_addr, cnt, sect_num; + int ret = ERROR_OK; cnt = 0; cur_addr = addr; end_addr = addr + len; - sect_buff = malloc(MG_MFLASH_SECTOR_SIZE); - if (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK) { next_sec_addr = (cur_addr + MG_MFLASH_SECTOR_SIZE) & ~MG_MFLASH_SECTOR_SIZE_MASK; sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT; - mg_mflash_read_sects(sect_buff, sect_num, 1); + ret = mg_mflash_read_sects(sect_buff, sect_num, 1); + if (ret != ERROR_OK) + return ret; if (end_addr < next_sec_addr) { memcpy(sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), buff_ptr, end_addr - cur_addr); - LOG_DEBUG("copies %u byte to sector offset 0x%8.8x", end_addr - cur_addr, cur_addr); + LOG_DEBUG("mflash: copies %u byte to sector offset 0x%8.8x", end_addr - cur_addr, cur_addr); cur_addr = end_addr; } else { memcpy(sect_buff + (cur_addr & MG_MFLASH_SECTOR_SIZE_MASK), buff_ptr, next_sec_addr - cur_addr); - LOG_DEBUG("copies %u byte to sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr); + LOG_DEBUG("mflash: copies %u byte to sector offset 0x%8.8x", next_sec_addr - cur_addr, cur_addr); buff_ptr += (next_sec_addr - cur_addr); cur_addr = next_sec_addr; } - mg_mflash_write_sects(sect_buff, sect_num, 1); + ret = mg_mflash_write_sects(sect_buff, sect_num, 1); + if (ret != ERROR_OK) + return ret; } if (cur_addr < end_addr) { @@ -648,7 +681,8 @@ } if (cnt) - mg_mflash_write_sects(buff_ptr, sect_num, cnt); + if ((ret = mg_mflash_write_sects(buff_ptr, sect_num, cnt)) != ERROR_OK) + return ret; buff_ptr += cnt * MG_MFLASH_SECTOR_SIZE; cur_addr += cnt * MG_MFLASH_SECTOR_SIZE; @@ -656,16 +690,17 @@ if (cur_addr < end_addr) { sect_num = cur_addr >> MG_MFLASH_SECTOR_SIZE_SHIFT; - mg_mflash_read_sects(sect_buff, sect_num, 1); + ret = mg_mflash_read_sects(sect_buff, sect_num, 1); + if (ret != ERROR_OK) + return ret; + memcpy(sect_buff, buff_ptr, end_addr - cur_addr); - LOG_DEBUG("copies %u byte", end_addr - cur_addr); - mg_mflash_write_sects(sect_buff, sect_num, 1); + LOG_DEBUG("mflash: copies %u byte", end_addr - cur_addr); + ret = mg_mflash_write_sects(sect_buff, sect_num, 1); } } - free(sect_buff); - - return ERROR_OK; + return ret; } static int mg_write_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -675,6 +710,7 @@ fileio_t fileio; duration_t duration; char *duration_text; + int ret; if (argc != 3) { return ERROR_COMMAND_SYNTAX_ERROR; @@ -682,9 +718,9 @@ address = strtoul(args[2], NULL, 0); - if (fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) { - return ERROR_FAIL; - } + ret = fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY); + if (ret != ERROR_OK) + return ret; buffer = malloc(MG_FILEIO_CHUNK); if (!buffer) { @@ -698,18 +734,18 @@ duration_start_measure(&duration); for (i = 0; i < cnt; i++) { - if (fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt) != + if ((ret = fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt)) != ERROR_OK) goto mg_write_cmd_err; - if (mg_mflash_write(address, buffer, MG_FILEIO_CHUNK) != ERROR_OK) + if ((ret = mg_mflash_write(address, buffer, MG_FILEIO_CHUNK)) != ERROR_OK) goto mg_write_cmd_err; address += MG_FILEIO_CHUNK; } if (res) { - if (fileio_read(&fileio, res, buffer, &buf_cnt) != ERROR_OK) + if ((ret = fileio_read(&fileio, res, buffer, &buf_cnt)) != ERROR_OK) goto mg_write_cmd_err; - if (mg_mflash_write(address, buffer, res) != ERROR_OK) + if ((ret = mg_mflash_write(address, buffer, res)) != ERROR_OK) goto mg_write_cmd_err; } @@ -731,7 +767,7 @@ free(buffer); fileio_close(&fileio); - return ERROR_FAIL; + return ret; } static int mg_dump_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -741,6 +777,7 @@ fileio_t fileio; duration_t duration; char *duration_text; + int ret; if (argc != 4) { return ERROR_COMMAND_SYNTAX_ERROR; @@ -749,9 +786,9 @@ address = strtoul(args[2], NULL, 0); size = strtoul(args[3], NULL, 0); - if (fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) { - return ERROR_FAIL; - } + ret = fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY); + if (ret != ERROR_OK) + return ret; buffer = malloc(MG_FILEIO_CHUNK); if (!buffer) { @@ -765,18 +802,18 @@ duration_start_measure(&duration); for (i = 0; i < cnt; i++) { - if (mg_mflash_read(address, buffer, MG_FILEIO_CHUNK) != ERROR_OK) + if ((ret = mg_mflash_read(address, buffer, MG_FILEIO_CHUNK)) != ERROR_OK) goto mg_dump_cmd_err; - if (fileio_write(&fileio, MG_FILEIO_CHUNK, buffer, &size_written) + if ((ret = fileio_write(&fileio, MG_FILEIO_CHUNK, buffer, &size_written)) != ERROR_OK) goto mg_dump_cmd_err; address += MG_FILEIO_CHUNK; } if (res) { - if (mg_mflash_read(address, buffer, res) != ERROR_OK) + if ((ret = mg_mflash_read(address, buffer, res)) != ERROR_OK) goto mg_dump_cmd_err; - if (fileio_write(&fileio, res, buffer, &size_written) != ERROR_OK) + if ((ret = fileio_write(&fileio, res, buffer, &size_written)) != ERROR_OK) goto mg_dump_cmd_err; } @@ -798,24 +835,25 @@ free(buffer); fileio_close(&fileio); - return ERROR_FAIL; + return ret; } static int mg_set_feature(mg_feature_id feature, mg_feature_val config) { target_t *target = mflash_bank->target; u32 mg_task_reg = mflash_bank->base + MG_REG_OFFSET; + int ret; - if (mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL) + if ((ret = mg_dsk_wait(mg_io_wait_rdy_noerr, MG_OEM_DISK_WAIT_TIME_NORMAL)) != ERROR_OK) - return ERROR_FAIL; + return ret; - target_write_u8(target, mg_task_reg + MG_REG_FEATURE, feature); - target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, config); - target_write_u8(target, mg_task_reg + MG_REG_COMMAND, + ret = target_write_u8(target, mg_task_reg + MG_REG_FEATURE, feature); + ret |= target_write_u8(target, mg_task_reg + MG_REG_SECT_CNT, config); + ret |= target_write_u8(target, mg_task_reg + MG_REG_COMMAND, mg_io_cmd_set_feature); - return ERROR_OK; + return ret; } static int mg_is_valid_pll(double XIN, int N, double CLK_OUT, int NO) @@ -824,7 +862,7 @@ double v2 = CLK_OUT * NO; if (v1 <1000000 || v1 > 15000000 || v2 < 100000000 || v2 > 500000000) - return ERROR_FAIL; + return ERROR_MG_INVALID_PLL; return ERROR_OK; } @@ -922,29 +960,34 @@ u16 i, j; u32 address = mflash_bank->base + MG_BUFFER_OFFSET; target_t *target = mflash_bank->target; + int ret; for (j = 0; j < 10; j++) { for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) buff[i] = i; - target_write_memory(target, address, 2, + ret = target_write_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff); + if (ret != ERROR_OK) + return ret; memset(buff, 0xff, MG_MFLASH_SECTOR_SIZE); - target_read_memory(target, address, 2, + ret = target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff); + if (ret != ERROR_OK) + return ret; for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) { if (buff[i] != i) { LOG_ERROR("mflash: verify interface fail"); - return ERROR_FAIL; + return ERROR_MG_INTERFACE; } } } LOG_INFO("mflash: verify interface ok"); - return ERROR_OK; + return ret; } static const char g_strSEG_SerialNum[20] = { @@ -1075,32 +1118,34 @@ static int mg_storage_config(void) { u8 buff[512]; + int ret; - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)) != ERROR_OK) - return ERROR_FAIL; + return ret; mg_gen_ataid((mg_io_type_drv_info *)buff); - if (mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_stgdrvinfo) + if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_stgdrvinfo)) != ERROR_OK) - return ERROR_FAIL; + return ret; - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)) != ERROR_OK) - return ERROR_FAIL; + return ret; LOG_INFO("mflash: storage config ok"); - return ERROR_OK; + return ret; } static int mg_boot_config(void) { u8 buff[512]; + int ret; - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)) != ERROR_OK) - return ERROR_FAIL; + return ret; memset(buff, 0xff, 512); @@ -1109,21 +1154,22 @@ buff[2] = 4; /* boot size */ *((u32 *)(buff + 4)) = 0; /* XIP size */ - if (mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_xipinfo) + if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_update_xipinfo)) != ERROR_OK) - return ERROR_FAIL; + return ret; - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)) != ERROR_OK) - return ERROR_FAIL; + return ret; LOG_INFO("mflash: boot config ok"); - return ERROR_OK; + return ret; } static int mg_set_pll(mg_pll_t *pll) { u8 buff[512]; + int ret; memset(buff, 0xff, 512); /* PLL Lock cycle and Feedback 9bit Divider */ @@ -1132,38 +1178,40 @@ buff[6] = pll->input_div; /* PLL Input 5bit Divider */ buff[7] = pll->output_div; /* PLL Output Divider */ - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)) != ERROR_OK) - return ERROR_FAIL; + return ret; - if (mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_wr_pll) + if ((ret = mg_mflash_do_write_sects(buff, 0, 1, mg_vcmd_wr_pll)) != ERROR_OK) - return ERROR_FAIL; + return ret; - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)) != ERROR_OK) - return ERROR_FAIL; + return ret; LOG_INFO("mflash: set pll ok"); - return ERROR_OK; + return ret; } static int mg_erase_nand(void) { - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd) + int ret; + + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_vcmd)) != ERROR_OK) - return ERROR_FAIL; + return ret; - if (mg_mflash_do_write_sects(NULL, 0, 0, mg_vcmd_purge_nand) + if ((ret = mg_mflash_do_write_sects(NULL, 0, 0, mg_vcmd_purge_nand)) != ERROR_OK) - return ERROR_FAIL; + return ret; - if (mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default) + if ((ret = mg_set_feature(mg_feature_id_transmode, mg_feature_val_trans_default)) != ERROR_OK) - return ERROR_FAIL; + return ret; LOG_INFO("mflash: erase nand ok"); - return ERROR_OK; + return ret; } int mg_config_cmd(struct command_context_s *cmd_ctx, char *cmd, @@ -1171,39 +1219,38 @@ { double fin, fout; mg_pll_t pll; + int ret; - if (mg_verify_interface() != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_verify_interface()) != ERROR_OK) + return ret; - if (mg_mflash_rst() != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_mflash_rst()) != ERROR_OK) + return ret; switch (argc) { case 2: - if (!strcmp(args[1], "boot")) { - if (mg_boot_config() != ERROR_OK) - return ERROR_FAIL; - - return ERROR_OK; - } else if (!strcmp(args[1], "storage")) { - if (mg_storage_config() != ERROR_OK) - return ERROR_FAIL; - - return ERROR_OK; - } else + if (!strcmp(args[1], "boot")) + return mg_boot_config(); + else if (!strcmp(args[1], "storage")) + return mg_storage_config(); + else return ERROR_COMMAND_NOTFOUND; break; case 3: if (!strcmp(args[1], "pll")) { fin = strtoul(args[2], NULL, 0); - if (fin > MG_PLL_CLK_OUT) - return ERROR_FAIL; + if (fin > MG_PLL_CLK_OUT) { + LOG_ERROR("mflash: input freq. is too large"); + return ERROR_MG_INVALID_OSC; + } fout = mg_calc_pll(fin, &pll); - if (!fout) - return ERROR_FAIL; + if (!fout) { + LOG_ERROR("mflash: cannot generate valid pll"); + return ERROR_MG_INVALID_PLL; + } LOG_INFO("mflash: Fout=%u Hz, feedback=%u," "indiv=%u, outdiv=%u, lock=%u", @@ -1211,21 +1258,16 @@ pll.input_div, pll.output_div, pll.lock_cyc); - if (mg_erase_nand() != ERROR_OK) - return ERROR_FAIL; + if ((ret = mg_erase_nand()) != ERROR_OK) + return ret; - if (mg_set_pll(&pll) != ERROR_OK) - return ERROR_FAIL; - - return ERROR_OK; + return mg_set_pll(&pll); } else return ERROR_COMMAND_NOTFOUND; break; default: return ERROR_COMMAND_SYNTAX_ERROR; } - - return ERROR_OK; } int mflash_init_drivers(struct command_context_s *cmd_ctx) @@ -1276,7 +1318,7 @@ if (! mflash_bank->gpio_drv) { LOG_ERROR("%s is unsupported soc", args[0]); - return ERROR_INVALID_ARGUMENTS; + return ERROR_MG_UNSUPPORTED_SOC; } return ERROR_OK; Modified: trunk/src/flash/mflash.h =================================================================== --- trunk/src/flash/mflash.h 2009-06-12 04:14:28 UTC (rev 2220) +++ trunk/src/flash/mflash.h 2009-06-12 21:31:11 UTC (rev 2221) @@ -178,6 +178,13 @@ #define MG_FILEIO_CHUNK 1048576 +#define ERROR_MG_IO (-1600) +#define ERROR_MG_TIMEOUT (-1601) +#define ERROR_MG_INVALID_PLL (-1603) +#define ERROR_MG_INTERFACE (-1604) +#define ERROR_MG_INVALID_OSC (-1605) +#define ERROR_MG_UNSUPPORTED_SOC (-1606) + typedef enum _mg_io_type_wait{ mg_io_wait_bsy = 1, |
From: <zw...@ma...> - 2009-06-12 06:14:32
|
Author: zwelch Date: 2009-06-12 06:14:28 +0200 (Fri, 12 Jun 2009) New Revision: 2220 Modified: trunk/src/target/mips_m4k.c Log: Further cleanup to MIPS target read/write memory function: - Move the mips32_..._read_mem calls to top-level of read_mem function. - Change: Only perform mips_m4k_read_mem conversion when retval == ERROR_OK. - Prevents pointless conversions of bogus read values after failures. - Eliminate retval variable from mips_m4k_write_mem; return directly. - Move declaration of retval variable to point of first use. - Remove the now redundant switch statements testing size: - argument sanitizing already covers these cases. Modified: trunk/src/target/mips_m4k.c =================================================================== --- trunk/src/target/mips_m4k.c 2009-06-12 04:14:18 UTC (rev 2219) +++ trunk/src/target/mips_m4k.c 2009-06-12 04:14:28 UTC (rev 2220) @@ -732,7 +732,6 @@ { mips32_common_t *mips32 = target->arch_info; mips_ejtag_t *ejtag_info = &mips32->ejtag_info; - int retval; LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count); @@ -749,22 +748,14 @@ if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u))) return ERROR_TARGET_UNALIGNED_ACCESS; - switch (size) - { - case 4: - case 2: - case 1: - /* if noDMA off, use DMAACC mode for memory read */ - if(ejtag_info->impcode & EJTAG_IMP_NODMA) - retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer); - else - retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer); - break; - default: - LOG_ERROR("BUG: we shouldn't get here"); - exit(-1); - break; - } + /* if noDMA off, use DMAACC mode for memory read */ + int retval; + if(ejtag_info->impcode & EJTAG_IMP_NODMA) + retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer); + else + retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer); + if (ERROR_OK != retval) + return retval; /* TAP data register is loaded LSB first (little endian) */ if (target->endianness == TARGET_BIG_ENDIAN) @@ -787,15 +778,14 @@ } } } - - return retval; + + return ERROR_OK; } int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { mips32_common_t *mips32 = target->arch_info; mips_ejtag_t *ejtag_info = &mips32->ejtag_info; - int retval; LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count); @@ -812,19 +802,6 @@ if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u))) return ERROR_TARGET_UNALIGNED_ACCESS; - switch (size) - { - case 4: - case 2: - case 1: - /* if noDMA off, use DMAACC mode for memory write */ - break; - default: - LOG_ERROR("BUG: we shouldn't get here"); - exit(-1); - break; - } - /* TAP data register is loaded LSB first (little endian) */ if (target->endianness == TARGET_BIG_ENDIAN) { @@ -847,13 +824,11 @@ } } + /* if noDMA off, use DMAACC mode for memory write */ if(ejtag_info->impcode & EJTAG_IMP_NODMA) - retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer); + return mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer); else - retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer); - - - return retval; + return mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer); } int mips_m4k_register_commands(struct command_context_s *cmd_ctx) |
From: <zw...@ma...> - 2009-06-12 06:14:26
|
Author: zwelch Date: 2009-06-12 06:14:18 +0200 (Fri, 12 Jun 2009) New Revision: 2219 Modified: trunk/src/target/mips_ejtag.c trunk/src/target/mips_m4k.c Log: David Claffey <dnc...@gm...>: This patch helps fix MIPS big endian (elf32-tradbigmips) targets. If "-endian big" is not set in target create, the endianess defaults to little. mw and md commands will still work, but binary file loads will have the incorrect word order loaded into memory. The EJTAG processor access data register (PrAcc) is little endian regardless of the CPU endianness; it is always loaded LSB first. This is confirmed by the fact that mips_ejtag_drscan_32() uses buf_set_u32() to load the scan field; buf_set_u32() is a little-endian formatter. For big endian targets, data buffers have to be modified so the LSB of each u32 or u16 is at the lower (first) memory location. If the drscan out_value word order is set using buf_set_u32() then it makes sense to also fixup the in_value with buf_get_u32(); a symmetry argument. This has no affect on little endian hosts. Modified: trunk/src/target/mips_ejtag.c =================================================================== --- trunk/src/target/mips_ejtag.c 2009-06-12 01:41:07 UTC (rev 2218) +++ trunk/src/target/mips_ejtag.c 2009-06-12 04:14:18 UTC (rev 2219) @@ -118,7 +118,7 @@ if (tap==NULL) return ERROR_FAIL; scan_field_t field; - u8 t[4]; + u8 t[4], r[4]; int retval; field.tap = tap; @@ -126,7 +126,7 @@ field.out_value = t; buf_set_u32(field.out_value, 0, field.num_bits, *data); - field.in_value = (u8*)data; + field.in_value = r; @@ -139,6 +139,8 @@ return retval; } + *data = buf_get_u32(field.in_value, 0, 32); + keep_alive(); return ERROR_OK; Modified: trunk/src/target/mips_m4k.c =================================================================== --- trunk/src/target/mips_m4k.c 2009-06-12 01:41:07 UTC (rev 2218) +++ trunk/src/target/mips_m4k.c 2009-06-12 04:14:18 UTC (rev 2219) @@ -732,6 +732,7 @@ { mips32_common_t *mips32 = target->arch_info; mips_ejtag_t *ejtag_info = &mips32->ejtag_info; + int retval; LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count); @@ -755,22 +756,46 @@ case 1: /* if noDMA off, use DMAACC mode for memory read */ if(ejtag_info->impcode & EJTAG_IMP_NODMA) - return mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer); + retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer); else - return mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer); + retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer); + break; default: LOG_ERROR("BUG: we shouldn't get here"); exit(-1); break; } - return ERROR_OK; + /* TAP data register is loaded LSB first (little endian) */ + if (target->endianness == TARGET_BIG_ENDIAN) + { + u32 i, t32; + u16 t16; + + for(i = 0; i < (count*size); i += size) + { + switch(size) + { + case 4: + t32 = le_to_h_u32(&buffer[i]); + h_u32_to_be(&buffer[i], t32); + break; + case 2: + t16 = le_to_h_u16(&buffer[i]); + h_u16_to_be(&buffer[i], t16); + break; + } + } + } + + return retval; } int mips_m4k_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { mips32_common_t *mips32 = target->arch_info; mips_ejtag_t *ejtag_info = &mips32->ejtag_info; + int retval; LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count); @@ -793,10 +818,6 @@ case 2: case 1: /* if noDMA off, use DMAACC mode for memory write */ - if(ejtag_info->impcode & EJTAG_IMP_NODMA) - mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer); - else - mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer); break; default: LOG_ERROR("BUG: we shouldn't get here"); @@ -804,7 +825,35 @@ break; } - return ERROR_OK; + /* TAP data register is loaded LSB first (little endian) */ + if (target->endianness == TARGET_BIG_ENDIAN) + { + u32 i, t32; + u16 t16; + + for(i = 0; i < (count*size); i += size) + { + switch(size) + { + case 4: + t32 = be_to_h_u32(&buffer[i]); + h_u32_to_le(&buffer[i], t32); + break; + case 2: + t16 = be_to_h_u16(&buffer[i]); + h_u16_to_le(&buffer[i], t16); + break; + } + } + } + + if(ejtag_info->impcode & EJTAG_IMP_NODMA) + retval = mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer); + else + retval = mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer); + + + return retval; } int mips_m4k_register_commands(struct command_context_s *cmd_ctx) |
From: <zw...@ma...> - 2009-06-12 03:41:11
|
Author: zwelch Date: 2009-06-12 03:41:07 +0200 (Fri, 12 Jun 2009) New Revision: 2218 Modified: trunk/src/jtag/tcl.c Log: Fix unitialized use of cur_speed in handle_jtag_khz_command: - Use the default KHz speed setting, in case interface is not initialized. Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 01:41:00 UTC (rev 2217) +++ trunk/src/jtag/tcl.c 2009-06-12 01:41:07 UTC (rev 2218) @@ -1038,7 +1038,7 @@ return retval; } - int cur_speed; + int cur_speed = jtag_get_speed_khz(); retval = jtag_get_speed_readable(&cur_speed); if (ERROR_OK != retval) return retval; |
From: <zw...@ma...> - 2009-06-12 03:41:04
|
Author: zwelch Date: 2009-06-12 03:41:00 +0200 (Fri, 12 Jun 2009) New Revision: 2217 Modified: trunk/src/jtag/vsllink.c Log: Improve vsllink command argument handling: - Bug fix: Always clear high bit of USB bulk out endpoint. - Use parse_ulong helpers to ensure numeric strings are parsed properly. Modified: trunk/src/jtag/vsllink.c =================================================================== --- trunk/src/jtag/vsllink.c 2009-06-12 01:40:54 UTC (rev 2216) +++ trunk/src/jtag/vsllink.c 2009-06-12 01:41:00 UTC (rev 2217) @@ -1407,9 +1407,7 @@ return ERROR_OK; } - vsllink_usb_vid = strtol(args[0], NULL, 0); - - return ERROR_OK; + return parse_u16(args[0], &vsllink_usb_vid); } static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1419,10 +1417,7 @@ LOG_ERROR("parameter error, should be one parameter for PID"); return ERROR_OK; } - - vsllink_usb_pid = strtol(args[0], NULL, 0); - - return ERROR_OK; + return parse_u16(args[0], &vsllink_usb_pid); } static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1433,9 +1428,11 @@ return ERROR_OK; } - vsllink_usb_bulkin = strtol(args[0], NULL, 0) | 0x80; + int retval = parse_u8(args[0], &vsllink_usb_bulkin); + if (ERROR_OK == retval) + vsllink_usb_bulkin |= 0x80; - return ERROR_OK; + return retval; } static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1446,9 +1443,11 @@ return ERROR_OK; } - vsllink_usb_bulkout = strtol(args[0], NULL, 0); + int retval = parse_u8(args[0], &vsllink_usb_bulkout); + if (ERROR_OK == retval) + vsllink_usb_bulkout &= ~0x80; - return ERROR_OK; + return retval; } static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1459,9 +1458,7 @@ return ERROR_OK; } - vsllink_usb_interface = strtol(args[0], NULL, 0); - - return ERROR_OK; + return parse_u8(args[0], &vsllink_usb_interface); } /***************************************************************************/ |
From: <zw...@ma...> - 2009-06-12 03:40:57
|
Author: zwelch Date: 2009-06-12 03:40:54 +0200 (Fri, 12 Jun 2009) New Revision: 2216 Modified: trunk/src/jtag/tcl.c Log: Improve handle_runtest_command: - Use parse_uint helper to ensure argument is parsed properly. Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 01:40:48 UTC (rev 2215) +++ trunk/src/jtag/tcl.c 2009-06-12 01:40:54 UTC (rev 2216) @@ -1088,7 +1088,12 @@ if (argc != 1) return ERROR_COMMAND_SYNTAX_ERROR; - jtag_add_runtest(strtol(args[0], NULL, 0), jtag_get_end_state()); + unsigned num_clocks; + int retval = parse_uint(args[0], &num_clocks); + if (ERROR_OK != retval) + return retval; + + jtag_add_runtest(num_clocks, jtag_get_end_state()); jtag_execute_queue(); return ERROR_OK; |
From: <zw...@ma...> - 2009-06-12 03:40:52
|
Author: zwelch Date: 2009-06-12 03:40:48 +0200 (Fri, 12 Jun 2009) New Revision: 2215 Modified: trunk/src/jtag/ft2232.c Log: Improve VID/PID command argument handling in FTDI driver: - Bug fix: Return a syntax error when less than two arguments are given. - Bug fix: Use parse_u16 helper to ensure vales are parsed properly. - Simplify loop termination logic by ensuring argc is always even. - Move loop induction variable declaration to where it is used. Modified: trunk/src/jtag/ft2232.c =================================================================== --- trunk/src/jtag/ft2232.c 2009-06-12 01:40:42 UTC (rev 2214) +++ trunk/src/jtag/ft2232.c 2009-06-12 01:40:48 UTC (rev 2215) @@ -2827,8 +2827,6 @@ static int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) { - int i; - if (argc > MAX_USB_IDS * 2) { LOG_WARNING("ignoring extra IDs in ft2232_vid_pid " @@ -2839,13 +2837,21 @@ { LOG_WARNING("incomplete ft2232_vid_pid configuration directive"); if (argc < 2) - return ERROR_OK; + return ERROR_COMMAND_SYNTAX_ERROR; + // remove the incomplete trailing id + argc -= 1; } - for (i = 0; i + 1 < argc; i += 2) + int i; + int retval = ERROR_OK; + for (i = 0; i < argc; i += 2) { - ft2232_vid[i >> 1] = strtol(args[i], NULL, 0); - ft2232_pid[i >> 1] = strtol(args[i + 1], NULL, 0); + retval = parse_u16(args[i], &ft2232_vid[i >> 1]); + if (ERROR_OK != retval) + break; + retval = parse_u16(args[i + 1], &ft2232_pid[i >> 1]); + if (ERROR_OK != retval) + break; } /* @@ -2854,7 +2860,7 @@ */ ft2232_vid[i >> 1] = ft2232_pid[i >> 1] = 0; - return ERROR_OK; + return retval; } |
From: <zw...@ma...> - 2009-06-12 03:40:46
|
Author: zwelch Date: 2009-06-12 03:40:42 +0200 (Fri, 12 Jun 2009) New Revision: 2214 Modified: trunk/src/jtag/tcl.c Log: Improve handle_irscan_command: - Use parse_u32 helper to ensure scan values are parsed properly. - Clear the fields buffer to ensure partial cleanup occur correctly. Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 01:40:35 UTC (rev 2213) +++ trunk/src/jtag/tcl.c 2009-06-12 01:40:42 UTC (rev 2214) @@ -1158,9 +1158,11 @@ } int num_fields = argc / 2; + size_t fields_len = sizeof(scan_field_t) * num_fields; + fields = malloc(fields_len); + memset(fields, 0, fields_len); - fields = malloc(sizeof(scan_field_t) * num_fields); - + int retval; for (i = 0; i < num_fields; i++) { tap = jtag_tap_by_string( args[i*2] ); @@ -1173,17 +1175,26 @@ fields[i].tap = tap; fields[i].num_bits = field_size; fields[i].out_value = malloc(CEIL(field_size, 8)); - buf_set_u32(fields[i].out_value, 0, field_size, strtoul(args[i*2+1], NULL, 0)); + + u32 value; + retval = parse_u32(args[i * 2 + 1], &value); + if (ERROR_OK != retval) + goto error_return; + buf_set_u32(fields[i].out_value, 0, field_size, value); fields[i].in_value = NULL; } /* did we have an endstate? */ jtag_add_ir_scan(num_fields, fields, endstate); - int retval=jtag_execute_queue(); + retval = jtag_execute_queue(); +error_return: for (i = 0; i < num_fields; i++) - free(fields[i].out_value); + { + if (NULL != fields[i].out_value) + free(fields[i].out_value); + } free (fields); |
From: <zw...@ma...> - 2009-06-12 03:40:39
|
Author: zwelch Date: 2009-06-12 03:40:35 +0200 (Fri, 12 Jun 2009) New Revision: 2213 Modified: trunk/src/jtag/tcl.c Log: Improve JTAG reset, speed, and khz handlers to use parse_uint helper. Modified: trunk/src/jtag/tcl.c =================================================================== --- trunk/src/jtag/tcl.c 2009-06-12 01:40:29 UTC (rev 2212) +++ trunk/src/jtag/tcl.c 2009-06-12 01:40:35 UTC (rev 2213) @@ -971,7 +971,13 @@ if (argc > 1) return ERROR_COMMAND_SYNTAX_ERROR; if (argc == 1) - jtag_set_nsrst_delay(strtoul(args[0], NULL, 0)); + { + unsigned delay; + int retval = parse_uint(args[0], &delay); + if (ERROR_OK != retval) + return retval; + jtag_set_nsrst_delay(delay); + } command_print(cmd_ctx, "jtag_nsrst_delay: %u", jtag_get_nsrst_delay()); return ERROR_OK; } @@ -982,7 +988,13 @@ if (argc > 1) return ERROR_COMMAND_SYNTAX_ERROR; if (argc == 1) - jtag_set_ntrst_delay(strtoul(args[0], NULL, 0)); + { + unsigned delay; + int retval = parse_uint(args[0], &delay); + if (ERROR_OK != retval) + return retval; + jtag_set_ntrst_delay(delay); + } command_print(cmd_ctx, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay()); return ERROR_OK; } @@ -997,8 +1009,10 @@ { LOG_DEBUG("handle jtag speed"); - int cur_speed = 0; - cur_speed = strtoul(args[0], NULL, 0); + unsigned cur_speed = 0; + int retval = parse_uint(args[0], &cur_speed); + if (ERROR_OK != retval) + return retval; retval = jtag_set_speed(cur_speed); } @@ -1015,9 +1029,13 @@ int retval = ERROR_OK; if (argc == 1) { - retval = jtag_config_khz(strtoul(args[0], NULL, 0)); + unsigned khz = 0; + int retval = parse_uint(args[0], &khz); if (ERROR_OK != retval) return retval; + retval = jtag_config_khz(khz); + if (ERROR_OK != retval) + return retval; } int cur_speed; |
From: <zw...@ma...> - 2009-06-12 03:40:33
|
Author: zwelch Date: 2009-06-12 03:40:29 +0200 (Fri, 12 Jun 2009) New Revision: 2212 Modified: trunk/src/jtag/core.c Log: Use parse_uint helper to replace strtoul call in jtag_tap_by_string. Modified: trunk/src/jtag/core.c =================================================================== --- trunk/src/jtag/core.c 2009-06-12 01:40:23 UTC (rev 2211) +++ trunk/src/jtag/core.c 2009-06-12 01:40:29 UTC (rev 2212) @@ -172,9 +172,8 @@ } /* no tap found by name, so try to parse the name as a number */ - char *cp; - unsigned n = strtoul(s, &cp, 0); - if ((s == cp) || (*cp != 0)) + unsigned n; + if (parse_uint(s, &n) != ERROR_OK) return NULL; return jtag_tap_by_position(n); |
From: <zw...@ma...> - 2009-06-12 03:40:27
|
Author: zwelch Date: 2009-06-12 03:40:23 +0200 (Fri, 12 Jun 2009) New Revision: 2211 Modified: trunk/src/jtag/gw16012.c Log: Simplify and improve gw16012_handle_parport_command: - Show the port number to the user when asking for it or setting it. - Print an error if the parport_port has already been set. - Use parse_u16 helper to ensure the parport_port string parses correctly. Modified: trunk/src/jtag/gw16012.c =================================================================== --- trunk/src/jtag/gw16012.c 2009-06-12 01:40:17 UTC (rev 2210) +++ trunk/src/jtag/gw16012.c 2009-06-12 01:40:23 UTC (rev 2211) @@ -571,12 +571,23 @@ static int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - if (argc == 0) - return ERROR_OK; + if (argc == 1) + { + /* only if the port wasn't overwritten by cmdline */ + if (gw16012_port == 0) + { + int retval = parse_u16(args[0], &gw16012_port); + if (ERROR_OK != retval) + return retval; + } + else + { + LOG_ERROR("The parport port was already configured!"); + return ERROR_FAIL; + } + } - /* only if the port wasn't overwritten by cmdline */ - if (gw16012_port == 0) - gw16012_port = strtoul(args[0], NULL, 0); + command_print(cmd_ctx, "parport port = %u", gw16012_port); return ERROR_OK; } |
From: <zw...@ma...> - 2009-06-12 03:40:21
|
Author: zwelch Date: 2009-06-12 03:40:17 +0200 (Fri, 12 Jun 2009) New Revision: 2210 Modified: trunk/src/jtag/amt_jtagaccel.c Log: Simplify and improve amt_jtagaccel_handle_parport_port_command: - Show the port number to the user when asking for it or setting it. - Print an error if the amt_jtagaccel_port has already been set. - Use parse_u16 helper to ensure amt_jtagaccel_port string parses correctly. Modified: trunk/src/jtag/amt_jtagaccel.c =================================================================== --- trunk/src/jtag/amt_jtagaccel.c 2009-06-12 01:40:03 UTC (rev 2209) +++ trunk/src/jtag/amt_jtagaccel.c 2009-06-12 01:40:17 UTC (rev 2210) @@ -526,14 +526,26 @@ return ERROR_OK; } -static int amt_jtagaccel_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int amt_jtagaccel_handle_parport_port_command( + struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - if (argc == 0) - return ERROR_OK; + if (argc == 1) + { + /* only if the port wasn't overwritten by cmdline */ + if (amt_jtagaccel_port == 0) + { + int retval = parse_u16(args[0], &amt_jtagaccel_port); + if (ERROR_OK != retval) + return retval; + } + else + { + LOG_ERROR("The parport port was already configured!"); + return ERROR_FAIL; + } + } - /* only if the port wasn't overwritten by cmdline */ - if (amt_jtagaccel_port == 0) - amt_jtagaccel_port = strtoul(args[0], NULL, 0); + command_print(cmd_ctx, "parport port = %u", amt_jtagaccel_port); return ERROR_OK; } |