This is an automated email from Gerrit.

Hellosun Wu ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/4133

-- gerrit

commit ab9f3dbc1150d2d0656b062c5e1a5a906358d576
Author: Hellosun Wu <[email protected]>
Date:   Fri May 12 14:37:21 2017 +0800

    nds32: Add jtag scan_chain command
    
    It support changing at runtime elements from JTAG chain and update JTAG 
chain
    by calling aice_scan_id_codes function.
    
    Change-Id: Ie889a39a6f57cea207b2b9c9e42c51c97cfe4d8e
    Signed-off-by: Hellosun Wu <[email protected]>

diff --git a/src/jtag/aice/aice_interface.c b/src/jtag/aice/aice_interface.c
index 20f1f07..1667113 100644
--- a/src/jtag/aice/aice_interface.c
+++ b/src/jtag/aice/aice_interface.c
@@ -239,6 +239,37 @@ static int aice_khz(int khz, int *jtag_speed)
        return ERROR_OK;
 }
 
+static uint32_t *p_aice_target_id_codes = (uint32_t *)&aice_target_id_codes[0];
+static int aice_update_tap_info(void)
+{
+       LOG_DEBUG("=== %s ===", __func__);
+       struct target *target;
+
+       for (target = all_targets; target; target = target->next)
+               target->tap->idcode = 
p_aice_target_id_codes[target->tap->abs_chain_position];
+
+       return ERROR_OK;
+}
+
+int aice_scan_jtag_chain(void)
+{
+       LOG_DEBUG("=== %s ===", __func__);
+       uint8_t num_of_idcode = 0;
+
+       int res = aice_port->api->idcode(p_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, p_aice_target_id_codes[i]);
+
+       return aice_update_tap_info();
+}
+
 /***************************************************************************/
 /* Command handlers */
 COMMAND_HANDLER(aice_handle_aice_info_command)
diff --git a/src/jtag/aice/aice_transport.c b/src/jtag/aice/aice_transport.c
index 9f07946..0b84080 100644
--- a/src/jtag/aice/aice_transport.c
+++ b/src/jtag/aice/aice_transport.c
@@ -158,6 +158,60 @@ COMMAND_HANDLER(handle_aice_init_command)
        return jtag_init(CMD_CTX);
 }
 
+extern int aice_scan_jtag_chain(void);
+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 +361,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
 };

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to