bsdl: extract parser into standalone libbsdl, pulled via FetchContent

The BSDL loader (seeded from the Viveris parser) now lives in its own
LGPL repo, electronics/libbsdl, consumed with CMake FetchContent.
Local development override: -DFETCHCONTENT_SOURCE_DIR_BSDL=<path>.
src/modules/bsdl_parser/ is removed; callers go through the libbsdl
API. Build verified against the libbsdl checkout.
This commit is contained in:
2026-06-13 00:10:02 +02:00
parent 43d291418b
commit 2752c3404b
19 changed files with 154 additions and 1897 deletions

View File

@@ -20,7 +20,12 @@ other families (Lattice, Microsemi, …) by playing a vendor-exported SVF.
The Viveris library itself lives unchanged in `src/modules/`. Everything The Viveris library itself lives unchanged in `src/modules/`. Everything
new is in `src/bs/` (the REPL) and the project modules (`target/`, new is in `src/bs/` (the REPL) and the project modules (`target/`,
`bscan/`, `spi_flash/`, `svf/`, `probes/`, `program/`, `arm_debug/`) `bscan/`, `spi_flash/`, `svf/`, `probes/`, `program/`, `arm_debug/`)
sitting alongside the Viveris ones. sitting alongside the Viveris ones. The BSDL parser was extracted into
a standalone library, **[libbsdl](ssh://gitea@git.beafrancois.fr:8329/electronics/libbsdl.git)**
(LGPL, seeded from the same Viveris loader), and is now pulled in via
CMake `FetchContent` instead of vendored. To build against a local
checkout (e.g. side-by-side dev): configure with
`-DFETCHCONTENT_SOURCE_DIR_BSDL=/path/to/libbsdl`.
## Architecture ## Architecture
@@ -30,13 +35,14 @@ src/
└── modules/ └── modules/
— Viveris's library (LGPL, unchanged) — — Viveris's library (LGPL, unchanged) —
├── jtag_core/ TAP state machine, IR/DR shifts ├── jtag_core/ TAP state machine, IR/DR shifts
├── bsdl_parser/ .bsd loader
├── bus_over_jtag/ SPI/I²C/MDIO/parallel mem bit-bang over EXTEST ├── bus_over_jtag/ SPI/I²C/MDIO/parallel mem bit-bang over EXTEST
├── drivers/ FTDI, J-Link, Linux GPIO, LPT, Digilent (optional, dlopen) ├── drivers/ FTDI, J-Link, Linux GPIO, LPT, Digilent (optional, dlopen)
├── script/ Script engine (the real UI) ├── script/ Script engine (the real UI)
├── config/ Built-in config.script ├── config/ Built-in config.script
├── os_interface/ Portable fs/network wrappers ├── os_interface/ Portable fs/network wrappers
└── natsort/ Natural pin-name sorting └── natsort/ Natural pin-name sorting
— pulled via FetchContent (LGPL, separate repo) —
└── (libbsdl) BSDL (.bsd) parser; struct + JSON; stable C ABI
— new (this project) — — new (this project) —
├── target/ Target registry: FPGAs + CPUs (parses data/targets.yaml) ├── target/ Target registry: FPGAs + CPUs (parses data/targets.yaml)
├── bscan/ JTAG TAP primitives (set_ir/shift_ir/shift_dr/tap_reset/ ├── bscan/ JTAG TAP primitives (set_ir/shift_ir/shift_dr/tap_reset/
@@ -528,7 +534,11 @@ mkdir build && cd build && cmake .. && make
Build needs **libyaml** (pkg-config `yaml-0.1`; Arch `libyaml`, Debian Build needs **libyaml** (pkg-config `yaml-0.1`; Arch `libyaml`, Debian
`libyaml-dev`) for the registry, and **libftdi1** + **libusb-1.0** `libyaml-dev`) for the registry, and **libftdi1** + **libusb-1.0**
(pkg-config `libftdi1`; Arch `libftdi`, Debian `libftdi1-dev`) for the (pkg-config `libftdi1`; Arch `libftdi`, Debian `libftdi1-dev`) for the
FTDI/Olimex driver. Run `bs` from the repo root so it finds FTDI/Olimex driver. **libbsdl** (the BSDL parser, separate repo) is
pulled in by CMake `FetchContent` at configure time — needs network on
first build. For a local checkout, configure with
`-DFETCHCONTENT_SOURCE_DIR_BSDL=/path/to/libbsdl` (built-in FetchContent
override, no clone happens). Run `bs` from the repo root so it finds
`data/targets.yaml` (and `data/bsdl_files/`, `data/bscan_proxies/`), or `data/targets.yaml` (and `data/bsdl_files/`, `data/bscan_proxies/`), or
point `$BS_TARGETS` at it. point `$BS_TARGETS` at it.

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.14)
project(BoundaryScanExplorer) project(BoundaryScanExplorer)
@@ -6,6 +6,19 @@ project(BoundaryScanExplorer)
# build/src/bs/ where the source tree would otherwise mirror it. # build/src/bs/ where the source tree would otherwise mirror it.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# ---- libbsdl (BSDL parser, extracted from this repo and now standalone) ----
# Pulled via FetchContent from the canonical Gitea URL. For a local checkout,
# set -DFETCHCONTENT_SOURCE_DIR_BSDL=/path/to/libbsdl at configure time
# (built-in FetchContent override — no clone happens).
include(FetchContent)
set(BSDL_BUILD_CLI OFF CACHE BOOL "" FORCE)
set(BSDL_BUILD_TESTS OFF CACHE BOOL "" FORCE)
FetchContent_Declare(bsdl
GIT_REPOSITORY ssh://gitea@git.beafrancois.fr:8329/electronics/libbsdl.git
GIT_TAG main
)
FetchContent_MakeAvailable(bsdl)
# Digilent JTAG-SMT* backend. The driver dlopen's libdjtg/libdmgr at # Digilent JTAG-SMT* backend. The driver dlopen's libdjtg/libdmgr at
# runtime and degrades to "no probe" if they're absent, so building it # runtime and degrades to "no probe" if they're absent, so building it
# in costs nothing — default ON. Needs <dlfcn.h>, so UNIX only. # in costs nothing — default ON. Needs <dlfcn.h>, so UNIX only.

View File

@@ -1,7 +0,0 @@
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
file(GLOB_RECURSE ALL_SOURCES "*.c")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_library(bsdl_parser ${ALL_SOURCES})

File diff suppressed because it is too large Load Diff

View File

@@ -1,87 +0,0 @@
#ifndef _BSDL_LOADER_H
#define _BSDL_LOADER_H
/*
* JTAG Core library
* Copyright (c) 2008 - 2024 Viveris Technologies
*
* JTAG Core library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* JTAG Core library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with JTAG Core library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file bsdl_loader.h
* @brief bsdl file parser header
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
*/
#include "jtag_core/jtag_core.h"
#define MAX_ELEMENT_SIZE (64+1)
typedef struct _pin_ctrl
{
char pinname[MAX_ELEMENT_SIZE];
int pintype;
char physical_pin[MAX_ELEMENT_SIZE];
int ctrl_bit_number;
int out_bit_number;
int in_bit_number;
}pin_ctrl;
typedef struct _jtag_chain
{
int bit_index;
int bit_cell_type; // BC_1,BC_2,...
char pinname[MAX_ELEMENT_SIZE]; // Pin name.
int bit_type; // None , ctrl , in, out.
int safe_state; // Default - Safe state. (0,1,-1)
int control_bit_index; // Indicate the associated control bit. -1 if no control bit.
int control_disable_state;
int control_disable_result;
}jtag_chain;
typedef struct _jtag_bsdl
{
unsigned long chip_id;
unsigned long chip_id_mask;
char src_filename[512];
char entity_name[512];
int number_of_chainbits;
jtag_chain * chain_list;
int number_of_pins;
pin_ctrl * pins_list;
int number_of_bits_per_instruction;
char IDCODE_Instruction[MAX_ELEMENT_SIZE];
char EXTEST_Instruction[MAX_ELEMENT_SIZE];
char BYPASS_Instruction[MAX_ELEMENT_SIZE];
char SAMPLE_Instruction[MAX_ELEMENT_SIZE];
}jtag_bsdl;
jtag_bsdl * load_bsdlfile(jtag_core * jc,char *filename);
void unload_bsdlfile(jtag_core * jc, jtag_bsdl * bsdl);
#endif

View File

@@ -1,93 +0,0 @@
/*
* JTAG Core library
* Copyright (c) 2008 - 2024 Viveris Technologies
*
* JTAG Core library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* JTAG Core library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with JTAG Core library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file bsdl_strings.c
* @brief bsdl file string keywords
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
*/
#include <string.h>
#include "jtag_core/jtag_core.h"
#include "bsdl_loader.h"
#include "bsdl_strings.h"
type_strings celltype_str[]=
{
{"BC_1",CELLTYPE_BC1},
{"BC_2",CELLTYPE_BC2},
{"BC_3",CELLTYPE_BC3},
{"BC_4",CELLTYPE_BC4},
{"BC_5",CELLTYPE_BC5},
{"BC_6",CELLTYPE_BC6},
{"BC_7",CELLTYPE_BC7},
{0,CELLTYPE_UNKNOWN}
};
type_strings bittype_str[]=
{
{"INPUT",BITTYPE_INPUT},
{"OBSERVE_ONLY",BITTYPE_INPUT},
{"OUTPUT",BITTYPE_OUTPUT},
{"OUTPUT2", BITTYPE_OUTPUT },
{"OUTPUT3",BITTYPE_TRISTATE_OUTPUT},
{"BIDIR",BITTYPE_INOUT},
{"CONTROL",BITTYPE_CONTROL},
{"CONTROLR",BITTYPE_CONTROL},
{"INTERNAL",BITTYPE_INTERNAL},
{0,BITTYPE_UNKNOWN}
};
type_strings statetype_str[]=
{
{"X",STATE_UNDEF},
{"1",STATE_HIGH},
{"0",STATE_LOW},
{"Z",STATE_HIGHZ},
{0,STATE_UNKNOWN}
};
type_strings pintype_str[]=
{
{"IN",IO_IN},
{"OUT",IO_OUT},
{"INOUT",IO_INOUT},
{"BUFFER", IO_OUT },
{0,IO_UNDEF}
};
int get_typecode(type_strings * typelist,char * name)
{
int i;
i = 0;
while( typelist[i].type_name )
{
if(!strcmp( typelist[i].type_name, name ) )
{
return typelist[i].type_code;
}
i++;
}
return typelist[i].type_code;
}

View File

@@ -1,81 +0,0 @@
#ifndef _BSDL_STRING_H
#define _BSDL_STRING_H
/*
* JTAG Core library
* Copyright (c) 2008 - 2024 Viveris Technologies
*
* JTAG Core library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* JTAG Core library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with JTAG Core library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file bsdl_strings.h
* @brief bsdl file string keywords header
* @author Jean-François DEL NERO <Jean-Francois.DELNERO@viveris.fr>
*/
typedef struct type_strings_
{
char * type_name;
int type_code;
}type_strings;
enum CELLTYPE
{
CELLTYPE_UNKNOWN = 0x00,
CELLTYPE_BC1,
CELLTYPE_BC2,
CELLTYPE_BC3,
CELLTYPE_BC4,
CELLTYPE_BC5,
CELLTYPE_BC6,
CELLTYPE_BC7
};
enum BITTYPE
{
BITTYPE_UNKNOWN = 0x00,
BITTYPE_INPUT,
BITTYPE_OUTPUT,
BITTYPE_TRISTATE_OUTPUT,
BITTYPE_INOUT,
BITTYPE_CONTROL,
BITTYPE_INTERNAL
};
enum STATETYPE
{
STATE_UNKNOWN = 0x00,
STATE_UNDEF,
STATE_HIGH,
STATE_LOW,
STATE_HIGHZ
};
enum PINIOTYPE
{
IO_UNDEF = 0x00,
IO_IN,
IO_OUT,
IO_INOUT
};
extern type_strings celltype_str[];
extern type_strings bittype_str[];
extern type_strings statetype_str[];
extern type_strings pintype_str[];
int get_typecode(type_strings * typelist,char * name);
#endif

View File

@@ -5,3 +5,4 @@ file(GLOB_RECURSE ALL_SOURCES "*.c")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_library(bus_over_jtag ${ALL_SOURCES}) add_library(bus_over_jtag ${ALL_SOURCES})
target_link_libraries(bus_over_jtag PUBLIC bsdl::bsdl)

View File

@@ -29,7 +29,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "drivers/drivers_list.h" #include "drivers/drivers_list.h"
@@ -41,7 +41,7 @@
int jtagcore_i2c_set_scl_pin(jtag_core * jc, int device, int pin) int jtagcore_i2c_set_scl_pin(jtag_core * jc, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -49,7 +49,7 @@ int jtagcore_i2c_set_scl_pin(jtag_core * jc, int device, int pin)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->i2c_scl_pin = pin; jc->i2c_scl_pin = pin;
jc->i2c_scl_device = device; jc->i2c_scl_device = device;
@@ -70,7 +70,7 @@ int jtagcore_i2c_set_scl_pin(jtag_core * jc, int device, int pin)
int jtagcore_i2c_set_sda_pin(jtag_core * jc, int device, int pin) int jtagcore_i2c_set_sda_pin(jtag_core * jc, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -78,7 +78,7 @@ int jtagcore_i2c_set_sda_pin(jtag_core * jc, int device, int pin)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->i2c_sda_pin = pin; jc->i2c_sda_pin = pin;
jc->i2c_sda_device = device; jc->i2c_sda_device = device;

View File

@@ -29,7 +29,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "drivers/drivers_list.h" #include "drivers/drivers_list.h"
@@ -39,7 +39,7 @@
int jtagcore_mdio_set_mdc_pin(jtag_core * jc, int device, int pin) int jtagcore_mdio_set_mdc_pin(jtag_core * jc, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -47,7 +47,7 @@ int jtagcore_mdio_set_mdc_pin(jtag_core * jc, int device, int pin)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->mdio_mdc_pin = pin; jc->mdio_mdc_pin = pin;
jc->mdio_mdc_device = device; jc->mdio_mdc_device = device;
@@ -61,7 +61,7 @@ int jtagcore_mdio_set_mdc_pin(jtag_core * jc, int device, int pin)
int jtagcore_mdio_set_mdio_pin(jtag_core * jc, int device, int pin) int jtagcore_mdio_set_mdio_pin(jtag_core * jc, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >=0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >=0)
{ {
@@ -69,7 +69,7 @@ int jtagcore_mdio_set_mdio_pin(jtag_core * jc, int device, int pin)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->mdio_mdio_pin = pin; jc->mdio_mdio_pin = pin;
jc->mdio_mdio_device = device; jc->mdio_mdio_device = device;

View File

@@ -29,7 +29,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "drivers/drivers_list.h" #include "drivers/drivers_list.h"
@@ -61,7 +61,7 @@ int jtagcore_memory_clear_pins(jtag_core * jc)
int jtagcore_memory_set_address_pin(jtag_core * jc, int address_bit, int device, int pin) int jtagcore_memory_set_address_pin(jtag_core * jc, int address_bit, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && address_bit < MAX_BUS_WIDTH) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && address_bit < MAX_BUS_WIDTH)
{ {
@@ -69,7 +69,7 @@ int jtagcore_memory_set_address_pin(jtag_core * jc, int address_bit, int device,
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if ( pin < bsdl_file->number_of_pins && pin >= 0 ) if ( pin < (int)bsdl_file->pin_count && pin >= 0 )
{ {
jc->ram_address_pin[address_bit] = pin; jc->ram_address_pin[address_bit] = pin;
jc->ram_address_device[address_bit] = device; jc->ram_address_device[address_bit] = device;
@@ -83,7 +83,7 @@ int jtagcore_memory_set_address_pin(jtag_core * jc, int address_bit, int device,
int jtagcore_memory_set_data_pin(jtag_core * jc, int data_bit, int device, int pin) int jtagcore_memory_set_data_pin(jtag_core * jc, int data_bit, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && data_bit < MAX_BUS_WIDTH) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && data_bit < MAX_BUS_WIDTH)
{ {
@@ -91,7 +91,7 @@ int jtagcore_memory_set_data_pin(jtag_core * jc, int data_bit, int device, int p
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if ( pin < bsdl_file->number_of_pins && pin >= 0 ) if ( pin < (int)bsdl_file->pin_count && pin >= 0 )
{ {
jc->ram_data_pin[data_bit] = pin; jc->ram_data_pin[data_bit] = pin;
jc->ram_data_device[data_bit] = device; jc->ram_data_device[data_bit] = device;
@@ -105,7 +105,7 @@ int jtagcore_memory_set_data_pin(jtag_core * jc, int data_bit, int device, int p
int jtagcore_memory_set_ctrl_pin(jtag_core * jc, int ctrl, int polarity, int device, int pin) int jtagcore_memory_set_ctrl_pin(jtag_core * jc, int ctrl, int polarity, int device, int pin)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && ctrl < 16) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && ctrl < 16)
{ {
@@ -113,7 +113,7 @@ int jtagcore_memory_set_ctrl_pin(jtag_core * jc, int ctrl, int polarity, int dev
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if ( pin < bsdl_file->number_of_pins && pin >= 0 ) if ( pin < (int)bsdl_file->pin_count && pin >= 0 )
{ {
jc->ram_ctrl_pin[ctrl] = pin; jc->ram_ctrl_pin[ctrl] = pin;
jc->ram_ctrl_pin_pol[ctrl] = polarity; jc->ram_ctrl_pin_pol[ctrl] = polarity;

View File

@@ -29,7 +29,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "drivers/drivers_list.h" #include "drivers/drivers_list.h"
@@ -39,7 +39,7 @@
int jtagcore_spi_set_mosi_pin(jtag_core * jc, int device, int pin, int sample_clk_phase) int jtagcore_spi_set_mosi_pin(jtag_core * jc, int device, int pin, int sample_clk_phase)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -47,7 +47,7 @@ int jtagcore_spi_set_mosi_pin(jtag_core * jc, int device, int pin, int sample_cl
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->spi_mosi_pin = pin; jc->spi_mosi_pin = pin;
if(sample_clk_phase) if(sample_clk_phase)
@@ -65,7 +65,7 @@ int jtagcore_spi_set_mosi_pin(jtag_core * jc, int device, int pin, int sample_cl
int jtagcore_spi_set_miso_pin(jtag_core * jc, int device, int pin, int sample_clk_phase) int jtagcore_spi_set_miso_pin(jtag_core * jc, int device, int pin, int sample_clk_phase)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -73,7 +73,7 @@ int jtagcore_spi_set_miso_pin(jtag_core * jc, int device, int pin, int sample_cl
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->spi_miso_pin = pin; jc->spi_miso_pin = pin;
if(sample_clk_phase) if(sample_clk_phase)
@@ -91,7 +91,7 @@ int jtagcore_spi_set_miso_pin(jtag_core * jc, int device, int pin, int sample_cl
int jtagcore_spi_set_clk_pin(jtag_core * jc, int device, int pin, int polarity) int jtagcore_spi_set_clk_pin(jtag_core * jc, int device, int pin, int polarity)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -99,7 +99,7 @@ int jtagcore_spi_set_clk_pin(jtag_core * jc, int device, int pin, int polarity)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->spi_clk_pin = pin; jc->spi_clk_pin = pin;
if(polarity) if(polarity)
@@ -117,7 +117,7 @@ int jtagcore_spi_set_clk_pin(jtag_core * jc, int device, int pin, int polarity)
int jtagcore_spi_set_cs_pin(jtag_core * jc, int device, int pin, int polarity) int jtagcore_spi_set_cs_pin(jtag_core * jc, int device, int pin, int polarity)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0)
{ {
@@ -125,7 +125,7 @@ int jtagcore_spi_set_cs_pin(jtag_core * jc, int device, int pin, int polarity)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins && pin >= 0) if (pin < (int)bsdl_file->pin_count && pin >= 0)
{ {
jc->spi_cs_pin = pin; jc->spi_cs_pin = pin;
if(polarity) if(polarity)

View File

@@ -20,7 +20,7 @@ add_library(drivers ${MAIN_SOURCES} ${FTDI_SOURCES} ${GPIO_SOURCES} ${JLINK_SOUR
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBFTDI REQUIRED IMPORTED_TARGET libftdi1) pkg_check_modules(LIBFTDI REQUIRED IMPORTED_TARGET libftdi1)
pkg_check_modules(LIBUSB REQUIRED IMPORTED_TARGET libusb-1.0) pkg_check_modules(LIBUSB REQUIRED IMPORTED_TARGET libusb-1.0)
target_link_libraries(drivers PUBLIC PkgConfig::LIBFTDI PkgConfig::LIBUSB) target_link_libraries(drivers PUBLIC PkgConfig::LIBFTDI PkgConfig::LIBUSB bsdl::bsdl)
if(BS_ENABLE_DIGILENT) if(BS_ENABLE_DIGILENT)
target_link_libraries(drivers PUBLIC ${CMAKE_DL_LIBS}) target_link_libraries(drivers PUBLIC ${CMAKE_DL_LIBS})

View File

@@ -25,7 +25,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#ifdef WIN32 #ifdef WIN32
#include "./lpt_jtag/lpt_jtag_drv.h" #include "./lpt_jtag/lpt_jtag_drv.h"

View File

@@ -28,7 +28,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "drivers_list.h" #include "drivers_list.h"

View File

@@ -21,3 +21,4 @@ include_directories(${DIR_MODULES})
add_library(jtag_core ${ALL_SOURCES}) add_library(jtag_core ${ALL_SOURCES})
add_dependencies(jtag_core prebuild) add_dependencies(jtag_core prebuild)
target_link_libraries(jtag_core PUBLIC bsdl::bsdl)

View File

@@ -32,13 +32,27 @@
#include "script/env.h" #include "script/env.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "bsdl_parser/bsdl_strings.h"
#include "drivers/drivers_list.h" #include "drivers/drivers_list.h"
/* #include "config_script.h" */ /* #include "config_script.h" */
/* Look up an INSTRUCTION_OPCODE by name. Returns the bit-string (e.g.
* "00000000001") or NULL if absent. */
static const char * jc_bsdl_opcode(const bsdl_t * b, const char * name)
{
size_t i;
if (!b)
return NULL;
for (i = 0; i < b->instruction_count; i++)
{
if (b->instructions[i].name && !strcmp(b->instructions[i].name, name))
return b->instructions[i].opcode;
}
return NULL;
}
jtag_core * jtagcore_init() jtag_core * jtagcore_init()
{ {
jtag_core * jc; jtag_core * jc;
@@ -86,7 +100,7 @@ int jtagcore_scan_and_init_chain(jtag_core * jc)
{ {
if (jc->devices_list[i].bsdl) if (jc->devices_list[i].bsdl)
{ {
unload_bsdlfile(jc,jc->devices_list[i].bsdl); bsdl_free(jc->devices_list[i].bsdl);
jc->devices_list[i].bsdl = 0; jc->devices_list[i].bsdl = 0;
} }
} }
@@ -272,12 +286,12 @@ unsigned long jtagcore_get_dev_id(jtag_core * jc,int device)
int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device) int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
int i; int i;
if ( (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) || device == -1) if ( (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0) || device == -1)
{ {
bsdl_file = load_bsdlfile(jc,path); bsdl_file = bsdl_parse_file(path, NULL);
if (bsdl_file) if (bsdl_file)
{ {
if (device == -1) if (device == -1)
@@ -288,7 +302,7 @@ int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device)
{ {
if (jc->devices_list[i].bsdl) if (jc->devices_list[i].bsdl)
{ {
unload_bsdlfile(jc,jc->devices_list[i].bsdl); bsdl_free(jc->devices_list[i].bsdl);
jc->devices_list[i].bsdl = 0; jc->devices_list[i].bsdl = 0;
} }
@@ -304,7 +318,7 @@ int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device)
{ {
if (jc->devices_list[device].bsdl) if (jc->devices_list[device].bsdl)
{ {
unload_bsdlfile(jc,jc->devices_list[device].bsdl); bsdl_free(jc->devices_list[device].bsdl);
} }
jc->devices_list[device].bsdl = bsdl_file; jc->devices_list[device].bsdl = bsdl_file;
@@ -316,20 +330,21 @@ int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device)
if (jc->devices_list[device].out_boundary_scan) if (jc->devices_list[device].out_boundary_scan)
free(jc->devices_list[device].out_boundary_scan); free(jc->devices_list[device].out_boundary_scan);
jc->devices_list[device].in_boundary_scan = malloc(bsdl_file->number_of_chainbits); jc->devices_list[device].in_boundary_scan = malloc(bsdl_file->chain_count);
if (jc->devices_list[device].in_boundary_scan) if (jc->devices_list[device].in_boundary_scan)
memset(jc->devices_list[device].in_boundary_scan, 0, bsdl_file->number_of_chainbits); memset(jc->devices_list[device].in_boundary_scan, 0, bsdl_file->chain_count);
jc->devices_list[device].out_boundary_scan = malloc(bsdl_file->number_of_chainbits); jc->devices_list[device].out_boundary_scan = malloc(bsdl_file->chain_count);
if (jc->devices_list[device].out_boundary_scan) if (jc->devices_list[device].out_boundary_scan)
{ {
memset(jc->devices_list[device].out_boundary_scan, 0, bsdl_file->number_of_chainbits); size_t bi;
for (i = 0; i < bsdl_file->number_of_chainbits; i++) memset(jc->devices_list[device].out_boundary_scan, 0, bsdl_file->chain_count);
for (bi = 0; bi < bsdl_file->chain_count; bi++)
{ {
if(bsdl_file->chain_list[i].safe_state == STATE_HIGH) if(bsdl_file->chain[bi].safe == BSDL_STATE_HIGH)
jc->devices_list[device].out_boundary_scan[i] = 0x01; jc->devices_list[device].out_boundary_scan[bi] = 0x01;
else else
jc->devices_list[device].out_boundary_scan[i] = 0x00; jc->devices_list[device].out_boundary_scan[bi] = 0x00;
} }
@@ -346,18 +361,18 @@ int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device)
unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path, unsigned long * mask) unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path, unsigned long * mask)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
unsigned long chip_id; unsigned long chip_id;
bsdl_file = load_bsdlfile(jc,path); bsdl_file = bsdl_parse_file(path, NULL);
if (bsdl_file) if (bsdl_file)
{ {
chip_id = bsdl_file->chip_id; chip_id = bsdl_file->idcode;
if( mask ) if( mask )
{ {
*mask = bsdl_file->chip_id_mask; *mask = bsdl_file->idcode_mask;
} }
unload_bsdlfile(jc,bsdl_file); bsdl_free(bsdl_file);
return chip_id; return chip_id;
} }
@@ -366,7 +381,7 @@ unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path, unsigned long *
int jtagcore_get_dev_name(jtag_core * jc, int device, char * devname, char * bsdlpath) int jtagcore_get_dev_name(jtag_core * jc, int device, char * devname, char * bsdlpath)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if ( device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 ) if ( device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 )
{ {
@@ -376,7 +391,7 @@ int jtagcore_get_dev_name(jtag_core * jc, int device, char * devname, char * bsd
if(devname) if(devname)
{ {
strcpy(devname,bsdl_file->entity_name); strcpy(devname,bsdl_file->entity);
} }
if(bsdlpath) if(bsdlpath)
@@ -405,7 +420,7 @@ int jtagcore_get_dev_name(jtag_core * jc, int device, char * devname, char * bsd
int jtagcore_get_number_of_pins(jtag_core * jc, int device) int jtagcore_get_number_of_pins(jtag_core * jc, int device)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
if ( device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 ) if ( device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 )
{ {
@@ -413,7 +428,7 @@ int jtagcore_get_number_of_pins(jtag_core * jc, int device)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
return bsdl_file->number_of_pins; return (int)bsdl_file->pin_count;
} }
} }
@@ -422,7 +437,7 @@ int jtagcore_get_number_of_pins(jtag_core * jc, int device)
int jtagcore_get_pin_properties(jtag_core * jc, int device,int pin,char * pinname,int maxsize,int * type) int jtagcore_get_pin_properties(jtag_core * jc, int device,int pin,char * pinname,int maxsize,int * type)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
int type_code; int type_code;
if (device >= jc->nb_of_devices_in_chain || if (device >= jc->nb_of_devices_in_chain ||
@@ -437,25 +452,25 @@ int jtagcore_get_pin_properties(jtag_core * jc, int device,int pin,char * pinnam
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins ) if (pin < (int)bsdl_file->pin_count )
{ {
type_code = 0x00; type_code = 0x00;
if (pinname) if (pinname)
{ {
strncpy(pinname, bsdl_file->pins_list[pin].pinname, maxsize - 1); strncpy(pinname, bsdl_file->pins[pin].name, maxsize - 1);
pinname[maxsize - 1] = '\0'; pinname[maxsize - 1] = '\0';
} }
if (type) if (type)
{ {
if (bsdl_file->pins_list[pin].ctrl_bit_number != -1) if (bsdl_file->pins[pin].ctrl_bit != -1)
type_code |= JTAG_CORE_PIN_IS_TRISTATES; type_code |= JTAG_CORE_PIN_IS_TRISTATES;
if (bsdl_file->pins_list[pin].out_bit_number != -1) if (bsdl_file->pins[pin].out_bit != -1)
type_code |= JTAG_CORE_PIN_IS_OUTPUT; type_code |= JTAG_CORE_PIN_IS_OUTPUT;
if (bsdl_file->pins_list[pin].in_bit_number != -1) if (bsdl_file->pins[pin].in_bit != -1)
type_code |= JTAG_CORE_PIN_IS_INPUT; type_code |= JTAG_CORE_PIN_IS_INPUT;
*type = type_code; *type = type_code;
@@ -470,7 +485,7 @@ int jtagcore_get_pin_properties(jtag_core * jc, int device,int pin,char * pinnam
int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type) int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
int bit_number, ret; int bit_number, ret;
int disable_state; int disable_state;
@@ -481,12 +496,12 @@ int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins) if (pin < (int)bsdl_file->pin_count)
{ {
switch (type) switch (type)
{ {
case JTAG_CORE_OUTPUT: case JTAG_CORE_OUTPUT:
bit_number = bsdl_file->pins_list[pin].out_bit_number; bit_number = bsdl_file->pins[pin].out_bit;
if (bit_number != -1) if (bit_number != -1)
{ {
@@ -509,14 +524,14 @@ int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type)
break; break;
case JTAG_CORE_OE: case JTAG_CORE_OE:
bit_number = bsdl_file->pins_list[pin].ctrl_bit_number; bit_number = bsdl_file->pins[pin].ctrl_bit;
if (bit_number != -1) if (bit_number != -1)
{ {
disable_state = bsdl_file->chain_list[bsdl_file->pins_list[pin].out_bit_number].control_disable_state; disable_state = bsdl_file->chain[bsdl_file->pins[pin].out_bit].disable_state;
if (jc->devices_list[device].scan_mode == JTAG_CORE_EXTEST_SCANMODE) if (jc->devices_list[device].scan_mode == JTAG_CORE_EXTEST_SCANMODE)
{ {
if (disable_state == STATE_HIGH) if (disable_state == BSDL_STATE_HIGH)
{ {
if (jc->devices_list[device].out_boundary_scan[bit_number]) if (jc->devices_list[device].out_boundary_scan[bit_number])
ret = 0x00; ret = 0x00;
@@ -552,7 +567,7 @@ int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type)
break; break;
case JTAG_CORE_INPUT: case JTAG_CORE_INPUT:
bit_number = bsdl_file->pins_list[pin].in_bit_number; bit_number = bsdl_file->pins[pin].in_bit;
if (bit_number != -1) if (bit_number != -1)
{ {
@@ -572,7 +587,7 @@ int jtagcore_get_pin_state(jtag_core * jc, int device, int pin, int type)
int jtagcore_set_pin_state(jtag_core * jc, int device, int pin, int type,int state) int jtagcore_set_pin_state(jtag_core * jc, int device, int pin, int type,int state)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
int bit_number,ret; int bit_number,ret;
int disable_state; int disable_state;
@@ -584,12 +599,12 @@ int jtagcore_set_pin_state(jtag_core * jc, int device, int pin, int type,int sta
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
if (pin < bsdl_file->number_of_pins) if (pin < (int)bsdl_file->pin_count)
{ {
switch (type) switch (type)
{ {
case JTAG_CORE_OUTPUT: case JTAG_CORE_OUTPUT:
bit_number = bsdl_file->pins_list[pin].out_bit_number; bit_number = bsdl_file->pins[pin].out_bit;
if (bit_number != -1) if (bit_number != -1)
{ {
@@ -604,13 +619,13 @@ int jtagcore_set_pin_state(jtag_core * jc, int device, int pin, int type,int sta
break; break;
case JTAG_CORE_OE: case JTAG_CORE_OE:
bit_number = bsdl_file->pins_list[pin].ctrl_bit_number; bit_number = bsdl_file->pins[pin].ctrl_bit;
if (bit_number != -1) if (bit_number != -1)
{ {
disable_state = bsdl_file->chain_list[bsdl_file->pins_list[pin].out_bit_number].control_disable_state; disable_state = bsdl_file->chain[bsdl_file->pins[pin].out_bit].disable_state;
if (disable_state == STATE_HIGH) if (disable_state == BSDL_STATE_HIGH)
{ {
if (state) if (state)
jc->devices_list[device].out_boundary_scan[bit_number] = 0x00; jc->devices_list[device].out_boundary_scan[bit_number] = 0x00;
@@ -638,7 +653,7 @@ int jtagcore_set_pin_state(jtag_core * jc, int device, int pin, int type,int sta
int jtagcore_get_pin_id(jtag_core * jc, int device, char * pinname) int jtagcore_get_pin_id(jtag_core * jc, int device, char * pinname)
{ {
jtag_bsdl * bsdl_file; bsdl_t * bsdl_file;
int pin; int pin;
if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && pinname) if (device < jc->nb_of_devices_in_chain && device < MAX_NB_JTAG_DEVICE && device >= 0 && pinname)
@@ -647,11 +662,11 @@ int jtagcore_get_pin_id(jtag_core * jc, int device, char * pinname)
{ {
bsdl_file = jc->devices_list[device].bsdl; bsdl_file = jc->devices_list[device].bsdl;
for ( pin = 0; pin < bsdl_file->number_of_pins; pin++) for ( pin = 0; pin < (int)bsdl_file->pin_count; pin++)
{ {
if(bsdl_file->pins_list[pin].pinname) if(bsdl_file->pins[pin].name)
{ {
if(!strcmp(bsdl_file->pins_list[pin].pinname, pinname)) if(!strcmp(bsdl_file->pins[pin].name, pinname))
{ {
return pin; return pin;
} }
@@ -702,7 +717,7 @@ int jtagcore_push_and_pop_chain(jtag_core * jc, int mode)
unsigned char buf_in[512]; unsigned char buf_in[512];
int d,i,irlen; int d,i,irlen;
int bit,first_bit,jtag_chain_check_needed; int bit,first_bit,jtag_chain_check_needed;
jtag_bsdl * bsdl; bsdl_t * bsdl;
jtag_chain_check_needed = 0; jtag_chain_check_needed = 0;
@@ -725,26 +740,26 @@ int jtagcore_push_and_pop_chain(jtag_core * jc, int mode)
{ {
if (d == (jc->nb_of_devices_in_chain - 1)) // Last device in chain ? if (d == (jc->nb_of_devices_in_chain - 1)) // Last device in chain ?
{ {
jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, jc->devices_list[d].in_boundary_scan, bsdl->number_of_chainbits - 1); jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, jc->devices_list[d].in_boundary_scan, (int)bsdl->chain_count - 1);
buf_out[0] = jc->devices_list[d].out_boundary_scan[bsdl->number_of_chainbits - 1] | JTAG_STR_TMS; buf_out[0] = jc->devices_list[d].out_boundary_scan[(int)bsdl->chain_count - 1] | JTAG_STR_TMS;
jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, &jc->devices_list[d].in_boundary_scan[bsdl->number_of_chainbits - 1], 1); jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, &jc->devices_list[d].in_boundary_scan[(int)bsdl->chain_count - 1], 1);
} }
else else
{ {
jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, jc->devices_list[d].in_boundary_scan, bsdl->number_of_chainbits); jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, jc->devices_list[d].in_boundary_scan, (int)bsdl->chain_count);
} }
// Check the incomming data // Check the incomming data
if(bsdl->number_of_chainbits) if((int)bsdl->chain_count)
{ {
first_bit = jc->devices_list[d].in_boundary_scan[0]; first_bit = jc->devices_list[d].in_boundary_scan[0];
bit = 0; bit = 0;
while( (bit < bsdl->number_of_chainbits) && (first_bit == jc->devices_list[d].in_boundary_scan[bit]) ) while( (bit < (int)bsdl->chain_count) && (first_bit == jc->devices_list[d].in_boundary_scan[bit]) )
{ {
bit++; bit++;
} }
if( bit == bsdl->number_of_chainbits) if( bit == (int)bsdl->chain_count)
{ {
// All bits have the same value. // All bits have the same value.
// Program a jtag chain check // Program a jtag chain check
@@ -758,13 +773,13 @@ int jtagcore_push_and_pop_chain(jtag_core * jc, int mode)
// Write only mode - Ignore incoming chain. // Write only mode - Ignore incoming chain.
if (d == (jc->nb_of_devices_in_chain - 1)) // Last device in chain ? if (d == (jc->nb_of_devices_in_chain - 1)) // Last device in chain ?
{ {
jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, 0, bsdl->number_of_chainbits - 1); jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, 0, (int)bsdl->chain_count - 1);
buf_out[0] = jc->devices_list[d].out_boundary_scan[bsdl->number_of_chainbits - 1] | JTAG_STR_TMS; buf_out[0] = jc->devices_list[d].out_boundary_scan[(int)bsdl->chain_count - 1] | JTAG_STR_TMS;
jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, 1); jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, 1);
} }
else else
{ {
jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, 0, bsdl->number_of_chainbits); jc->io_functions.drv_TXRX_DATA(jc, jc->devices_list[d].out_boundary_scan, 0, (int)bsdl->chain_count);
} }
} }
@@ -878,32 +893,36 @@ int jtagcore_push_and_pop_chain(jtag_core * jc, int mode)
bsdl = jc->devices_list[d].bsdl; bsdl = jc->devices_list[d].bsdl;
if ( bsdl ) if ( bsdl )
{ {
switch ( jc->devices_list[d].scan_mode )
{ {
case JTAG_CORE_SAMPLE_SCANMODE: const char *opcode = NULL;
for (i = 0; i < bsdl->number_of_bits_per_instruction; i++) switch ( jc->devices_list[d].scan_mode )
{
case JTAG_CORE_SAMPLE_SCANMODE:
opcode = jc_bsdl_opcode(bsdl, "SAMPLE");
break;
case JTAG_CORE_EXTEST_SCANMODE:
opcode = jc_bsdl_opcode(bsdl, "EXTEST");
break;
}
if (opcode)
{
for (i = 0; i < bsdl->instruction_length; i++)
{ {
buf_out[(bsdl->number_of_bits_per_instruction - 1) - i] = bsdl->SAMPLE_Instruction[i] - '0'; buf_out[(bsdl->instruction_length - 1) - i] = opcode[i] - '0';
} }
break; }
case JTAG_CORE_EXTEST_SCANMODE:
for (i = 0; i < bsdl->number_of_bits_per_instruction; i++)
{
buf_out[(bsdl->number_of_bits_per_instruction - 1) - i] = bsdl->EXTEST_Instruction[i] - '0';
}
break;
} }
if (d == (jc->nb_of_devices_in_chain - 1)) // Last device in chain ? if (d == (jc->nb_of_devices_in_chain - 1)) // Last device in chain ?
{ {
jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, bsdl->number_of_bits_per_instruction - 1); jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, bsdl->instruction_length - 1);
buf_out[0] = buf_out[bsdl->number_of_bits_per_instruction - 1] | JTAG_STR_TMS; buf_out[0] = buf_out[bsdl->instruction_length - 1] | JTAG_STR_TMS;
jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, 1); jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, 1);
} }
else else
{ {
jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, bsdl->number_of_bits_per_instruction); jc->io_functions.drv_TXRX_DATA(jc, (unsigned char *)&buf_out, 0, bsdl->instruction_length);
} }
} }
else else
@@ -921,7 +940,7 @@ int jtagcore_push_and_pop_chain(jtag_core * jc, int mode)
if ( jc->devices_list[0].bsdl ) if ( jc->devices_list[0].bsdl )
{ {
bsdl = jc->devices_list[0].bsdl; bsdl = jc->devices_list[0].bsdl;
irlen = jc->total_IR_lenght - bsdl->number_of_bits_per_instruction; irlen = jc->total_IR_lenght - bsdl->instruction_length;
} }
} }
else else
@@ -929,7 +948,7 @@ int jtagcore_push_and_pop_chain(jtag_core * jc, int mode)
if ( jc->devices_list[1].bsdl ) if ( jc->devices_list[1].bsdl )
{ {
bsdl = jc->devices_list[1].bsdl; bsdl = jc->devices_list[1].bsdl;
irlen = jc->total_IR_lenght - bsdl->number_of_bits_per_instruction; irlen = jc->total_IR_lenght - bsdl->instruction_length;
} }
} }
break; break;

View File

@@ -6,3 +6,4 @@ include_directories(${DIR_MODULES})
include_directories(${DIR_LIBS}) include_directories(${DIR_LIBS})
add_library(script ${ALL_SOURCES}) add_library(script ${ALL_SOURCES})
target_link_libraries(script PUBLIC bsdl::bsdl)

View File

@@ -35,7 +35,7 @@
#include "jtag_core/jtag_core.h" #include "jtag_core/jtag_core.h"
#include "config/version.h" #include "config/version.h"
#include "bsdl_parser/bsdl_loader.h" #include <bsdl/bsdl.h>
#include "os_interface/os_interface.h" #include "os_interface/os_interface.h"
#include "target/target.h" #include "target/target.h"
#include "probes/probes.h" #include "probes/probes.h"