digilent: add driver skeleton + CMake option BS_ENABLE_DIGILENT

Stub Digilent JTAG-SMT backend, off by default. Wiring only: option,
conditional sources, dl link, drivers_list registration. Detect()
returns 0 for now; dlopen + real implementation in follow-up commits.
This commit is contained in:
2026-05-23 11:06:43 +02:00
parent 3c1e5f987e
commit 78f6bb9b34
5 changed files with 133 additions and 1 deletions

View File

@@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.10)
project(BoundaryScanExplorer)
# Optional backends. Off by default: no proprietary runtime dependency.
option(BS_ENABLE_DIGILENT
"Enable Digilent JTAG-SMT* backend (dlopen libdjtg.so / libdmgr.so at runtime; requires Adept Runtime installed)"
OFF)
# script and jtag_core must be the last linked archive for the application to compile
set(BS_MODULES script jtag_core)
set(DIR_MODULES ${CMAKE_SOURCE_DIR}/modules)

View File

@@ -5,10 +5,20 @@ file(GLOB_RECURSE JLINK_SOURCES "jlink_jtag/*.c")
file(GLOB_RECURSE FTDI_SOURCES "ftdi_jtag/*.c")
file(GLOB_RECURSE GPIO_SOURCES "linux_gpio_jtag/*.c")
set(DIGILENT_SOURCES "")
if(BS_ENABLE_DIGILENT)
file(GLOB_RECURSE DIGILENT_SOURCES "digilent_jtag/*.c")
add_compile_definitions(BS_ENABLE_DIGILENT)
endif()
include_directories(${DIR_MODULES})
include_directories(${DIR_LIBS})
add_compile_definitions(FTD2XX_STATIC)
add_compile_definitions(FTDILIB)
add_library(drivers ${MAIN_SOURCES} ${FTDI_SOURCES} ${GPIO_SOURCES} ${JLINK_SOURCES})
add_library(drivers ${MAIN_SOURCES} ${FTDI_SOURCES} ${GPIO_SOURCES} ${JLINK_SOURCES} ${DIGILENT_SOURCES})
if(BS_ENABLE_DIGILENT)
target_link_libraries(drivers PUBLIC ${CMAKE_DL_LIBS})
endif()

View File

@@ -0,0 +1,92 @@
/*
* Boundary-Scan Explorer - Digilent JTAG-SMT* driver (skeleton)
*
* Step 1: build wiring + driver registration only. Detect() returns 0,
* Init() returns an error. Real implementation lands in subsequent steps.
*/
#include <stdio.h>
#include <string.h>
#include "jtag_core/jtag_core.h"
#include "jtag_core/dbg_logs.h"
#include "config/bs_defines.h"
#include "drivers/drv_loader.h"
#include "digilent_jtag_drv.h"
#define MAX_PROBES_DIGILENT 8
typedef struct _digilent_drv_desc
{
char drv_id[64];
char drv_desc[128];
int sub_drv_id;
} digilent_drv_desc;
static digilent_drv_desc subdrv_list[MAX_PROBES_DIGILENT] = {
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
{"DIGILENT_SMT_PROBE", "DIGILENT JTAG-SMT PROBE", 0},
};
static int drv_Digilent_Detect(jtag_core * jc)
{
/* Step 2 will populate subdrv_list via DmgrEnumDevices. */
return 0;
}
static int drv_Digilent_Init(jtag_core * jc, int sub_drv, char * params)
{
jtagcore_logs_printf(jc, MSG_ERROR,
"drv_Digilent_Init : Digilent backend not yet implemented\r\n");
return -1;
}
static int drv_Digilent_DeInit(jtag_core * jc)
{
return 0;
}
static int drv_Digilent_TMS_xfer(jtag_core * jc, unsigned char * str_out, int size)
{
return -1;
}
static int drv_Digilent_TDOTDI_xfer(jtag_core * jc,
unsigned char * str_out,
unsigned char * str_in,
int size)
{
return -1;
}
int drv_Digilent_libGetDrv(jtag_core * jc, int sub_drv, unsigned int infotype, void * returnvalue)
{
drv_ptr drv_funcs = {
(DRV_DETECT) drv_Digilent_Detect,
(DRV_INIT) drv_Digilent_Init,
(DRV_DEINIT) drv_Digilent_DeInit,
(DRV_TXTMS) drv_Digilent_TMS_xfer,
(DRV_TXRXDATA) drv_Digilent_TDOTDI_xfer,
(DRV_GETMODULEINFOS) drv_Digilent_libGetDrv,
};
if (sub_drv < 0 || sub_drv >= MAX_PROBES_DIGILENT)
return JTAG_CORE_BAD_PARAMETER;
return GetDrvInfo(
jc,
infotype,
returnvalue,
subdrv_list[sub_drv].drv_id,
subdrv_list[sub_drv].drv_desc,
&drv_funcs
);
}

View File

@@ -0,0 +1,18 @@
#ifndef _DIGILENT_JTAG_DRV_H
#define _DIGILENT_JTAG_DRV_H
/*
* Boundary-Scan Explorer - Digilent JTAG-SMT* driver
*
* Talks to Digilent JTAG modules (SMT2, SMT2-NC, SMT3, ...) through
* dlopen of libdjtg.so / libdmgr.so at runtime. No Digilent binary or
* header is embedded in this repository; the typedefs in djtg_dlsym.h
* are hand-rolled from the public Adept API.
*
* Enabled with -DBS_ENABLE_DIGILENT=ON at CMake configure time.
*/
#include "jtag_core/jtag_core.h"
int drv_Digilent_libGetDrv(jtag_core * jc, int sub_drv, unsigned int infotype, void * returnvalue);
#endif

View File

@@ -40,6 +40,10 @@
#include "./jlink_jtag/jlink_jtag_drv.h"
#endif
#ifdef BS_ENABLE_DIGILENT
#include "./digilent_jtag/digilent_jtag_drv.h"
#endif
#include "drivers_list.h"
const drv_entry staticdrvs[] =
@@ -57,6 +61,9 @@ const drv_entry staticdrvs[] =
#endif
#if defined(__linux__)
{(DRV_GETMODULEINFOS)drv_LinuxGPIO_libGetDrv,0},
#endif
#ifdef BS_ENABLE_DIGILENT
{(DRV_GETMODULEINFOS)drv_Digilent_libGetDrv,0},
#endif
{(DRV_GETMODULEINFOS)-1,0}
};