]> git.sur5r.net Git - openocd/commitdiff
nds32: Add jtag scan_chain command
authorHellosun Wu <wujiheng.tw@gmail.com>
Fri, 12 May 2017 06:37:21 +0000 (14:37 +0800)
committerTomas Vanek <vanekt@fbl.cz>
Mon, 12 Mar 2018 14:12:59 +0000 (14:12 +0000)
Create new command to refresh idcode list during runtime
and update Tap idcode.

Change-Id: Ie889a39a6f57cea207b2b9c9e42c51c97cfe4d8e
Signed-off-by: Hellosun Wu <wujiheng.tw@gmail.com>
Reviewed-on: http://openocd.zylin.com/4133
Tested-by: jenkins
Reviewed-by: Hsiangkai Wang <hsiangkai@gmail.com>
Reviewed-by: penny chen <penny6610231@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/jtag/aice/aice_interface.c
src/jtag/aice/aice_interface.h
src/jtag/aice/aice_transport.c

index 20f1f07f9b91d199649ad8f492ee78006e7841d8..c758bb43b9156ce800fe5b0bfb61ada034d19cbc 100644 (file)
@@ -239,6 +239,30 @@ static int aice_khz(int khz, int *jtag_speed)
        return ERROR_OK;
 }
 
+int aice_scan_jtag_chain(void)
+{
+       LOG_DEBUG("=== %s ===", __func__);
+       uint8_t num_of_idcode = 0;
+       struct target *target;
+
+       int res = aice_port->api->idcode(aice_target_id_codes, &num_of_idcode);
+       if (res != ERROR_OK) {
+               LOG_ERROR("<-- TARGET ERROR! Failed to identify AndesCore "
+                                       "JTAG Manufacture ID in the JTAG scan chain. "
+                                       "Failed to access EDM registers. -->");
+               return res;
+       }
+
+       for (uint32_t i = 0; i < num_of_idcode; i++)
+               LOG_DEBUG("id_codes[%d] = 0x%x", i, aice_target_id_codes[i]);
+
+       /* Update tap idcode */
+       for (target = all_targets; target; target = target->next)
+               target->tap->idcode = aice_target_id_codes[target->tap->abs_chain_position];
+
+       return ERROR_OK;
+}
+
 /***************************************************************************/
 /* Command handlers */
 COMMAND_HANDLER(aice_handle_aice_info_command)
index 0e3f10836f2b0c52f68bf0c9b1cd8fe3b9f8ec3a..220b0b04d4fb348a14ae0adca164e71933ac1915 100644 (file)
@@ -31,5 +31,6 @@ struct aice_interface_param_s {
 };
 
 int aice_init_targets(void);
+int aice_scan_jtag_chain(void);
 
 #endif /* OPENOCD_JTAG_AICE_AICE_INTERFACE_H */
index 9f079468c506644196073df783fb650dcb47172f..57c93f2a15977d5a7474e422537e78a69ced99e0 100644 (file)
@@ -158,6 +158,59 @@ COMMAND_HANDLER(handle_aice_init_command)
        return jtag_init(CMD_CTX);
 }
 
+COMMAND_HANDLER(handle_scan_chain_command)
+{
+       struct jtag_tap *tap;
+       char expected_id[12];
+
+       aice_scan_jtag_chain();
+       tap = jtag_all_taps();
+       command_print(CMD_CTX,
+               "   TapName             Enabled  IdCode     Expected   IrLen IrCap IrMask");
+       command_print(CMD_CTX,
+               "-- ------------------- -------- ---------- ---------- ----- ----- ------");
+
+       while (tap) {
+               uint32_t expected, expected_mask, ii;
+
+               snprintf(expected_id, sizeof expected_id, "0x%08x",
+                       (unsigned)((tap->expected_ids_cnt > 0)
+                                  ? tap->expected_ids[0]
+                                  : 0));
+               if (tap->ignore_version)
+                       expected_id[2] = '*';
+
+               expected = buf_get_u32(tap->expected, 0, tap->ir_length);
+               expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);
+
+               command_print(CMD_CTX,
+                       "%2d %-18s     %c     0x%08x %s %5d 0x%02x  0x%02x",
+                       tap->abs_chain_position,
+                       tap->dotted_name,
+                       tap->enabled ? 'Y' : 'n',
+                       (unsigned int)(tap->idcode),
+                       expected_id,
+                       (unsigned int)(tap->ir_length),
+                       (unsigned int)(expected),
+                       (unsigned int)(expected_mask));
+
+               for (ii = 1; ii < tap->expected_ids_cnt; ii++) {
+                       snprintf(expected_id, sizeof expected_id, "0x%08x",
+                               (unsigned) tap->expected_ids[ii]);
+                       if (tap->ignore_version)
+                               expected_id[2] = '*';
+
+                       command_print(CMD_CTX,
+                               "                                           %s",
+                               expected_id);
+               }
+
+               tap = tap->next_tap;
+       }
+
+       return ERROR_OK;
+}
+
 static int jim_aice_arp_init(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
 {
        LOG_DEBUG("No implement: jim_aice_arp_init");
@@ -307,6 +360,13 @@ aice_transport_jtag_subcommand_handlers[] = {
                .jim_handler = jim_aice_names,
                .help = "Returns list of all JTAG tap names.",
        },
+       {
+               .name = "scan_chain",
+               .handler = handle_scan_chain_command,
+               .mode = COMMAND_ANY,
+               .help = "print current scan chain configuration",
+               .usage = ""
+       },
 
        COMMAND_REGISTRATION_DONE
 };