Merge pull request #406 from markfeathers/add-user-device-list
Add user device list for non-fpga JTAG devices
This commit is contained in:
commit
1306c79bdc
11
src/jtag.cpp
11
src/jtag.cpp
|
|
@ -77,11 +77,13 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
|||
const string &dev,
|
||||
const string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const string &ip_adr, int port,
|
||||
const bool invert_read_edge, const string &firmware_path):
|
||||
const bool invert_read_edge, const string &firmware_path,
|
||||
const std::map<uint32_t, misc_device> &user_misc_devs):
|
||||
_verbose(verbose > 1),
|
||||
_state(RUN_TEST_IDLE),
|
||||
_tms_buffer_size(128), _num_tms(0),
|
||||
_board_name("nope"), device_index(0), _curr_tdi(1)
|
||||
_board_name("nope"), device_index(0), _curr_tdi(1),
|
||||
_user_misc_devs(user_misc_devs)
|
||||
{
|
||||
switch (cable.type) {
|
||||
case MODE_ANLOGICCABLE:
|
||||
|
|
@ -246,6 +248,11 @@ bool Jtag::search_and_insert_device_with_idcode(uint32_t idcode)
|
|||
if (misc != misc_dev_list.end())
|
||||
irlength = misc->second.irlength;
|
||||
}
|
||||
if (irlength == -1) {
|
||||
auto misc = this->_user_misc_devs.find(idcode);
|
||||
if (misc != this->_user_misc_devs.end())
|
||||
irlength = misc->second.irlength;
|
||||
}
|
||||
if (irlength == -1)
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "board.hpp"
|
||||
#include "cable.hpp"
|
||||
#include "part.hpp"
|
||||
#include "jtagInterface.hpp"
|
||||
|
||||
class Jtag {
|
||||
|
|
@ -21,7 +22,8 @@ class Jtag {
|
|||
const std::string &serial, uint32_t clkHZ, int8_t verbose,
|
||||
const std::string &ip_adr, int port,
|
||||
const bool invert_read_edge = false,
|
||||
const std::string &firmware_path = "");
|
||||
const std::string &firmware_path = "",
|
||||
const std::map<uint32_t, misc_device> &user_misc_devs = {});
|
||||
~Jtag();
|
||||
|
||||
/* maybe to update */
|
||||
|
|
@ -146,6 +148,7 @@ class Jtag {
|
|||
int _num_tms;
|
||||
unsigned char *_tms_buffer;
|
||||
std::string _board_name;
|
||||
const std::map<uint32_t, misc_device>& _user_misc_devs;
|
||||
|
||||
int device_index; /*!< index for targeted FPGA */
|
||||
|
||||
|
|
|
|||
39
src/main.cpp
39
src/main.cpp
|
|
@ -91,6 +91,7 @@ struct arguments {
|
|||
string interface;
|
||||
string mcufw;
|
||||
bool conmcu;
|
||||
std::map<uint32_t, misc_device> user_misc_devs;
|
||||
};
|
||||
|
||||
int run_xvc_server(const struct arguments &args, const cable_t &cable,
|
||||
|
|
@ -119,7 +120,7 @@ int main(int argc, char **argv)
|
|||
"127.0.0.1", 0, false, false, "", false, false,
|
||||
/* xvc server */
|
||||
false, 3721, "-",
|
||||
"", false, // mcufw conmcu
|
||||
"", false, {} // mcufw conmcu, user_misc_dev_list
|
||||
};
|
||||
/* parse arguments */
|
||||
try {
|
||||
|
|
@ -446,7 +447,8 @@ int main(int argc, char **argv)
|
|||
try {
|
||||
jtag = new Jtag(cable, &pins_config, args.device, args.ftdi_serial,
|
||||
args.freq, args.verbose, args.ip_adr, args.port,
|
||||
args.invert_read_edge, args.probe_firmware);
|
||||
args.invert_read_edge, args.probe_firmware,
|
||||
args.user_misc_devs);
|
||||
} catch (std::exception &e) {
|
||||
printError("JTAG init failed with: " + string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
|
|
@ -479,6 +481,11 @@ int main(int argc, char **argv)
|
|||
t,
|
||||
misc_dev_list[t].name.c_str(),
|
||||
misc_dev_list[t].irlength);
|
||||
} else if (args.user_misc_devs.find(t) != args.user_misc_devs.end()) {
|
||||
printf("\tidcode 0x%x\n\ttype %s\n\tirlength %d\n",
|
||||
t,
|
||||
args.user_misc_devs[t].name.c_str(),
|
||||
args.user_misc_devs[t].irlength);
|
||||
}
|
||||
}
|
||||
if (args.detect == true) {
|
||||
|
|
@ -765,6 +772,8 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
"write bitstream in flash (default: false)")
|
||||
("index-chain", "device index in JTAG-chain",
|
||||
cxxopts::value<int>(args->index_chain))
|
||||
("misc-device", "add JTAG non-FPGA devices <idcode,irlen,name>",
|
||||
cxxopts::value<vector<string>>())
|
||||
("ip", "IP address (XVC and remote bitbang client)",
|
||||
cxxopts::value<string>(args->ip_adr))
|
||||
("list-boards", "list all supported boards",
|
||||
|
|
@ -846,6 +855,32 @@ int parse_opt(int argc, char **argv, struct arguments *args,
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (result.count("misc-device")) {
|
||||
auto misc_devices = result["misc-device"].as<std::vector<std::string>>();
|
||||
for (auto &dev : misc_devices) {
|
||||
uint32_t idcode;
|
||||
int irlen;
|
||||
std:string name;
|
||||
std::stringstream ss(dev);
|
||||
std::string item;
|
||||
std::vector<std::string> tokens;
|
||||
|
||||
while (std::getline(ss, item, ',')) {
|
||||
tokens.push_back(item);
|
||||
}
|
||||
|
||||
if (tokens.size() != 3) {
|
||||
printError("Error: invalid format for misc-device.");
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
idcode = std::stoul(tokens[0], nullptr, 16);
|
||||
irlen = std::stoi(tokens[1]);
|
||||
name = tokens[2];
|
||||
args->user_misc_devs[idcode] = {name, irlen};
|
||||
}
|
||||
}
|
||||
|
||||
if (result.count("write-flash") && result.count("write-sram") &&
|
||||
result.count("dump-flash")) {
|
||||
printError("Error: both write to flash and write to ram enabled");
|
||||
|
|
|
|||
Loading…
Reference in New Issue