jtag: driver-neutral JTAG_TCK_FREQ_KHZ clock (phase A)
One clock knob across probes instead of per-driver names: - jtag_open mirrors JTAG_TCK_FREQ_KHZ into PROBE_FTDI_TCK_FREQ_KHZ for the Viveris FTDI driver (read-only at init); unset leaves the existing value untouched - the Digilent driver reads JTAG_TCK_FREQ_KHZ directly instead of hardcoding 4 MHz (falls back to 4 MHz when unset) - documented in probes.yaml; CLAUDE.md design note marks phase A done FTDI path validated on the IGLOO2/FlashPro (250 kHz, mirror confirmed); Digilent path not hardware-tested. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "jtag_core/jtag_core.h"
|
||||
#include "jtag_core/dbg_logs.h"
|
||||
#include "config/bs_defines.h"
|
||||
#include "script/env.h"
|
||||
|
||||
#include "drivers/drv_loader.h"
|
||||
|
||||
@@ -209,11 +210,17 @@ static int drv_Digilent_Detect(jtag_core *jc)
|
||||
|
||||
static int drv_Digilent_Init(jtag_core *jc, int sub_drv, char *params)
|
||||
{
|
||||
DJ_DWORD frq_req = 4000000; /* 4 MHz — safe and fast enough for IDCODE/IR */
|
||||
DJ_DWORD frq_req;
|
||||
DJ_DWORD frq_set = 0;
|
||||
int tck_khz;
|
||||
|
||||
(void)params;
|
||||
|
||||
/* Driver-neutral JTAG clock (JTAG_TCK_FREQ_KHZ, kHz). Unset/<=0 keeps
|
||||
* the 4 MHz default — safe and fast enough for IDCODE/IR. */
|
||||
tck_khz = jtagcore_getEnvVarValue(jc, "JTAG_TCK_FREQ_KHZ");
|
||||
frq_req = (tck_khz > 0) ? (DJ_DWORD)tck_khz * 1000u : 4000000u;
|
||||
|
||||
/* Lazy enumeration: jtag_open can be called without going
|
||||
* through jtag_probes first, so make sure Detect ran. */
|
||||
if (g_dj_num_probes == 0) {
|
||||
|
||||
@@ -1863,6 +1863,20 @@ static int cmd_open_probe(script_ctx *ctx, char *line)
|
||||
ctx->script_printf(ctx, MSG_INFO_0, "Applied probe profile '%s'.\n", profile);
|
||||
}
|
||||
|
||||
// Driver-neutral JTAG clock: if JTAG_TCK_FREQ_KHZ is set, feed it to
|
||||
// the Viveris FTDI driver's own variable (it reads only PROBE_FTDI_*;
|
||||
// our Digilent driver reads the neutral name directly). Harmless for
|
||||
// the other drivers, which keep their defaults.
|
||||
{
|
||||
int tck_khz = jtagcore_getEnvVarValue(jc, "JTAG_TCK_FREQ_KHZ");
|
||||
if (tck_khz > 0)
|
||||
{
|
||||
char tck_str[24];
|
||||
snprintf(tck_str, sizeof(tck_str), "%d", tck_khz);
|
||||
setEnvVarDat((envvar_entry *)ctx->env, "PROBE_FTDI_TCK_FREQ_KHZ", tck_str);
|
||||
}
|
||||
}
|
||||
|
||||
ret = jtagcore_select_and_open_probe(jc, id);
|
||||
if (ret != JTAG_CORE_NO_ERROR)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user