Global: added option to select/delect all cables, added variable to enable FTDI/LIBUSB when cables requires it
This commit is contained in:
parent
530b7a9993
commit
a70f1a2f5c
149
CMakeLists.txt
149
CMakeLists.txt
|
|
@ -3,6 +3,22 @@ cmake_minimum_required(VERSION 3.5)
|
|||
# set the project name
|
||||
project(openFPGALoader VERSION "1.0.0" LANGUAGES CXX)
|
||||
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
|
||||
|
||||
# set all cable on by default
|
||||
option(ENABLE_CABLE_ALL "Enable all cables" ON)
|
||||
|
||||
# set dependencies
|
||||
set(USE_LIBUSB OFF)
|
||||
set(USE_LIBFTDI OFF)
|
||||
|
||||
option(ENABLE_FTDI_BASED_CABLE ${ENABLE_CABLE_ALL})
|
||||
|
||||
if (ENABLE_FTDI_BASED_CABLE)
|
||||
set(USE_LIBFTDI ON)
|
||||
else()
|
||||
message("disabled all cables based on FTDI devices")
|
||||
endif(ENABLE_FTDI_BASED_CABLE)
|
||||
|
||||
option(ENABLE_OPTIM "Enable build with -O3 optimization level" ON)
|
||||
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
|
@ -46,7 +62,15 @@ add_definitions(-DBLASTERII_DIR=\"${BLASTERII_PATH}\")
|
|||
|
||||
if (USE_PKGCONFIG)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if (USE_LIBFTDI)
|
||||
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
|
||||
else()
|
||||
set(LIBFTDI_LIBRARY_DIRS "")
|
||||
set(LIBFTDI_INCLUDE_DIRS "")
|
||||
set(LIBFTDI_LIBRARIES "")
|
||||
endif(USE_LIBFTDI)
|
||||
|
||||
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
||||
pkg_check_modules(HIDAPI hidapi-libusb)
|
||||
# if libusb not found try with hidraw
|
||||
|
|
@ -87,18 +111,33 @@ if (USE_PKGCONFIG)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# Core Classes
|
||||
set(OPENFPGALOADER_SOURCE
|
||||
src/common.cpp
|
||||
src/display.cpp
|
||||
src/main.cpp
|
||||
src/progressBar.cpp
|
||||
)
|
||||
|
||||
set(OPENFPGALOADER_HEADERS
|
||||
src/board.hpp
|
||||
src/cable.hpp
|
||||
src/common.hpp
|
||||
src/cxxopts.hpp
|
||||
src/device.hpp
|
||||
src/display.hpp
|
||||
src/part.hpp
|
||||
src/progressBar.hpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/anlogic.cpp
|
||||
src/anlogicBitParser.cpp
|
||||
src/anlogicCable.cpp
|
||||
src/ch552_jtag.cpp
|
||||
src/common.cpp
|
||||
src/dfu.cpp
|
||||
src/dfuFileParser.cpp
|
||||
src/dirtyJtag.cpp
|
||||
src/ch347jtag.cpp
|
||||
src/efinix.cpp
|
||||
src/efinixHexParser.cpp
|
||||
src/fx2_ll.cpp
|
||||
src/ihexParser.cpp
|
||||
src/pofParser.cpp
|
||||
|
|
@ -108,94 +147,118 @@ set(OPENFPGALOADER_SOURCE
|
|||
src/usbBlaster.cpp
|
||||
src/epcq.cpp
|
||||
src/svf_jtag.cpp
|
||||
src/display.cpp
|
||||
src/jtag.cpp
|
||||
src/ftdiJtagBitbang.cpp
|
||||
src/ftdiJtagMPSSE.cpp
|
||||
src/configBitstreamParser.cpp
|
||||
src/ftdipp_mpsse.cpp
|
||||
src/main.cpp
|
||||
src/libusb_ll.cpp
|
||||
src/gowin.cpp
|
||||
src/device.cpp
|
||||
src/jlink.cpp
|
||||
src/progressBar.cpp
|
||||
src/fsparser.cpp
|
||||
src/mcsParser.cpp
|
||||
src/ftdispi.cpp
|
||||
src/altera.cpp
|
||||
src/bitparser.cpp
|
||||
src/xilinx.cpp
|
||||
src/xilinxMapParser.cpp
|
||||
src/colognechip.cpp
|
||||
src/colognechipCfgParser.cpp
|
||||
src/esp_usb_jtag.cpp
|
||||
)
|
||||
|
||||
set(OPENFPGALOADER_HEADERS
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/altera.hpp
|
||||
src/anlogic.hpp
|
||||
src/anlogicBitParser.hpp
|
||||
src/anlogicCable.hpp
|
||||
src/ch552_jtag.hpp
|
||||
src/common.hpp
|
||||
src/cxxopts.hpp
|
||||
src/dfu.hpp
|
||||
src/dfuFileParser.hpp
|
||||
src/dirtyJtag.hpp
|
||||
src/ch347jtag.hpp
|
||||
src/efinix.hpp
|
||||
src/efinixHexParser.hpp
|
||||
src/fx2_ll.hpp
|
||||
src/ihexParser.hpp
|
||||
src/pofParser.hpp
|
||||
src/progressBar.hpp
|
||||
src/rawParser.hpp
|
||||
src/usbBlaster.hpp
|
||||
src/bitparser.hpp
|
||||
src/ftdiJtagBitbang.hpp
|
||||
src/ftdiJtagMPSSE.hpp
|
||||
src/jlink.hpp
|
||||
src/jtag.hpp
|
||||
src/jtagInterface.hpp
|
||||
src/libusb_ll.hpp
|
||||
src/fsparser.hpp
|
||||
src/part.hpp
|
||||
src/board.hpp
|
||||
src/display.hpp
|
||||
src/mcsParser.hpp
|
||||
src/ftdipp_mpsse.hpp
|
||||
src/spiFlash.hpp
|
||||
src/spiFlashdb.hpp
|
||||
src/epcq.hpp
|
||||
src/spiInterface.hpp
|
||||
src/svf_jtag.hpp
|
||||
src/configBitstreamParser.hpp
|
||||
src/device.hpp
|
||||
src/gowin.hpp
|
||||
src/cable.hpp
|
||||
src/ftdispi.hpp
|
||||
src/xilinx.hpp
|
||||
src/xilinxMapParser.hpp
|
||||
src/colognechip.hpp
|
||||
src/colognechipCfgParser.hpp
|
||||
src/esp_usb_jtag.hpp
|
||||
)
|
||||
|
||||
# FTDI Based cables
|
||||
if (${USE_LIBFTDI})
|
||||
add_definitions(-DUSE_LIBFTDI)
|
||||
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/ch552_jtag.cpp
|
||||
src/ftdiJtagBitbang.cpp
|
||||
src/ftdiJtagMPSSE.cpp
|
||||
src/ftdipp_mpsse.cpp
|
||||
src/ftdispi.cpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/ch552_jtag.hpp
|
||||
src/ftdiJtagBitbang.hpp
|
||||
src/ftdiJtagMPSSE.hpp
|
||||
src/ftdipp_mpsse.hpp
|
||||
src/ftdispi.hpp
|
||||
)
|
||||
|
||||
# CologneChip Drivers / Files parsers.
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/colognechip.cpp
|
||||
src/colognechipCfgParser.cpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/colognechip.hpp
|
||||
src/colognechipCfgParser.hpp
|
||||
)
|
||||
|
||||
# Efinix Drivers / Files parsers.
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/efinix.cpp
|
||||
src/efinixHexParser.cpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/efinix.hpp
|
||||
src/efinixHexParser.hpp
|
||||
)
|
||||
|
||||
# Lattice Drivers / Files parsers.
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/ice40.cpp
|
||||
src/latticeSSPI.cpp
|
||||
)
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/ice40.hpp
|
||||
src/latticeSSPI.hpp
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
# Lattice Drivers / Files parsers.
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/ice40.cpp
|
||||
src/lattice.cpp
|
||||
src/latticeSSPI.cpp
|
||||
src/feaparser.cpp
|
||||
src/jedParser.cpp
|
||||
src/latticeBitParser.cpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/ice40.hpp
|
||||
src/lattice.hpp
|
||||
src/latticeSSPI.hpp
|
||||
src/jedParser.hpp
|
||||
src/feaparser.hpp
|
||||
src/latticeBitParser.hpp
|
||||
|
|
@ -299,7 +362,7 @@ if (ENABLE_CMSISDAP)
|
|||
endif()
|
||||
endif(ENABLE_CMSISDAP)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
if ((${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND USE_LIBFTDI)
|
||||
add_definitions(-DENABLE_XVC=1)
|
||||
target_sources(openFPGALoader PRIVATE src/xvc_client.cpp src/xvc_server.cpp)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/xvc_client.hpp src/xvc_server.hpp)
|
||||
|
|
@ -331,12 +394,14 @@ if (LINK_CMAKE_THREADS)
|
|||
target_link_libraries(openFPGALoader Threads::Threads)
|
||||
endif()
|
||||
|
||||
# libftdi < 1.4 as no usb_addr
|
||||
# libftdi >= 1.5 as purge_buffer obsolete
|
||||
string(REPLACE "." ";" VERSION_LIST ${LIBFTDI_VERSION})
|
||||
list(GET VERSION_LIST 0 LIBFTDI_VERSION_MAJOR)
|
||||
list(GET VERSION_LIST 1 LIBFTDI_VERSION_MINOR)
|
||||
math(EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR}")
|
||||
if (USE_LIBFTDI)
|
||||
# libftdi < 1.4 as no usb_addr
|
||||
# libftdi >= 1.5 as purge_buffer obsolete
|
||||
string(REPLACE "." ";" VERSION_LIST ${LIBFTDI_VERSION})
|
||||
list(GET VERSION_LIST 0 LIBFTDI_VERSION_MAJOR)
|
||||
list(GET VERSION_LIST 1 LIBFTDI_VERSION_MINOR)
|
||||
math(EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR}")
|
||||
endif()
|
||||
|
||||
add_definitions(-DFTDI_VERSION=${FTDI_VAL})
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,15 @@
|
|||
#include <string>
|
||||
|
||||
#include "anlogicCable.hpp"
|
||||
#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
|
||||
|
|
@ -94,6 +98,7 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
|||
case MODE_ANLOGICCABLE:
|
||||
_jtag = new AnlogicCable(clkHZ);
|
||||
break;
|
||||
#ifdef USE_LIBFTDI
|
||||
case MODE_FTDI_BITBANG:
|
||||
if (pin_conf == NULL)
|
||||
throw std::exception();
|
||||
|
|
@ -106,6 +111,7 @@ 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:
|
||||
_jtag = new CH347Jtag(clkHZ, verbose, cable.vid, cable.pid, cable.bus_addr, cable.device_addr);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -217,6 +217,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 +242,7 @@ int main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args.vid != 0) {
|
||||
printInfo("Cable VID overridden");
|
||||
|
|
@ -258,6 +260,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,6 +407,7 @@ int main(int argc, char **argv)
|
|||
|
||||
return spi_ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ------------------- */
|
||||
/* DFU access */
|
||||
|
|
@ -604,19 +608,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);
|
||||
|
|
|
|||
|
|
@ -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,7 +45,11 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
|||
_curr_tms(0), _buffer_size(64)
|
||||
{
|
||||
if (cable.pid == 0x6001)
|
||||
#ifdef USE_LIBFTDI
|
||||
ll_driver = new UsbBlasterI();
|
||||
#else
|
||||
throw std::runtime_error("usb-blasterI: Not build");
|
||||
#endif
|
||||
else if (cable.pid == 0x6810)
|
||||
ll_driver = new UsbBlasterII(firmware_path);
|
||||
else
|
||||
|
|
@ -58,6 +64,7 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
|||
_nb_bit = 0;
|
||||
memset(_in_buf, 0, _buffer_size);
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
/* Force flush internal FT245 internal buffer */
|
||||
if (cable.pid == 0x6001) {
|
||||
uint8_t val = DEFAULT | DO_WRITE | DO_BITBB | _tms_pin;
|
||||
|
|
@ -70,6 +77,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 +345,7 @@ int UsbBlaster::write(bool read, int rd_len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
/*
|
||||
* USB Blash I specific implementation
|
||||
*/
|
||||
|
|
@ -426,6 +435,7 @@ int UsbBlasterI::write(uint8_t *wr_buf, int wr_len,
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* USB Blash II specific implementation
|
||||
|
|
|
|||
|
|
@ -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 USE_LIBFTDI
|
||||
/*!
|
||||
* \file UsbBlaster.hpp
|
||||
* \class UsbBlasterI
|
||||
|
|
@ -113,6 +118,7 @@ class UsbBlasterI: public UsbBlaster_ll {
|
|||
private:
|
||||
struct ftdi_context *_ftdi; /*!< ftdi_context */
|
||||
};
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \file UsbBlaster.hpp
|
||||
|
|
|
|||
Loading…
Reference in New Issue