global: continue to conditional enables cables and dependencies
This commit is contained in:
parent
a70f1a2f5c
commit
a6ae266205
100
CMakeLists.txt
100
CMakeLists.txt
|
|
@ -4,6 +4,9 @@ cmake_minimum_required(VERSION 3.5)
|
|||
project(openFPGALoader VERSION "1.0.0" LANGUAGES CXX)
|
||||
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
|
||||
|
||||
option(ENABLE_OPTIM "Enable build with -O3 optimization level" ON)
|
||||
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
||||
|
||||
# set all cable on by default
|
||||
option(ENABLE_CABLE_ALL "Enable all cables" ON)
|
||||
|
||||
|
|
@ -11,30 +14,36 @@ option(ENABLE_CABLE_ALL "Enable all cables" ON)
|
|||
set(USE_LIBUSB OFF)
|
||||
set(USE_LIBFTDI OFF)
|
||||
|
||||
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ${ENABLE_CABLE_ALL})
|
||||
option(ENABLE_DFU ${ENABLE_CABLE_ALL})
|
||||
option(ENABLE_FTDI_BASED_CABLE ${ENABLE_CABLE_ALL})
|
||||
option(ENABLE_GOWIN_GWU2X "enable Gowin GWU2X interface" ${ENABLE_CABLE_ALL})
|
||||
option(ENABLE_USB_BLASTERI ${ENABLE_CABLE_ALL})
|
||||
option(ENABLE_USB_BLASTERII ${ENABLE_CABLE_ALL})
|
||||
|
||||
if (ENABLE_FTDI_BASED_CABLE)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
option(ENABLE_LIBGPIOD "enable libgpiod bitbang driver (requires libgpiod)" ${ENABLE_CABLE_ALL})
|
||||
option(ENABLE_REMOTEBITBANG "enable remote bitbang driver" ${ENABLE_CABLE_ALL})
|
||||
else()
|
||||
set(ENABLE_LIBGPIOD OFF)
|
||||
set(ENABLE_REMOTEBITBANG OFF)
|
||||
endif()
|
||||
|
||||
# Only adds libftdi as dependency when a cable
|
||||
# need this library.
|
||||
if (ENABLE_FTDI_BASED_CABLE OR ENABLE_USB_BLASTERI)
|
||||
set(USE_LIBFTDI ON)
|
||||
else()
|
||||
message("disabled all cables based on FTDI devices")
|
||||
endif(ENABLE_FTDI_BASED_CABLE)
|
||||
endif(ENABLE_FTDI_BASED_CABLE OR ENABLE_USB_BLASTERI)
|
||||
|
||||
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")
|
||||
set(ENABLE_UDEV OFF)
|
||||
else()
|
||||
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON)
|
||||
endif()
|
||||
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ON)
|
||||
option(ENABLE_GOWIN_GWU2X "enable Gowin GWU2X interface" ON)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
option(ENABLE_LIBGPIOD "enable libgpiod bitbang driver (requires libgpiod)" ON)
|
||||
option(ENABLE_REMOTEBITBANG "enable remote bitbang driver" ON)
|
||||
else()
|
||||
set(ENABLE_LIBGPIOD OFF)
|
||||
set(ENABLE_REMOTEBITBANG OFF)
|
||||
endif()
|
||||
|
||||
|
||||
option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON)
|
||||
option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF)
|
||||
set(BLASTERII_PATH "" CACHE STRING "usbBlasterII firmware directory")
|
||||
|
|
@ -58,7 +67,6 @@ include(GNUInstallDirs)
|
|||
add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\")
|
||||
|
||||
add_definitions(-DISE_DIR=\"${ISE_PATH}\")
|
||||
add_definitions(-DBLASTERII_DIR=\"${BLASTERII_PATH}\")
|
||||
|
||||
if (USE_PKGCONFIG)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
|
@ -72,13 +80,16 @@ if (USE_PKGCONFIG)
|
|||
endif(USE_LIBFTDI)
|
||||
|
||||
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
||||
|
||||
if(ENABLE_CMSISDAP)
|
||||
pkg_check_modules(HIDAPI hidapi-libusb)
|
||||
# if libusb not found try with hidraw
|
||||
if (NOT HIDAPI_FOUND)
|
||||
pkg_check_modules(HIDAPI hidapi-hidraw)
|
||||
endif()
|
||||
if (NOT HIDAPI_FOUND)
|
||||
pkg_check_modules(HIDAPI hidapi)
|
||||
# if libusb not found try with hidraw
|
||||
if (NOT HIDAPI_FOUND)
|
||||
pkg_check_modules(HIDAPI hidapi-hidraw)
|
||||
endif()
|
||||
if (NOT HIDAPI_FOUND)
|
||||
pkg_check_modules(HIDAPI hidapi)
|
||||
endif()
|
||||
endif()
|
||||
# zlib support (gzip)
|
||||
pkg_check_modules(ZLIB zlib)
|
||||
|
|
@ -114,6 +125,8 @@ endif()
|
|||
# Core Classes
|
||||
set(OPENFPGALOADER_SOURCE
|
||||
src/common.cpp
|
||||
src/configBitstreamParser.cpp
|
||||
src/device.cpp
|
||||
src/display.cpp
|
||||
src/main.cpp
|
||||
src/progressBar.cpp
|
||||
|
|
@ -123,6 +136,7 @@ set(OPENFPGALOADER_HEADERS
|
|||
src/board.hpp
|
||||
src/cable.hpp
|
||||
src/common.hpp
|
||||
src/configBitstreamParser.hpp
|
||||
src/cxxopts.hpp
|
||||
src/device.hpp
|
||||
src/display.hpp
|
||||
|
|
@ -134,8 +148,6 @@ list(APPEND OPENFPGALOADER_SOURCE
|
|||
src/anlogic.cpp
|
||||
src/anlogicBitParser.cpp
|
||||
src/anlogicCable.cpp
|
||||
src/dfu.cpp
|
||||
src/dfuFileParser.cpp
|
||||
src/dirtyJtag.cpp
|
||||
src/ch347jtag.cpp
|
||||
src/fx2_ll.cpp
|
||||
|
|
@ -144,14 +156,11 @@ list(APPEND OPENFPGALOADER_SOURCE
|
|||
src/rawParser.cpp
|
||||
src/spiFlash.cpp
|
||||
src/spiInterface.cpp
|
||||
src/usbBlaster.cpp
|
||||
src/epcq.cpp
|
||||
src/svf_jtag.cpp
|
||||
src/jtag.cpp
|
||||
src/configBitstreamParser.cpp
|
||||
src/libusb_ll.cpp
|
||||
src/gowin.cpp
|
||||
src/device.cpp
|
||||
src/jlink.cpp
|
||||
src/fsparser.cpp
|
||||
src/mcsParser.cpp
|
||||
|
|
@ -167,15 +176,12 @@ list(APPEND OPENFPGALOADER_HEADERS
|
|||
src/anlogic.hpp
|
||||
src/anlogicBitParser.hpp
|
||||
src/anlogicCable.hpp
|
||||
src/dfu.hpp
|
||||
src/dfuFileParser.hpp
|
||||
src/dirtyJtag.hpp
|
||||
src/ch347jtag.hpp
|
||||
src/fx2_ll.hpp
|
||||
src/ihexParser.hpp
|
||||
src/pofParser.hpp
|
||||
src/rawParser.hpp
|
||||
src/usbBlaster.hpp
|
||||
src/bitparser.hpp
|
||||
src/jlink.hpp
|
||||
src/jtag.hpp
|
||||
|
|
@ -188,7 +194,6 @@ list(APPEND OPENFPGALOADER_HEADERS
|
|||
src/epcq.hpp
|
||||
src/spiInterface.hpp
|
||||
src/svf_jtag.hpp
|
||||
src/configBitstreamParser.hpp
|
||||
src/gowin.hpp
|
||||
src/xilinx.hpp
|
||||
src/xilinxMapParser.hpp
|
||||
|
|
@ -264,6 +269,43 @@ list(APPEND OPENFPGALOADER_HEADERS
|
|||
src/latticeBitParser.hpp
|
||||
)
|
||||
|
||||
# Cables select
|
||||
|
||||
# DFU
|
||||
if (ENABLE_DFU)
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/dfu.cpp
|
||||
src/dfuFileParser.cpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/dfu.hpp
|
||||
src/dfuFileParser.hpp
|
||||
)
|
||||
endif(ENABLE_DFU)
|
||||
|
||||
# Altera USB Blaster (I & II).
|
||||
if (ENABLE_USB_BLASTERI OR ENABLE_USB_BLASTERII)
|
||||
add_definitions(-DENABLE_USBBLASTER)
|
||||
|
||||
if (ENABLE_USB_BLASTERI)
|
||||
add_definitions(-DENABLE_USB_BLASTERI)
|
||||
endif()
|
||||
|
||||
if (ENABLE_USB_BLASTERII)
|
||||
add_definitions(-DBLASTERII_DIR=\"${BLASTERII_PATH}\")
|
||||
add_definitions(-DENABLE_USB_BLASTERII)
|
||||
endif (ENABLE_USB_BLASTERII)
|
||||
|
||||
list(APPEND OPENFPGALOADER_SOURCE
|
||||
src/usbBlaster.cpp
|
||||
)
|
||||
|
||||
list(APPEND OPENFPGALOADER_HEADERS
|
||||
src/usbBlaster.hpp
|
||||
)
|
||||
endif(ENABLE_USB_BLASTERI OR ENABLE_USB_BLASTERII)
|
||||
|
||||
link_directories(
|
||||
${LIBUSB_LIBRARY_DIRS}
|
||||
${LIBFTDI_LIBRARY_DIRS}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,9 @@
|
|||
#ifdef ENABLE_REMOTEBITBANG
|
||||
#include "remoteBitbang_client.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_USBBLASTER
|
||||
#include "usbBlaster.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_XVC
|
||||
#include "xvc_client.hpp"
|
||||
#endif
|
||||
|
|
@ -133,8 +135,13 @@ Jtag::Jtag(const cable_t &cable, const jtag_pins_conf_t *pin_conf,
|
|||
_jtag = new esp_usb_jtag(clkHZ, verbose, 0x303a, 0x1001);
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@ int main(int argc, char **argv)
|
|||
/* 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;
|
||||
|
|
@ -462,6 +463,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
|
||||
|
|
|
|||
|
|
@ -45,13 +45,17 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
|||
_curr_tms(0), _buffer_size(64)
|
||||
{
|
||||
if (cable.pid == 0x6001)
|
||||
#ifdef USE_LIBFTDI
|
||||
#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");
|
||||
|
||||
|
|
@ -64,7 +68,7 @@ UsbBlaster::UsbBlaster(const cable_t &cable, const std::string &firmware_path,
|
|||
_nb_bit = 0;
|
||||
memset(_in_buf, 0, _buffer_size);
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
/* Force flush internal FT245 internal buffer */
|
||||
if (cable.pid == 0x6001) {
|
||||
uint8_t val = DEFAULT | DO_WRITE | DO_BITBB | _tms_pin;
|
||||
|
|
@ -345,7 +349,7 @@ int UsbBlaster::write(bool read, int rd_len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
/*
|
||||
* USB Blash I specific implementation
|
||||
*/
|
||||
|
|
@ -437,6 +441,7 @@ int UsbBlasterI::write(uint8_t *wr_buf, int wr_len,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERII
|
||||
/*
|
||||
* USB Blash II specific implementation
|
||||
*/
|
||||
|
|
@ -522,3 +527,4 @@ int UsbBlasterII::write(uint8_t *wr_buf, int wr_len,
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class UsbBlaster : public JtagInterface {
|
|||
uint16_t _buffer_size;
|
||||
};
|
||||
|
||||
#ifdef USE_LIBFTDI
|
||||
#ifdef ENABLE_USB_BLASTERI
|
||||
/*!
|
||||
* \file UsbBlaster.hpp
|
||||
* \class UsbBlasterI
|
||||
|
|
@ -120,6 +120,7 @@ class UsbBlasterI: public UsbBlaster_ll {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_USB_BLASTERII
|
||||
/*!
|
||||
* \file UsbBlaster.hpp
|
||||
* \class UsbBlasterII
|
||||
|
|
@ -138,4 +139,5 @@ class UsbBlasterII: public UsbBlaster_ll {
|
|||
private:
|
||||
FX2_ll *fx2;
|
||||
};
|
||||
#endif
|
||||
#endif // SRC_USBBLASTER_HPP_
|
||||
|
|
|
|||
Loading…
Reference in New Issue