From 78f6bb9b34517540ce3ffaca38d1c969f26d3d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sat, 23 May 2026 11:06:43 +0200 Subject: [PATCH] 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. --- CMakeLists.txt | 5 + modules/drivers/CMakeLists.txt | 12 ++- .../drivers/digilent_jtag/digilent_jtag_drv.c | 92 +++++++++++++++++++ .../drivers/digilent_jtag/digilent_jtag_drv.h | 18 ++++ modules/drivers/drivers_list.c | 7 ++ 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 modules/drivers/digilent_jtag/digilent_jtag_drv.c create mode 100644 modules/drivers/digilent_jtag/digilent_jtag_drv.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c75a95..80906bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/modules/drivers/CMakeLists.txt b/modules/drivers/CMakeLists.txt index 9a61071..5a8ee9e 100644 --- a/modules/drivers/CMakeLists.txt +++ b/modules/drivers/CMakeLists.txt @@ -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() diff --git a/modules/drivers/digilent_jtag/digilent_jtag_drv.c b/modules/drivers/digilent_jtag/digilent_jtag_drv.c new file mode 100644 index 0000000..5184732 --- /dev/null +++ b/modules/drivers/digilent_jtag/digilent_jtag_drv.c @@ -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 +#include + +#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 + ); +} diff --git a/modules/drivers/digilent_jtag/digilent_jtag_drv.h b/modules/drivers/digilent_jtag/digilent_jtag_drv.h new file mode 100644 index 0000000..92ca3a3 --- /dev/null +++ b/modules/drivers/digilent_jtag/digilent_jtag_drv.h @@ -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 diff --git a/modules/drivers/drivers_list.c b/modules/drivers/drivers_list.c index aaeacca..6940a51 100644 --- a/modules/drivers/drivers_list.c +++ b/modules/drivers/drivers_list.c @@ -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} };