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
151
CMakeLists.txt
151
CMakeLists.txt
|
|
@ -3,6 +3,22 @@ cmake_minimum_required(VERSION 3.5)
|
||||||
# set the project name
|
# set the project name
|
||||||
project(openFPGALoader VERSION "1.0.0" LANGUAGES CXX)
|
project(openFPGALoader VERSION "1.0.0" LANGUAGES CXX)
|
||||||
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
|
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(ENABLE_OPTIM "Enable build with -O3 optimization level" ON)
|
||||||
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
|
|
@ -46,7 +62,15 @@ add_definitions(-DBLASTERII_DIR=\"${BLASTERII_PATH}\")
|
||||||
|
|
||||||
if (USE_PKGCONFIG)
|
if (USE_PKGCONFIG)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
|
|
||||||
|
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(LIBUSB REQUIRED libusb-1.0)
|
||||||
pkg_check_modules(HIDAPI hidapi-libusb)
|
pkg_check_modules(HIDAPI hidapi-libusb)
|
||||||
# if libusb not found try with hidraw
|
# if libusb not found try with hidraw
|
||||||
|
|
@ -87,18 +111,33 @@ if (USE_PKGCONFIG)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Core Classes
|
||||||
set(OPENFPGALOADER_SOURCE
|
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/anlogic.cpp
|
||||||
src/anlogicBitParser.cpp
|
src/anlogicBitParser.cpp
|
||||||
src/anlogicCable.cpp
|
src/anlogicCable.cpp
|
||||||
src/ch552_jtag.cpp
|
|
||||||
src/common.cpp
|
|
||||||
src/dfu.cpp
|
src/dfu.cpp
|
||||||
src/dfuFileParser.cpp
|
src/dfuFileParser.cpp
|
||||||
src/dirtyJtag.cpp
|
src/dirtyJtag.cpp
|
||||||
src/ch347jtag.cpp
|
src/ch347jtag.cpp
|
||||||
src/efinix.cpp
|
|
||||||
src/efinixHexParser.cpp
|
|
||||||
src/fx2_ll.cpp
|
src/fx2_ll.cpp
|
||||||
src/ihexParser.cpp
|
src/ihexParser.cpp
|
||||||
src/pofParser.cpp
|
src/pofParser.cpp
|
||||||
|
|
@ -108,94 +147,118 @@ set(OPENFPGALOADER_SOURCE
|
||||||
src/usbBlaster.cpp
|
src/usbBlaster.cpp
|
||||||
src/epcq.cpp
|
src/epcq.cpp
|
||||||
src/svf_jtag.cpp
|
src/svf_jtag.cpp
|
||||||
src/display.cpp
|
|
||||||
src/jtag.cpp
|
src/jtag.cpp
|
||||||
src/ftdiJtagBitbang.cpp
|
|
||||||
src/ftdiJtagMPSSE.cpp
|
|
||||||
src/configBitstreamParser.cpp
|
src/configBitstreamParser.cpp
|
||||||
src/ftdipp_mpsse.cpp
|
|
||||||
src/main.cpp
|
|
||||||
src/libusb_ll.cpp
|
src/libusb_ll.cpp
|
||||||
src/gowin.cpp
|
src/gowin.cpp
|
||||||
src/device.cpp
|
src/device.cpp
|
||||||
src/jlink.cpp
|
src/jlink.cpp
|
||||||
src/progressBar.cpp
|
|
||||||
src/fsparser.cpp
|
src/fsparser.cpp
|
||||||
src/mcsParser.cpp
|
src/mcsParser.cpp
|
||||||
src/ftdispi.cpp
|
|
||||||
src/altera.cpp
|
src/altera.cpp
|
||||||
src/bitparser.cpp
|
src/bitparser.cpp
|
||||||
src/xilinx.cpp
|
src/xilinx.cpp
|
||||||
src/xilinxMapParser.cpp
|
src/xilinxMapParser.cpp
|
||||||
src/colognechip.cpp
|
|
||||||
src/colognechipCfgParser.cpp
|
|
||||||
src/esp_usb_jtag.cpp
|
src/esp_usb_jtag.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(OPENFPGALOADER_HEADERS
|
list(APPEND OPENFPGALOADER_HEADERS
|
||||||
src/altera.hpp
|
src/altera.hpp
|
||||||
src/anlogic.hpp
|
src/anlogic.hpp
|
||||||
src/anlogicBitParser.hpp
|
src/anlogicBitParser.hpp
|
||||||
src/anlogicCable.hpp
|
src/anlogicCable.hpp
|
||||||
src/ch552_jtag.hpp
|
|
||||||
src/common.hpp
|
|
||||||
src/cxxopts.hpp
|
|
||||||
src/dfu.hpp
|
src/dfu.hpp
|
||||||
src/dfuFileParser.hpp
|
src/dfuFileParser.hpp
|
||||||
src/dirtyJtag.hpp
|
src/dirtyJtag.hpp
|
||||||
src/ch347jtag.hpp
|
src/ch347jtag.hpp
|
||||||
src/efinix.hpp
|
|
||||||
src/efinixHexParser.hpp
|
|
||||||
src/fx2_ll.hpp
|
src/fx2_ll.hpp
|
||||||
src/ihexParser.hpp
|
src/ihexParser.hpp
|
||||||
src/pofParser.hpp
|
src/pofParser.hpp
|
||||||
src/progressBar.hpp
|
|
||||||
src/rawParser.hpp
|
src/rawParser.hpp
|
||||||
src/usbBlaster.hpp
|
src/usbBlaster.hpp
|
||||||
src/bitparser.hpp
|
src/bitparser.hpp
|
||||||
src/ftdiJtagBitbang.hpp
|
|
||||||
src/ftdiJtagMPSSE.hpp
|
|
||||||
src/jlink.hpp
|
src/jlink.hpp
|
||||||
src/jtag.hpp
|
src/jtag.hpp
|
||||||
src/jtagInterface.hpp
|
src/jtagInterface.hpp
|
||||||
src/libusb_ll.hpp
|
src/libusb_ll.hpp
|
||||||
src/fsparser.hpp
|
src/fsparser.hpp
|
||||||
src/part.hpp
|
|
||||||
src/board.hpp
|
|
||||||
src/display.hpp
|
|
||||||
src/mcsParser.hpp
|
src/mcsParser.hpp
|
||||||
src/ftdipp_mpsse.hpp
|
|
||||||
src/spiFlash.hpp
|
src/spiFlash.hpp
|
||||||
src/spiFlashdb.hpp
|
src/spiFlashdb.hpp
|
||||||
src/epcq.hpp
|
src/epcq.hpp
|
||||||
src/spiInterface.hpp
|
src/spiInterface.hpp
|
||||||
src/svf_jtag.hpp
|
src/svf_jtag.hpp
|
||||||
src/configBitstreamParser.hpp
|
src/configBitstreamParser.hpp
|
||||||
src/device.hpp
|
|
||||||
src/gowin.hpp
|
src/gowin.hpp
|
||||||
src/cable.hpp
|
|
||||||
src/ftdispi.hpp
|
|
||||||
src/xilinx.hpp
|
src/xilinx.hpp
|
||||||
src/xilinxMapParser.hpp
|
src/xilinxMapParser.hpp
|
||||||
src/colognechip.hpp
|
|
||||||
src/colognechipCfgParser.hpp
|
|
||||||
src/esp_usb_jtag.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.
|
# Lattice Drivers / Files parsers.
|
||||||
list(APPEND OPENFPGALOADER_SOURCE
|
list(APPEND OPENFPGALOADER_SOURCE
|
||||||
src/ice40.cpp
|
|
||||||
src/lattice.cpp
|
src/lattice.cpp
|
||||||
src/latticeSSPI.cpp
|
|
||||||
src/feaparser.cpp
|
src/feaparser.cpp
|
||||||
src/jedParser.cpp
|
src/jedParser.cpp
|
||||||
src/latticeBitParser.cpp
|
src/latticeBitParser.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND OPENFPGALOADER_HEADERS
|
list(APPEND OPENFPGALOADER_HEADERS
|
||||||
src/ice40.hpp
|
|
||||||
src/lattice.hpp
|
src/lattice.hpp
|
||||||
src/latticeSSPI.hpp
|
|
||||||
src/jedParser.hpp
|
src/jedParser.hpp
|
||||||
src/feaparser.hpp
|
src/feaparser.hpp
|
||||||
src/latticeBitParser.hpp
|
src/latticeBitParser.hpp
|
||||||
|
|
@ -299,7 +362,7 @@ if (ENABLE_CMSISDAP)
|
||||||
endif()
|
endif()
|
||||||
endif(ENABLE_CMSISDAP)
|
endif(ENABLE_CMSISDAP)
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if ((${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND USE_LIBFTDI)
|
||||||
add_definitions(-DENABLE_XVC=1)
|
add_definitions(-DENABLE_XVC=1)
|
||||||
target_sources(openFPGALoader PRIVATE src/xvc_client.cpp src/xvc_server.cpp)
|
target_sources(openFPGALoader PRIVATE src/xvc_client.cpp src/xvc_server.cpp)
|
||||||
list (APPEND OPENFPGALOADER_HEADERS src/xvc_client.hpp src/xvc_server.hpp)
|
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)
|
target_link_libraries(openFPGALoader Threads::Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libftdi < 1.4 as no usb_addr
|
if (USE_LIBFTDI)
|
||||||
# libftdi >= 1.5 as purge_buffer obsolete
|
# libftdi < 1.4 as no usb_addr
|
||||||
string(REPLACE "." ";" VERSION_LIST ${LIBFTDI_VERSION})
|
# libftdi >= 1.5 as purge_buffer obsolete
|
||||||
list(GET VERSION_LIST 0 LIBFTDI_VERSION_MAJOR)
|
string(REPLACE "." ";" VERSION_LIST ${LIBFTDI_VERSION})
|
||||||
list(GET VERSION_LIST 1 LIBFTDI_VERSION_MINOR)
|
list(GET VERSION_LIST 0 LIBFTDI_VERSION_MAJOR)
|
||||||
math(EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR}")
|
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})
|
add_definitions(-DFTDI_VERSION=${FTDI_VAL})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "anlogicCable.hpp"
|
#include "anlogicCable.hpp"
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
#include "ch552_jtag.hpp"
|
#include "ch552_jtag.hpp"
|
||||||
|
#endif
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
#include "jtag.hpp"
|
#include "jtag.hpp"
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
#include "ftdiJtagBitbang.hpp"
|
#include "ftdiJtagBitbang.hpp"
|
||||||
#include "ftdiJtagMPSSE.hpp"
|
#include "ftdiJtagMPSSE.hpp"
|
||||||
|
#endif
|
||||||
#ifdef ENABLE_GOWIN_GWU2X
|
#ifdef ENABLE_GOWIN_GWU2X
|
||||||
#include "gwu2x_jtag.hpp"
|
#include "gwu2x_jtag.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -94,6 +98,7 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||||
case MODE_ANLOGICCABLE:
|
case MODE_ANLOGICCABLE:
|
||||||
_jtag = new AnlogicCable(clkHZ);
|
_jtag = new AnlogicCable(clkHZ);
|
||||||
break;
|
break;
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
case MODE_FTDI_BITBANG:
|
case MODE_FTDI_BITBANG:
|
||||||
if (pin_conf == NULL)
|
if (pin_conf == NULL)
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
|
@ -106,6 +111,7 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
||||||
case MODE_CH552_JTAG:
|
case MODE_CH552_JTAG:
|
||||||
_jtag = new CH552_jtag(cable, dev, serial, clkHZ, verbose);
|
_jtag = new CH552_jtag(cable, dev, serial, clkHZ, verbose);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case MODE_CH347:
|
case MODE_CH347:
|
||||||
_jtag = new CH347Jtag(clkHZ, verbose, cable.vid, cable.pid, cable.bus_addr, cable.device_addr);
|
_jtag = new CH347Jtag(clkHZ, verbose, cable.vid, cable.pid, cable.bus_addr, cable.device_addr);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
cable = select_cable->second;
|
cable = select_cable->second;
|
||||||
|
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
if (args.ftdi_channel != -1) {
|
if (args.ftdi_channel != -1) {
|
||||||
if (cable.type != MODE_FTDI_SERIAL && cable.type != MODE_FTDI_BITBANG){
|
if (cable.type != MODE_FTDI_SERIAL && cable.type != MODE_FTDI_BITBANG){
|
||||||
printError("Error: FTDI channel param is for FTDI cables.");
|
printError("Error: FTDI channel param is for FTDI cables.");
|
||||||
|
|
@ -241,6 +242,7 @@ int main(int argc, char **argv)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (args.vid != 0) {
|
if (args.vid != 0) {
|
||||||
printInfo("Cable VID overridden");
|
printInfo("Cable VID overridden");
|
||||||
|
|
@ -258,6 +260,7 @@ int main(int argc, char **argv)
|
||||||
cable.config.index = args.cable_index;
|
cable.config.index = args.cable_index;
|
||||||
cable.config.status_pin = args.status_pin;
|
cable.config.status_pin = args.status_pin;
|
||||||
|
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
/* FLASH direct access */
|
/* FLASH direct access */
|
||||||
if (args.spi || (board && board->mode == COMM_SPI)) {
|
if (args.spi || (board && board->mode == COMM_SPI)) {
|
||||||
/* if no instruction from user -> select flash mode */
|
/* if no instruction from user -> select flash mode */
|
||||||
|
|
@ -404,6 +407,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
return spi_ret;
|
return spi_ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ------------------- */
|
/* ------------------- */
|
||||||
/* DFU access */
|
/* DFU access */
|
||||||
|
|
@ -604,19 +608,23 @@ int main(int argc, char **argv)
|
||||||
} else if (fab == "anlogic") {
|
} else if (fab == "anlogic") {
|
||||||
fpga = new Anlogic(jtag, args.bit_file, args.file_type,
|
fpga = new Anlogic(jtag, args.bit_file, args.file_type,
|
||||||
args.prg_type, args.verify, args.verbose);
|
args.prg_type, args.verify, args.verbose);
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
} else if (fab == "efinix") {
|
} else if (fab == "efinix") {
|
||||||
fpga = new Efinix(jtag, args.bit_file, args.file_type,
|
fpga = new Efinix(jtag, args.bit_file, args.file_type,
|
||||||
args.prg_type, args.board, args.fpga_part, args.bridge_path,
|
args.prg_type, args.board, args.fpga_part, args.bridge_path,
|
||||||
args.verify, args.verbose);
|
args.verify, args.verbose);
|
||||||
|
#endif
|
||||||
} else if (fab == "Gowin") {
|
} else if (fab == "Gowin") {
|
||||||
fpga = new Gowin(jtag, args.bit_file, args.file_type, args.mcufw,
|
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);
|
args.prg_type, args.external_flash, args.verify, args.verbose, args.user_flash);
|
||||||
} else if (fab == "lattice") {
|
} else if (fab == "lattice") {
|
||||||
fpga = new Lattice(jtag, args.bit_file, args.file_type,
|
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);
|
args.prg_type, args.flash_sector, args.verify, args.verbose, args.skip_load_bridge, args.skip_reset);
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
} else if (fab == "colognechip") {
|
} else if (fab == "colognechip") {
|
||||||
fpga = new CologneChip(jtag, args.bit_file, args.file_type,
|
fpga = new CologneChip(jtag, args.bit_file, args.file_type,
|
||||||
args.prg_type, args.board, args.cable, args.verify, args.verbose);
|
args.prg_type, args.board, args.cable, args.verify, args.verbose);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
printError("Error: manufacturer " + fab + " not supported");
|
printError("Error: manufacturer " + fab + " not supported");
|
||||||
delete(jtag);
|
delete(jtag);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "display.hpp"
|
#include "display.hpp"
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
#include "ftdipp_mpsse.hpp"
|
#include "ftdipp_mpsse.hpp"
|
||||||
|
#endif
|
||||||
#include "fx2_ll.hpp"
|
#include "fx2_ll.hpp"
|
||||||
#include "usbBlaster.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)
|
_curr_tms(0), _buffer_size(64)
|
||||||
{
|
{
|
||||||
if (cable.pid == 0x6001)
|
if (cable.pid == 0x6001)
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
ll_driver = new UsbBlasterI();
|
ll_driver = new UsbBlasterI();
|
||||||
|
#else
|
||||||
|
throw std::runtime_error("usb-blasterI: Not build");
|
||||||
|
#endif
|
||||||
else if (cable.pid == 0x6810)
|
else if (cable.pid == 0x6810)
|
||||||
ll_driver = new UsbBlasterII(firmware_path);
|
ll_driver = new UsbBlasterII(firmware_path);
|
||||||
else
|
else
|
||||||
|
|
@ -58,6 +64,7 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
||||||
_nb_bit = 0;
|
_nb_bit = 0;
|
||||||
memset(_in_buf, 0, _buffer_size);
|
memset(_in_buf, 0, _buffer_size);
|
||||||
|
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
/* Force flush internal FT245 internal buffer */
|
/* Force flush internal FT245 internal buffer */
|
||||||
if (cable.pid == 0x6001) {
|
if (cable.pid == 0x6001) {
|
||||||
uint8_t val = DEFAULT | DO_WRITE | DO_BITBB | _tms_pin;
|
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);
|
ll_driver->write(tmp_buf, _nb_bit, NULL, 0);
|
||||||
_nb_bit = 0;
|
_nb_bit = 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UsbBlaster::~UsbBlaster()
|
UsbBlaster::~UsbBlaster()
|
||||||
|
|
@ -337,6 +345,7 @@ int UsbBlaster::write(bool read, int rd_len)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
/*
|
/*
|
||||||
* USB Blash I specific implementation
|
* USB Blash I specific implementation
|
||||||
*/
|
*/
|
||||||
|
|
@ -426,6 +435,7 @@ int UsbBlasterI::write(uint8_t *wr_buf, int wr_len,
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* USB Blash II specific implementation
|
* USB Blash II specific implementation
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,17 @@
|
||||||
|
|
||||||
#ifndef SRC_USBBLASTER_HPP_
|
#ifndef SRC_USBBLASTER_HPP_
|
||||||
#define SRC_USBBLASTER_HPP_
|
#define SRC_USBBLASTER_HPP_
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
#include <ftdi.h>
|
#include <ftdi.h>
|
||||||
|
#endif
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "cable.hpp"
|
#include "cable.hpp"
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
#include "ftdipp_mpsse.hpp"
|
#include "ftdipp_mpsse.hpp"
|
||||||
|
#endif
|
||||||
#include "fx2_ll.hpp"
|
#include "fx2_ll.hpp"
|
||||||
#include "jtagInterface.hpp"
|
#include "jtagInterface.hpp"
|
||||||
|
|
||||||
|
|
@ -95,6 +99,7 @@ class UsbBlaster : public JtagInterface {
|
||||||
uint16_t _buffer_size;
|
uint16_t _buffer_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef USE_LIBFTDI
|
||||||
/*!
|
/*!
|
||||||
* \file UsbBlaster.hpp
|
* \file UsbBlaster.hpp
|
||||||
* \class UsbBlasterI
|
* \class UsbBlasterI
|
||||||
|
|
@ -113,6 +118,7 @@ class UsbBlasterI: public UsbBlaster_ll {
|
||||||
private:
|
private:
|
||||||
struct ftdi_context *_ftdi; /*!< ftdi_context */
|
struct ftdi_context *_ftdi; /*!< ftdi_context */
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \file UsbBlaster.hpp
|
* \file UsbBlaster.hpp
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue