mirror of
https://github.com/trabucayre/openFPGALoader.git
synced 2026-09-04 08:34:04 +02:00
Global: added option to select/deselect all cables, added variables ENABLE_xxx to enable corresponding cables. Some vendor drivers needs to to be disabled accordlingly
This commit is contained in:
@@ -47,11 +47,16 @@ CologneChip::CologneChip(Jtag* jtag, const std::string &filename,
|
||||
} else if (cable_name == "gatemate_pgm") {
|
||||
ftdi_board_name = "gatemate_pgm_spi";
|
||||
} else if (cable_name == "dirtyJtag") {
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
_dirtyjtag = reinterpret_cast<DirtyJtag *>(_jtag->_jtag);
|
||||
_rstn_pin = (1 << 6);
|
||||
_done_pin = 0;
|
||||
_fail_pin = 0;
|
||||
_oen_pin = 0;
|
||||
#else
|
||||
std::cerr << "Jtag: support for dirtyJtag cable was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ftdi_board_name != "") {
|
||||
@@ -90,10 +95,12 @@ void CologneChip::reset()
|
||||
_ftdi_jtag->gpio_clear(_rstn_pin | _oen_pin);
|
||||
usleep(SLEEP_US);
|
||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
} else if (_dirtyjtag) {
|
||||
_dirtyjtag->gpio_clear(_rstn_pin);
|
||||
_dirtyjtag->gpio_set(_rstn_pin);
|
||||
usleep(SLEEP_US);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,10 +149,12 @@ bool CologneChip::prepare_flash_access()
|
||||
/* enable output and disable reset */
|
||||
_ftdi_jtag->gpio_clear(_oen_pin);
|
||||
_ftdi_jtag->gpio_set(_rstn_pin);
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
} else if (_dirtyjtag) {
|
||||
_dirtyjtag->gpio_clear(_rstn_pin);
|
||||
_dirtyjtag->gpio_set(_rstn_pin);
|
||||
usleep(SLEEP_US);
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include <string>
|
||||
|
||||
#include "device.hpp"
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
#include "dirtyJtag.hpp"
|
||||
#endif
|
||||
#include "jtag.hpp"
|
||||
#include "ftdispi.hpp"
|
||||
#include "ftdiJtagMPSSE.hpp"
|
||||
@@ -70,7 +72,9 @@ class CologneChip: public Device, SPIInterface {
|
||||
|
||||
FtdiSpi *_spi = NULL;
|
||||
FtdiJtagMPSSE *_ftdi_jtag = NULL;
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
DirtyJtag *_dirtyjtag = NULL;
|
||||
#endif
|
||||
uint16_t _rstn_pin;
|
||||
uint16_t _done_pin;
|
||||
uint16_t _fail_pin;
|
||||
|
||||
+50
-2
@@ -12,12 +12,18 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifdef ENABLE_ANLOGIC_CABLE
|
||||
#include "anlogicCable.hpp"
|
||||
#endif
|
||||
#ifdef USE_LIBFTDI
|
||||
#include "ch552_jtag.hpp"
|
||||
#endif
|
||||
#include "display.hpp"
|
||||
#include "jtag.hpp"
|
||||
#ifdef USE_LIBFTDI
|
||||
#include "ftdiJtagBitbang.hpp"
|
||||
#include "ftdiJtagMPSSE.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_GOWIN_GWU2X
|
||||
#include "gwu2x_jtag.hpp"
|
||||
#endif
|
||||
@@ -27,18 +33,28 @@
|
||||
#ifdef ENABLE_JETSONNANOGPIO
|
||||
#include "jetsonNanoJtagBitbang.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_JLINK
|
||||
#include "jlink.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_CMSISDAP
|
||||
#include "cmsisDAP.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
#include "dirtyJtag.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_ESP_USB_JTAG
|
||||
#include "esp_usb_jtag.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_CH347
|
||||
#include "ch347jtag.hpp"
|
||||
#endif
|
||||
#include "part.hpp"
|
||||
#ifdef ENABLE_REMOTEBITBANG
|
||||
#include "remoteBitbang_client.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_USBBLASTER
|
||||
#include "usbBlaster.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_XVC
|
||||
#include "xvc_client.hpp"
|
||||
#endif
|
||||
@@ -92,8 +108,14 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||
{
|
||||
switch (cable.type) {
|
||||
case MODE_ANLOGICCABLE:
|
||||
#ifdef ENABLE_ANLOGIC_CABLE
|
||||
_jtag = new AnlogicCable(clkHZ);
|
||||
#else
|
||||
std::cerr << "Jtag: support for Anlogic cable was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
break;
|
||||
#ifdef USE_LIBFTDI
|
||||
case MODE_FTDI_BITBANG:
|
||||
if (pin_conf == NULL)
|
||||
throw std::exception();
|
||||
@@ -106,29 +128,55 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||
case MODE_CH552_JTAG:
|
||||
_jtag = new CH552_jtag(cable, dev, serial, clkHZ, verbose);
|
||||
break;
|
||||
#endif
|
||||
case MODE_CH347:
|
||||
#ifdef ENABLE_CH347
|
||||
_jtag = new CH347Jtag(clkHZ, verbose, cable.vid, cable.pid, cable.bus_addr, cable.device_addr);
|
||||
#else
|
||||
std::cerr << "Jtag: support for CH347 cable was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
break;
|
||||
case MODE_DIRTYJTAG:
|
||||
#ifdef ENABLE_DIRTYJTAG
|
||||
_jtag = new DirtyJtag(clkHZ, verbose);
|
||||
#else
|
||||
std::cerr << "Jtag: support for dirtyJtag cable was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
break;
|
||||
#ifdef ENABLE_GOWIN_GWU2X
|
||||
case MODE_GWU2X:
|
||||
#ifdef ENABLE_GOWIN_GWU2X
|
||||
_jtag = new GowinGWU2x((cable_t *)&cable, clkHZ, verbose);
|
||||
break;
|
||||
#else
|
||||
std::cerr << "Jtag: support for Gowin GWU2X was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
break;
|
||||
case MODE_JLINK:
|
||||
#ifdef ENABLE_JLINK
|
||||
_jtag = new Jlink(clkHZ, verbose, cable.vid, cable.pid);
|
||||
#else
|
||||
std::cerr << "Jtag: support for JLink cable was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
break;
|
||||
case MODE_ESP:
|
||||
#ifdef ENABLE_ESP_USB_JTAG
|
||||
_jtag = new esp_usb_jtag(clkHZ, verbose, 0x303a, 0x1001);
|
||||
#else
|
||||
std::cerr << "Jtag: support for esp32s3 cable was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
break;
|
||||
case MODE_USBBLASTER:
|
||||
#ifdef ENABLE_USBBLASTER
|
||||
_jtag = new UsbBlaster(cable, firmware_path, verbose);
|
||||
break;
|
||||
#else
|
||||
std::cerr << "Jtag: support for usb-blaster was not enabled at compile time" << std::endl;
|
||||
throw std::exception();
|
||||
#endif
|
||||
case MODE_CMSISDAP:
|
||||
#ifdef ENABLE_CMSISDAP
|
||||
_jtag = new CmsisDAP(cable, cable.config.index, verbose);
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "common.hpp"
|
||||
#include "cxxopts.hpp"
|
||||
#include "device.hpp"
|
||||
#ifdef ENABLE_DFU
|
||||
#include "dfu.hpp"
|
||||
#endif
|
||||
#include "display.hpp"
|
||||
#include "efinix.hpp"
|
||||
#include "ftdispi.hpp"
|
||||
@@ -29,7 +31,9 @@
|
||||
#include "ice40.hpp"
|
||||
#include "lattice.hpp"
|
||||
#include "latticeSSPI.hpp"
|
||||
#ifdef ENABLE_USB_SCAN
|
||||
#include "libusb_ll.hpp"
|
||||
#endif
|
||||
#include "jtag.hpp"
|
||||
#include "part.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
@@ -217,6 +221,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
cable = select_cable->second;
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
if (args.ftdi_channel != -1) {
|
||||
if (cable.type != MODE_FTDI_SERIAL && cable.type != MODE_FTDI_BITBANG){
|
||||
printError("Error: FTDI channel param is for FTDI cables.");
|
||||
@@ -241,6 +246,7 @@ int main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args.vid != 0) {
|
||||
printInfo("Cable VID overridden");
|
||||
@@ -258,6 +264,7 @@ int main(int argc, char **argv)
|
||||
cable.config.index = args.cable_index;
|
||||
cable.config.status_pin = args.status_pin;
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
/* FLASH direct access */
|
||||
if (args.spi || (board && board->mode == COMM_SPI)) {
|
||||
/* if no instruction from user -> select flash mode */
|
||||
@@ -404,11 +411,13 @@ int main(int argc, char **argv)
|
||||
|
||||
return spi_ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ------------------- */
|
||||
/* DFU access */
|
||||
/* ------------------- */
|
||||
if (args.dfu || (board && board->mode == COMM_DFU)) {
|
||||
#ifdef ENABLE_DFU
|
||||
/* try to init DFU probe */
|
||||
DFU *dfu = NULL;
|
||||
uint16_t vid = 0, pid = 0;
|
||||
@@ -458,6 +467,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
#else
|
||||
throw std::runtime_error("DFU support: disabled at build time");
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_XVC
|
||||
@@ -604,19 +617,23 @@ int main(int argc, char **argv)
|
||||
} else if (fab == "anlogic") {
|
||||
fpga = new Anlogic(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.verify, args.verbose);
|
||||
#ifdef USE_LIBFTDI
|
||||
} else if (fab == "efinix") {
|
||||
fpga = new Efinix(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.board, args.fpga_part, args.bridge_path,
|
||||
args.verify, args.verbose);
|
||||
#endif
|
||||
} else if (fab == "Gowin") {
|
||||
fpga = new Gowin(jtag, args.bit_file, args.file_type, args.mcufw,
|
||||
args.prg_type, args.external_flash, args.verify, args.verbose, args.user_flash);
|
||||
} else if (fab == "lattice") {
|
||||
fpga = new Lattice(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.flash_sector, args.verify, args.verbose, args.skip_load_bridge, args.skip_reset);
|
||||
#ifdef USE_LIBFTDI
|
||||
} else if (fab == "colognechip") {
|
||||
fpga = new CologneChip(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.board, args.cable, args.verify, args.verbose);
|
||||
#endif
|
||||
} else {
|
||||
printError("Error: manufacturer " + fab + " not supported");
|
||||
delete(jtag);
|
||||
@@ -1193,9 +1210,11 @@ void displaySupported(const struct arguments &args)
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_USB_SCAN
|
||||
if (args.scan_usb) {
|
||||
libusb_ll usb(0, 0, args.verbose);
|
||||
usb.scan();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include "display.hpp"
|
||||
#ifdef USE_LIBFTDI
|
||||
#include "ftdipp_mpsse.hpp"
|
||||
#endif
|
||||
#include "fx2_ll.hpp"
|
||||
#include "usbBlaster.hpp"
|
||||
|
||||
@@ -43,9 +45,17 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
||||
_curr_tms(0), _buffer_size(64)
|
||||
{
|
||||
if (cable.pid == 0x6001)
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
ll_driver = new UsbBlasterI();
|
||||
#else
|
||||
throw std::runtime_error("usb-blasterI: Not build");
|
||||
#endif
|
||||
#ifdef ENABLE_USB_BLASTERII
|
||||
else if (cable.pid == 0x6810)
|
||||
ll_driver = new UsbBlasterII(firmware_path);
|
||||
#else
|
||||
throw std::runtime_error("usb-blasterII: Not build");
|
||||
#endif
|
||||
else
|
||||
throw std::runtime_error("usb-blaster: unknown VID/PID");
|
||||
|
||||
@@ -58,6 +68,7 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
||||
_nb_bit = 0;
|
||||
memset(_in_buf, 0, _buffer_size);
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
/* Force flush internal FT245 internal buffer */
|
||||
if (cable.pid == 0x6001) {
|
||||
uint8_t val = DEFAULT | DO_WRITE | DO_BITBB | _tms_pin;
|
||||
@@ -70,6 +81,7 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
||||
ll_driver->write(tmp_buf, _nb_bit, NULL, 0);
|
||||
_nb_bit = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
UsbBlaster::~UsbBlaster()
|
||||
@@ -337,6 +349,7 @@ int UsbBlaster::write(bool read, int rd_len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
/*
|
||||
* USB Blash I specific implementation
|
||||
*/
|
||||
@@ -426,7 +439,9 @@ int UsbBlasterI::write(uint8_t *wr_buf, int wr_len,
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERII
|
||||
/*
|
||||
* USB Blash II specific implementation
|
||||
*/
|
||||
@@ -512,3 +527,4 @@ int UsbBlasterII::write(uint8_t *wr_buf, int wr_len,
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -5,13 +5,17 @@
|
||||
|
||||
#ifndef SRC_USBBLASTER_HPP_
|
||||
#define SRC_USBBLASTER_HPP_
|
||||
#ifdef USE_LIBFTDI
|
||||
#include <ftdi.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cable.hpp"
|
||||
#ifdef USE_LIBFTDI
|
||||
#include "ftdipp_mpsse.hpp"
|
||||
#endif
|
||||
#include "fx2_ll.hpp"
|
||||
#include "jtagInterface.hpp"
|
||||
|
||||
@@ -95,6 +99,7 @@ class UsbBlaster : public JtagInterface {
|
||||
uint16_t _buffer_size;
|
||||
};
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
/*!
|
||||
* \file UsbBlaster.hpp
|
||||
* \class UsbBlasterI
|
||||
@@ -113,7 +118,9 @@ class UsbBlasterI: public UsbBlaster_ll {
|
||||
private:
|
||||
struct ftdi_context *_ftdi; /*!< ftdi_context */
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERII
|
||||
/*!
|
||||
* \file UsbBlaster.hpp
|
||||
* \class UsbBlasterII
|
||||
@@ -132,4 +139,5 @@ class UsbBlasterII: public UsbBlaster_ll {
|
||||
private:
|
||||
FX2_ll *fx2;
|
||||
};
|
||||
#endif
|
||||
#endif // SRC_USBBLASTER_HPP_
|
||||
|
||||
Reference in New Issue
Block a user