David Brownell <david-b@pacbell.net> start phasing out integers as target IDs
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 30 Aug 2009 17:30:14 +0000 (17:30 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Sun, 30 Aug 2009 17:30:14 +0000 (17:30 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@2650 b42882b7-edfa-0310-969c-e2dbd0fdcd60

doc/openocd.texi
src/flash/at91sam7.c
src/flash/orion_nand.c
src/helper/startup.tcl
src/server/gdb_server.c
src/target/target.c
src/target/target.h

index 14dec6d215bbc4b1ddbf530befd10eff082aa368..8b679705f9d1fa0e5844a8edc82143af4e8873dd 100644 (file)
@@ -2365,6 +2365,10 @@ are examples; and there are many more.
 Several commands let you examine the list of targets:
 
 @deffn Command {target count}
 Several commands let you examine the list of targets:
 
 @deffn Command {target count}
+@emph{Note: target numbers are deprecated; don't use them.
+They will be removed shortly after August 2010, including this command.
+Iterate target using @command{target names}, not by counting.}
+
 Returns the number of targets, @math{N}.
 The highest numbered target is @math{N - 1}.
 @example
 Returns the number of targets, @math{N}.
 The highest numbered target is @math{N - 1}.
 @example
@@ -2390,6 +2394,9 @@ foreach t [target names] @{
 @end deffn
 
 @deffn Command {target number} number
 @end deffn
 
 @deffn Command {target number} number
+@emph{Note: target numbers are deprecated; don't use them.
+They will be removed shortly after August 2010, including this command.}
+
 The list of targets is numbered starting at zero.
 This command returns the name of the target at index @var{number}.
 @example
 The list of targets is numbered starting at zero.
 This command returns the name of the target at index @var{number}.
 @example
@@ -2711,8 +2718,7 @@ For example, if you wanted to summarize information about
 all the targets you might use something like this:
 
 @example
 all the targets you might use something like this:
 
 @example
-for @{ set x 0 @} @{ $x < [target count] @} @{ incr x @} @{
-    set name [target number $x]
+foreach name [target names] @{
     set y [$name cget -endian]
     set z [$name cget -type]
     puts [format "Chip %d is %s, Endian: %s, type: %s" \
     set y [$name cget -endian]
     set z [$name cget -type]
     puts [format "Chip %d is %s, Endian: %s, type: %s" \
index 04790617fafb2252177b3dabcd74ad1662aed375..315a3f3ffd195e1ef7dd441f9902eb87cda5c66f 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ****************************************************************************/
 
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ****************************************************************************/
 
-/***************************************************************************************************************************************************************************************
+/***************************************************************************
 *
 * New flash setup command:
 *
 *
 * New flash setup command:
 *
-* flash bank <driver> <base_addr> <size> <chip_width> <bus_width> <target_number> [<target_name> <banks> <sectors_per_bank> <pages_per_sector> <page_size> <num_nvmbits> <ext_freq_khz>]
+* flash bank <driver> <base_addr> <size> <chip_width> <bus_width> <target_id>
+*      [<chip_type> <banks>
+*       <sectors_per_bank> <pages_per_sector>
+*       <page_size> <num_nvmbits>
+*       <ext_freq_khz>]
 *
 *   <ext_freq_khz> - MUST be used if clock is from external source,
 *
 *   <ext_freq_khz> - MUST be used if clock is from external source,
-*                    CAN be used if main oscillator frequency is known (recomended)
+*                    CAN be used if main oscillator frequency is known (recommended)
 * Examples:
 * Examples:
-*  flash bank at91sam7 0x00100000 0 0 4 0 0 AT91SAM7XC256 1 16 64 256 3 25000                   ==== RECOMENDED ============
-*  flash bank at91sam7 0 0 0 0 0 0 0 0 0 0 0 0 25000    (auto-detection, except for clock)      ==== RECOMENDED ============
-*  flash bank at91sam7 0x00100000 0 0 4 0 0 AT91SAM7XC256 1 16 64 256 3 0                       ==== NOT RECOMENDED !!! ====
-*  flash bank at91sam7 0 0 0 0 0            (old style, full auto-detection)                    ==== NOT RECOMENDED !!! ====
-****************************************************************************************************************************************************************************************/
+* ==== RECOMMENDED (covers clock speed) ============
+*  flash bank at91sam7 0x00100000 0 0 4 $_TARGETNAME AT91SAM7XC256 1 16 64 256 3 25000
+*                      (if auto-detect fails; provides clock spec)
+*  flash bank at91sam7 0 0 0 0 $_TARGETNAME 0 0 0 0 0 0 25000
+*                      (auto-detect everything except the clock)
+* ==== NOT RECOMMENDED !!! (clock speed is not configured) ====
+*  flash bank at91sam7 0x00100000 0 0 4 $_TARGETNAME AT91SAM7XC256 1 16 64 256 3 0
+*                      (if auto-detect fails)
+*  flash bank at91sam7 0 0 0 0 $_TARGETNAME
+*                      (old style, auto-detect everything)
+****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -734,16 +744,6 @@ static int at91sam7_protect_check(struct flash_bank_s *bank)
        return ERROR_OK;
 }
 
        return ERROR_OK;
 }
 
-/***************************************************************************************************************************************************************************************
-# flash bank <driver> <base_addr> <size> <chip_width> <bus_width> <target_number> [<target_name> <banks> <sectors_per_bank> <pages_per_sector> <page_size> <num_nvmbits> <ext_freq_khz>]
-#   <ext_freq_khz> - MUST be used if clock is from external source
-#                    CAN be used if main oscillator frequency is known
-# Examples:
-#  flash bank at91sam7 0x00100000 0 0 4 0 0 AT91SAM7XC256 1 16 64 256 3 25000                   ==== RECOMENDED ============
-#  flash bank at91sam7 0 0 0 0 0 0 0 0 0 0 0 0 25000    (auto-detection, except for clock)      ==== RECOMENDED ============
-#  flash bank at91sam7 0x00100000 0 0 4 0 0 AT91SAM7XC256 1 16 64 256 3 0                       ==== NOT RECOMENDED !!! ====
-#  flash bank at91sam7 0 0 0 0 0                        (old style, full auto-detection)        ==== NOT RECOMENDED !!! ====
-****************************************************************************************************************************************************************************************/
 static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
 {
        flash_bank_t *t_bank = bank;
 static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
 {
        flash_bank_t *t_bank = bank;
index 6b50f1fb9a421377d214781ad60c9161ef9a521c..dc9d78c53791fe500d7761afd9bc90a4da8333e6 100644 (file)
@@ -198,7 +198,7 @@ int orion_nand_device_command(struct command_context_s *cmd_ctx, char *cmd,
        uint8_t ale, cle;
 
        if (argc != 3) {
        uint8_t ale, cle;
 
        if (argc != 3) {
-               LOG_ERROR("arguments must be: <target_number> <NAND_address>\n");
+               LOG_ERROR("arguments must be: <target_id> <NAND_address>\n");
                return ERROR_NAND_DEVICE_INVALID;
        }
 
                return ERROR_NAND_DEVICE_INVALID;
        }
 
index 14b209205a5162b527f13cba8ac63abed60671a4..b85f47682c783568a602e8f17557db41af8cbfa2 100644 (file)
@@ -128,7 +128,7 @@ add_help_text script "<filename> - filename of OpenOCD script (tcl) to run"
 # Handle GDB 'R' packet. Can be overriden by configuration script,
 # but it's not something one would expect target scripts to do
 # normally
 # Handle GDB 'R' packet. Can be overriden by configuration script,
 # but it's not something one would expect target scripts to do
 # normally
-proc ocd_gdb_restart {target_num} {
+proc ocd_gdb_restart {target_id} {
        # Fix!!! we're resetting all targets here! Really we should reset only
        # one target
        reset halt
        # Fix!!! we're resetting all targets here! Really we should reset only
        # one target
        reset halt
index 48144f2665a3048b6d81398c8cbc9d21df8615af..948e44bae9e62ebcfb7b2e48d1aa7561140df194 100644 (file)
@@ -2156,7 +2156,9 @@ int gdb_input_inner(connection_t *connection)
                                        /* handle extended restart packet */
                                        breakpoint_clear_target(gdb_service->target);
                                        watchpoint_clear_target(gdb_service->target);
                                        /* handle extended restart packet */
                                        breakpoint_clear_target(gdb_service->target);
                                        watchpoint_clear_target(gdb_service->target);
-                                       command_run_linef(connection->cmd_ctx, "ocd_gdb_restart %d", get_num_by_target(target));
+                                       command_run_linef(connection->cmd_ctx,
+                                                       "ocd_gdb_restart %s",
+                                                       target->cmd_name);
                                        break;
                                default:
                                        /* ignore unkown packets */
                                        break;
                                default:
                                        /* ignore unkown packets */
@@ -2230,17 +2232,23 @@ int gdb_init(void)
        }
        else
        {
        }
        else
        {
+               unsigned short port = gdb_port;
+
                while (target)
                {
                        gdb_service = malloc(sizeof(gdb_service_t));
                        gdb_service->target = target;
 
                while (target)
                {
                        gdb_service = malloc(sizeof(gdb_service_t));
                        gdb_service->target = target;
 
-                       add_service("gdb", CONNECTION_TCP, gdb_port + target->target_number, 1, gdb_new_connection, gdb_input, gdb_connection_closed, gdb_service);
+                       add_service("gdb", CONNECTION_TCP,
+                                       port, 1,
+                                       gdb_new_connection, gdb_input,
+                                       gdb_connection_closed, gdb_service);
 
 
-                       LOG_DEBUG("gdb service for target %s at port %i",
+                       LOG_DEBUG("gdb service for target %s at TCP port %i",
                                        target_get_name(target),
                                        target_get_name(target),
-                                       gdb_port + target->target_number);
+                                       port);
                        target = target->next;
                        target = target->next;
+                       port++;
                }
        }
 
                }
        }
 
index 381e774e882e2dd3bae13981e0b864c66aa06705..b6ea65551632635d69aead809957c495b0be7455 100644 (file)
@@ -249,22 +249,6 @@ target_state_name( target_t *t )
        return cp;
 }
 
        return cp;
 }
 
-static int max_target_number(void)
-{
-       target_t *t;
-       int x;
-
-       x = -1;
-       t = all_targets;
-       while (t) {
-               if (x < t->target_number) {
-                       x = (t->target_number) + 1;
-               }
-               t = t->next;
-       }
-       return x;
-}
-
 /* determine the number of the new target */
 static int new_target_number(void)
 {
 /* determine the number of the new target */
 static int new_target_number(void)
 {
@@ -346,14 +330,19 @@ target_t *get_target(const char *id)
                        return target;
        }
 
                        return target;
        }
 
+       /* It's OK to remove this fallback sometime after August 2010 or so */
+
        /* no match, try as number */
        unsigned num;
        if (parse_uint(id, &num) != ERROR_OK)
                return NULL;
 
        for (target = all_targets; target; target = target->next) {
        /* no match, try as number */
        unsigned num;
        if (parse_uint(id, &num) != ERROR_OK)
                return NULL;
 
        for (target = all_targets; target; target = target->next) {
-               if (target->target_number == (int)num)
+               if (target->target_number == (int)num) {
+                       LOG_WARNING("use '%s' as target identifier, not '%u'",
+                                       target->cmd_name, num);
                        return target;
                        return target;
+               }
        }
 
        return NULL;
        }
 
        return NULL;
@@ -374,11 +363,6 @@ static target_t *get_target_by_num(int num)
        return NULL;
 }
 
        return NULL;
 }
 
-int get_num_by_target(target_t *query_target)
-{
-       return query_target->target_number;
-}
-
 target_t* get_current_target(command_context_t *cmd_ctx)
 {
        target_t *target = get_target_by_num(cmd_ctx->current_target);
 target_t* get_current_target(command_context_t *cmd_ctx)
 {
        target_t *target = get_target_by_num(cmd_ctx->current_target);
@@ -4387,6 +4371,8 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                return target_create(&goi);
                break;
        case TG_CMD_NUMBER:
                return target_create(&goi);
                break;
        case TG_CMD_NUMBER:
+               /* It's OK to remove this mechanism sometime after August 2010 or so */
+               LOG_WARNING("don't use numbers as target identifiers; use names");
                if (goi.argc != 1) {
                        Jim_SetResult_sprintf(goi.interp, "expected: target number ?NUMBER?");
                        return JIM_ERR;
                if (goi.argc != 1) {
                        Jim_SetResult_sprintf(goi.interp, "expected: target number ?NUMBER?");
                        return JIM_ERR;
@@ -4395,23 +4381,25 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                if (e != JIM_OK) {
                        return JIM_ERR;
                }
                if (e != JIM_OK) {
                        return JIM_ERR;
                }
-               {
-                       target_t *t;
-                       t = get_target_by_num(w);
-                       if (t == NULL) {
-                               Jim_SetResult_sprintf(goi.interp,"Target: number %d does not exist", (int)(w));
-                               return JIM_ERR;
-                       }
-                       Jim_SetResultString(goi.interp, t->cmd_name, -1);
-                       return JIM_OK;
+               for (x = 0, target = all_targets; target; target = target->next, x++) {
+                       if (target->target_number == w)
+                               break;
                }
                }
+               if (target == NULL) {
+                       Jim_SetResult_sprintf(goi.interp,
+                                       "Target: number %d does not exist", (int)(w));
+                       return JIM_ERR;
+               }
+               Jim_SetResultString(goi.interp, target->cmd_name, -1);
+               return JIM_OK;
        case TG_CMD_COUNT:
                if (goi.argc != 0) {
                        Jim_WrongNumArgs(goi.interp, 0, goi.argv, "<no parameters>");
                        return JIM_ERR;
                }
        case TG_CMD_COUNT:
                if (goi.argc != 0) {
                        Jim_WrongNumArgs(goi.interp, 0, goi.argv, "<no parameters>");
                        return JIM_ERR;
                }
-               Jim_SetResult(goi.interp,
-                                          Jim_NewIntObj(goi.interp, max_target_number()));
+               for (x = 0, target = all_targets; target; target = target->next, x++)
+                       continue;
+               Jim_SetResult(goi.interp, Jim_NewIntObj(goi.interp, x));
                return JIM_OK;
        }
 
                return JIM_OK;
        }
 
index 9894aca99e1b850987ba689b6dae2ff90f01b096..509bfd2a22ac90496b83db6f8978c51eafd9d06b 100644 (file)
@@ -120,7 +120,7 @@ typedef struct target_s
 {
        target_type_t *type;                            /* target type definition (name, access functions) */
        const char *cmd_name;                           /* tcl Name of target */
 {
        target_type_t *type;                            /* target type definition (name, access functions) */
        const char *cmd_name;                           /* tcl Name of target */
-       int target_number;                                      /* generaly, target index but may not be in order */
+       int target_number;                                      /* DO NOT USE!  field to be removed in 2010 */
        jtag_tap_t *tap;                                        /* where on the jtag chain is this */
        const char *variant;                            /* what varient of this chip is it? */
        target_event_action_t *event_action;
        jtag_tap_t *tap;                                        /* where on the jtag chain is this */
        const char *variant;                            /* what varient of this chip is it? */
        target_event_action_t *event_action;
@@ -250,7 +250,6 @@ extern int target_call_timer_callbacks(void);
 extern int target_call_timer_callbacks_now(void);
 
 extern target_t* get_current_target(struct command_context_s *cmd_ctx);
 extern int target_call_timer_callbacks_now(void);
 
 extern target_t* get_current_target(struct command_context_s *cmd_ctx);
-extern int get_num_by_target(target_t *query_target);
 extern target_t *get_target(const char *id);
 
 /**
 extern target_t *get_target(const char *id);
 
 /**

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)