script: add bscan_jedec command

bscan_jedec <device> reads the SPI flash JEDEC ID (0x9F + 3 bytes)
through a loaded BSCAN proxy, via bscan_spi_xfer. Validation command for
the proxy path; not yet exercised on hardware.
This commit is contained in:
2026-05-23 17:16:19 +02:00
parent 0c9cc679f1
commit 12f358981f

View File

@@ -2951,6 +2951,50 @@ static int cmd_bscan_load_bitstream(script_ctx *ctx, char *line)
return JTAG_CORE_NO_ERROR;
}
const char *cmd_bscan_jedec_help[] = {
"<device>",
"Read the SPI flash JEDEC ID (0x9F) through the loaded BSCAN proxy.",
"Requires a proxy bitstream already loaded (bscan_load_bitstream).",
""};
static int cmd_bscan_jedec(script_ctx *ctx, char *line)
{
char dev_txt[DEFAULT_BUFLEN];
int device;
unsigned long idcode;
const fpga_target *t;
uint8_t tx = 0x9F;
uint8_t rx[3] = {0};
jtag_core *jc = (jtag_core *)ctx->app_ctx;
if (get_param(ctx, line, 1, dev_txt) < 0) {
ctx->script_printf(ctx, MSG_ERROR, "Usage: bscan_jedec <device>\n");
return JTAG_CORE_BAD_PARAMETER;
}
device = (int)strtoul(dev_txt, NULL, 0);
if (jtagcore_get_number_of_devices(jc) <= 0) {
ctx->script_printf(ctx, MSG_ERROR, "No device on the chain. Run jtag_autoinit first.\n");
return JTAG_CORE_NOT_FOUND;
}
idcode = jtagcore_get_dev_id(jc, device);
t = fpga_lookup_by_idcode(idcode);
if (!t) {
ctx->script_printf(ctx, MSG_ERROR, "Device %d IDCODE 0x%.8lX not in FPGA registry\n", device, idcode);
return JTAG_CORE_NOT_FOUND;
}
if (bscan_spi_xfer(jc, t, &tx, 1, rx, sizeof(rx)) < 0) {
ctx->script_printf(ctx, MSG_ERROR, "bscan_spi_xfer failed (proxy not loaded?)\n");
return JTAG_CORE_IO_ERROR;
}
ctx->script_printf(ctx, MSG_INFO_0,
"JEDEC ID: %.2X %.2X %.2X (manufacturer 0x%.2X, device 0x%.2X%.2X)\n",
rx[0], rx[1], rx[2], rx[0], rx[1], rx[2]);
ctx->last_data_value = (rx[0] << 16) | (rx[1] << 8) | rx[2];
return JTAG_CORE_NO_ERROR;
}
cmd_list script_commands_list[] =
{
{"print", cmd_print, cmd_print_help},
@@ -2998,6 +3042,7 @@ cmd_list script_commands_list[] =
{"bscan_set_ir", cmd_bscan_set_ir, cmd_bscan_set_ir_help},
{"bscan_shift_dr", cmd_bscan_shift_dr, cmd_bscan_shift_dr_help},
{"bscan_load_bitstream", cmd_bscan_load_bitstream, cmd_bscan_load_bitstream_help},
{"bscan_jedec", cmd_bscan_jedec, cmd_bscan_jedec_help},
{0, 0}};
///////////////////////////////////////////////////////////////////////////////