diff --git a/modules/script/script.c b/modules/script/script.c index 6045ac4..2728a48 100644 --- a/modules/script/script.c +++ b/modules/script/script.c @@ -1585,32 +1585,34 @@ static int cmd_autoinit(script_ctx *ctx, char *line) } const char *cmd_init_and_scan_help[] = { - "", // Arguments "1(type) ..." - "explanations line one", // Explanations - "explanations line two", + "", + "Scan the JTAG chain and report the devices found with their IDCODEs.", + "Unlike jtag_autoinit, it does not load any BSDL.", "" }; static int cmd_init_and_scan(script_ctx *ctx, char *line) { jtag_core *jc; - int ret; + int ret, n, i; jc = (jtag_core *)ctx->app_ctx; ret = jtagcore_scan_and_init_chain(jc); - - if (ret == JTAG_CORE_NO_ERROR) + if (ret != JTAG_CORE_NO_ERROR) { - ctx->script_printf(ctx, MSG_INFO_0, "JTAG Scan done\n"); - - return JTAG_CORE_NO_ERROR; - } - else - { - ctx->script_printf(ctx, MSG_INFO_0, "JTAG Scan return code : %d\n", ret); + ctx->script_printf(ctx, MSG_ERROR, "JTAG scan failed (code %d)\n", ret); + return ret; } - return ret; + n = jtagcore_get_number_of_devices(jc); + ctx->script_printf(ctx, MSG_INFO_0, "%d device(s) found\n", n); + for (i = 0; i < n; i++) + { + ctx->script_printf(ctx, MSG_INFO_0, " Device %d : IDCODE 0x%.8lX\n", + i, jtagcore_get_dev_id(jc, i)); + } + ctx->last_data_value = n; + return JTAG_CORE_NO_ERROR; } const char *cmd_print_nb_dev_help[] = {