main: add optional probe-firmware

This commit is contained in:
Gwenhael Goavec-Merou 2021-05-13 16:07:40 +02:00
parent 167d430c34
commit 42b7279a4b
3 changed files with 18 additions and 8 deletions

View File

@ -67,13 +67,14 @@ using namespace std;
*/
Jtag::Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf, string dev,
const string &serial, uint32_t clkHZ, bool verbose):
const string &serial, uint32_t clkHZ, bool verbose,
const string &firmware_path):
_verbose(verbose),
_state(RUN_TEST_IDLE),
_tms_buffer_size(128), _num_tms(0),
_board_name("nope")
{
init_internal(cable, dev, serial, pin_conf, clkHZ);
init_internal(cable, dev, serial, pin_conf, clkHZ, firmware_path);
}
Jtag::~Jtag()
@ -83,7 +84,7 @@ Jtag::~Jtag()
}
void Jtag::init_internal(cable_t &cable, const string &dev, const string &serial,
const jtag_pins_conf_t *pin_conf, uint32_t clkHZ)
const jtag_pins_conf_t *pin_conf, uint32_t clkHZ, const string &firmware_path)
{
switch (cable.type) {
case MODE_ANLOGICCABLE:
@ -101,7 +102,8 @@ void Jtag::init_internal(cable_t &cable, const string &dev, const string &serial
_jtag = new DirtyJtag(clkHZ, _verbose);
break;
case MODE_USBBLASTER:
_jtag = new UsbBlaster(_verbose);
_jtag = new UsbBlaster(cable.config.vid, cable.config.pid,
firmware_path, _verbose);
break;
default:
std::cerr << "Jtag: unknown cable type" << std::endl;

View File

@ -30,7 +30,8 @@
class Jtag {
public:
Jtag(cable_t &cable, const jtag_pins_conf_t *pin_conf, std::string dev,
const std::string &serial, uint32_t clkHZ, bool verbose = false);
const std::string &serial, uint32_t clkHZ, bool verbose = false,
const std::string &firmware_path="");
~Jtag();
/* maybe to update */
@ -79,7 +80,8 @@ class Jtag {
private:
void init_internal(cable_t &cable, const std::string &dev, const std::string &serial,
const jtag_pins_conf_t *pin_conf, uint32_t clkHZ);
const jtag_pins_conf_t *pin_conf, uint32_t clkHZ,
const std::string &firmware_path);
bool _verbose;
int _state;
int _tms_buffer_size;

View File

@ -63,6 +63,7 @@ struct arguments {
bool spi;
string file_type;
string fpga_part;
string probe_firmware;
};
int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *pins_config);
@ -78,7 +79,7 @@ int main(int argc, char **argv)
/* command line args. */
struct arguments args = {0, false, false, 0, "", "", "-", "", -1, 6000000, "-",
false, false, false, false, Device::WR_SRAM, false, false, "",
""};
"", ""};
/* parse arguments */
try {
if (parse_opt(argc, argv, &args, &pins_config))
@ -230,7 +231,8 @@ int main(int argc, char **argv)
/* jtag base */
Jtag *jtag;
try {
jtag = new Jtag(cable, &pins_config, args.device, args.ftdi_serial, args.freq, false);
jtag = new Jtag(cable, &pins_config, args.device, args.ftdi_serial,
args.freq, false, args.probe_firmware);
} catch (std::exception &e) {
printError("Error: Failed to claim cable");
return EXIT_FAILURE;
@ -244,6 +246,8 @@ int main(int argc, char **argv)
cout << "found " << std::to_string(found) << " devices" << endl;
if (found > 1) {
printError("Error: currently only one device is supported");
for (int i = 0; i < found; i++)
printf("0x%08x\n", listDev[i]);
delete(jtag);
return EXIT_FAILURE;
} else if (found < 1) {
@ -394,6 +398,8 @@ int parse_opt(int argc, char **argv, struct arguments *args, jtag_pins_conf_t *p
cxxopts::value<unsigned int>(args->offset))
("pins", "pin config (only for ft232R) TDI:TDO:TCK:TMS",
cxxopts::value<vector<string>>(pins))
("probe-firmware", "firmware for JTAG probe (usbBlasterII)",
cxxopts::value<string>(args->probe_firmware))
("quiet", "Produce quiet output (no progress bar)",
cxxopts::value<bool>(quiet))
("r,reset", "reset FPGA after operations",