dirtyjtag: Allow custom VID/PID via command line options
Pass cable.vid and cable.pid to DirtyJtag constructor instead of using hardcoded DIRTYJTAG_VID/PID. This allows users to use DirtyJTAG-compatible firmware with custom USB VID/PID using the --vid and --pid flags: openFPGALoader -c dirtyJtag --vid 0x1337 --pid 0x0001 bitstream.fs This is useful for custom DirtyJTAG implementations, embedded microcontrollers with built-in JTAG adapters, or devices that use MS OS 2.0 descriptors for automatic WinUSB driver loading with different VID/PID. The default VID/PID (0x1209:0xC0CA) is preserved for backward compatibility.
This commit is contained in:
parent
ac3ed1266d
commit
c1c6e438a5
|
|
@ -62,7 +62,7 @@ enum dirtyJtagSig {
|
||||||
SIG_SRST = (1 << 6)
|
SIG_SRST = (1 << 6)
|
||||||
};
|
};
|
||||||
|
|
||||||
DirtyJtag::DirtyJtag(uint32_t clkHZ, int8_t verbose):
|
DirtyJtag::DirtyJtag(uint32_t clkHZ, int8_t verbose, uint16_t vid, uint16_t pid):
|
||||||
_verbose(verbose),
|
_verbose(verbose),
|
||||||
dev_handle(NULL), usb_ctx(NULL), _tdi(0), _tms(0)
|
dev_handle(NULL), usb_ctx(NULL), _tdi(0), _tms(0)
|
||||||
{
|
{
|
||||||
|
|
@ -73,8 +73,7 @@ DirtyJtag::DirtyJtag(uint32_t clkHZ, int8_t verbose):
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_handle = libusb_open_device_with_vid_pid(usb_ctx,
|
dev_handle = libusb_open_device_with_vid_pid(usb_ctx, vid, pid);
|
||||||
DIRTYJTAG_VID, DIRTYJTAG_PID);
|
|
||||||
if (!dev_handle) {
|
if (!dev_handle) {
|
||||||
cerr << "fails to open device" << endl;
|
cerr << "fails to open device" << endl;
|
||||||
libusb_exit(usb_ctx);
|
libusb_exit(usb_ctx);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
class DirtyJtag : public JtagInterface {
|
class DirtyJtag : public JtagInterface {
|
||||||
public:
|
public:
|
||||||
DirtyJtag(uint32_t clkHZ, int8_t verbose);
|
DirtyJtag(uint32_t clkHZ, int8_t verbose, uint16_t vid = 0x1209, uint16_t pid = 0xC0CA);
|
||||||
virtual ~DirtyJtag();
|
virtual ~DirtyJtag();
|
||||||
|
|
||||||
int setClkFreq(uint32_t clkHZ) override;
|
int setClkFreq(uint32_t clkHZ) override;
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||||
break;
|
break;
|
||||||
case MODE_DIRTYJTAG:
|
case MODE_DIRTYJTAG:
|
||||||
#ifdef ENABLE_DIRTYJTAG
|
#ifdef ENABLE_DIRTYJTAG
|
||||||
_jtag = new DirtyJtag(clkHZ, verbose);
|
_jtag = new DirtyJtag(clkHZ, verbose, cable.vid, cable.pid);
|
||||||
#else
|
#else
|
||||||
std::cerr << "Jtag: support for dirtyJtag cable was not enabled at compile time" << std::endl;
|
std::cerr << "Jtag: support for dirtyJtag cable was not enabled at compile time" << std::endl;
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ XVC_server::XVC_server(int port, const cable_t & cable,
|
||||||
new CH552_jtag(cable.config, dev, serial, clkHZ, _verbose);
|
new CH552_jtag(cable.config, dev, serial, clkHZ, _verbose);
|
||||||
break;
|
break;
|
||||||
case MODE_DIRTYJTAG:
|
case MODE_DIRTYJTAG:
|
||||||
_jtag = new DirtyJtag(clkHZ, _verbose);
|
_jtag = new DirtyJtag(clkHZ, _verbose, cable.vid, cable.pid);
|
||||||
break;
|
break;
|
||||||
case MODE_JLINK:
|
case MODE_JLINK:
|
||||||
_jtag = new Jlink(clkHZ, _verbose);
|
_jtag = new Jlink(clkHZ, _verbose);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue