CMakeLists, main: allows (un)select vendors support
This commit is contained in:
parent
d8bc361e7f
commit
b0ef00995f
123
CMakeLists.txt
123
CMakeLists.txt
|
|
@ -4,6 +4,23 @@ cmake_minimum_required(VERSION 3.0)
|
|||
project(openFPGALoader VERSION "0.10.0" LANGUAGES CXX)
|
||||
add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
|
||||
|
||||
# Enable all vendors by default
|
||||
if (NOT DEFINED ENABLE_VENDORS_DEFAULT)
|
||||
set(ENABLE_VENDORS_DEFAULT ON)
|
||||
message(STATUS "")
|
||||
message(STATUS "All vendors drivers will enabled by default.")
|
||||
message(STATUS "Use -DENABLE_VENDORS_DEFAULT=OFF to disable vendors by default.")
|
||||
endif()
|
||||
|
||||
message(${ENABLE_VENDORS_DEFAULT})
|
||||
option(ENABLE_ALTERA "Enable altera FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
option(ENABLE_ANLOGIC "Enable anlogic FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
option(ENABLE_COLOGNECHIP "Enable cologneChip FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
OPTION(ENABLE_EFINIX "Enable efinix FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
option(ENABLE_GOWIN "Enable gowin FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
option(ENABLE_LATTICE "Enable lattice FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
option(ENABLE_XILINX "Enable xilinx FPGA support" ${ENABLE_VENDORS_DEFAULT})
|
||||
|
||||
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")
|
||||
|
|
@ -88,20 +105,15 @@ if (USE_PKGCONFIG)
|
|||
endif()
|
||||
|
||||
set(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/efinix.cpp
|
||||
src/efinixHexParser.cpp
|
||||
src/fx2_ll.cpp
|
||||
src/ice40.cpp
|
||||
src/ihexParser.cpp
|
||||
src/pofParser.cpp
|
||||
src/rawParser.cpp
|
||||
src/spiFlash.cpp
|
||||
src/spiInterface.cpp
|
||||
|
|
@ -109,7 +121,6 @@ set(OPENFPGALOADER_SOURCE
|
|||
src/epcq.cpp
|
||||
src/svf_jtag.cpp
|
||||
src/jedParser.cpp
|
||||
src/feaparser.cpp
|
||||
src/display.cpp
|
||||
src/jtag.cpp
|
||||
src/ftdiJtagBitbang.cpp
|
||||
|
|
@ -117,28 +128,13 @@ set(OPENFPGALOADER_SOURCE
|
|||
src/configBitstreamParser.cpp
|
||||
src/ftdipp_mpsse.cpp
|
||||
src/main.cpp
|
||||
src/latticeBitParser.cpp
|
||||
src/libusb_ll.cpp
|
||||
src/gowin.cpp
|
||||
src/device.cpp
|
||||
src/jlink.cpp
|
||||
src/lattice.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
|
||||
)
|
||||
|
||||
set(OPENFPGALOADER_HEADERS
|
||||
src/altera.hpp
|
||||
src/anlogic.hpp
|
||||
src/anlogicBitParser.hpp
|
||||
src/anlogicCable.hpp
|
||||
src/ch552_jtag.hpp
|
||||
src/common.hpp
|
||||
|
|
@ -146,29 +142,22 @@ set(OPENFPGALOADER_HEADERS
|
|||
src/dfu.hpp
|
||||
src/dfuFileParser.hpp
|
||||
src/dirtyJtag.hpp
|
||||
src/efinix.hpp
|
||||
src/efinixHexParser.hpp
|
||||
src/fx2_ll.hpp
|
||||
src/ice40.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/jedParser.hpp
|
||||
src/feaparser.hpp
|
||||
src/display.hpp
|
||||
src/mcsParser.hpp
|
||||
src/ftdipp_mpsse.hpp
|
||||
src/spiFlash.hpp
|
||||
src/spiFlashdb.hpp
|
||||
|
|
@ -177,15 +166,8 @@ set(OPENFPGALOADER_HEADERS
|
|||
src/svf_jtag.hpp
|
||||
src/configBitstreamParser.hpp
|
||||
src/device.hpp
|
||||
src/gowin.hpp
|
||||
src/cable.hpp
|
||||
src/ftdispi.hpp
|
||||
src/lattice.hpp
|
||||
src/latticeBitParser.hpp
|
||||
src/xilinx.hpp
|
||||
src/xilinxMapParser.hpp
|
||||
src/colognechip.hpp
|
||||
src/colognechipCfgParser.hpp
|
||||
)
|
||||
|
||||
link_directories(
|
||||
|
|
@ -317,6 +299,77 @@ math(EXPR FTDI_VAL "${LIBFTDI_VERSION_MAJOR} * 100 + ${LIBFTDI_VERSION_MINOR}")
|
|||
|
||||
add_definitions(-DFTDI_VERSION=${FTDI_VAL})
|
||||
|
||||
if (ENABLE_ALTERA)
|
||||
add_definitions(-DENABLE_ALTERA=1)
|
||||
target_sources(openFPGALoader PRIVATE src/altera.cpp src/pofParser.cpp)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/altera.hpp src/pofParser.hpp)
|
||||
message("altera support enabled")
|
||||
else()
|
||||
message("altera support disabled")
|
||||
endif(ENABLE_ALTERA)
|
||||
|
||||
if (ENABLE_ANLOGIC)
|
||||
add_definitions(-DENABLE_ANLOGIC=1)
|
||||
target_sources(openFPGALoader PRIVATE src/anlogic.cpp src/anlogicBitParser.cpp)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/anlogic.hpp src/anlogicBitParser.hpp)
|
||||
message("anlogic support enabled")
|
||||
else()
|
||||
message("anlogic support disabled")
|
||||
endif(ENABLE_ANLOGIC)
|
||||
|
||||
if (ENABLE_COLOGNECHIP)
|
||||
add_definitions(-DENABLE_COLOGNECHIP=1)
|
||||
target_sources(openFPGALoader PRIVATE src/colognechip.cpp src/colognechipCfgParser.cpp)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/colognechip.hpp src/colognechipCfgParser.hpp)
|
||||
message("colognechip support enabled")
|
||||
else()
|
||||
message("colognechip support disabled")
|
||||
endif(ENABLE_COLOGNECHIP)
|
||||
|
||||
if (ENABLE_EFINIX)
|
||||
add_definitions(-DENABLE_EFINIX=1)
|
||||
target_sources(openFPGALoader PRIVATE src/efinix.cpp src/efinixHexParser.cpp)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/efinix.hpp src/efinixHexParser.hpp)
|
||||
message("efinix support enabled")
|
||||
else()
|
||||
message("efinix support disabled")
|
||||
endif(ENABLE_EFINIX)
|
||||
|
||||
if (ENABLE_GOWIN)
|
||||
add_definitions(-DENABLE_GOWIN=1)
|
||||
target_sources(openFPGALoader PRIVATE src/gowin.cpp src/fsparser.cpp)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/gowin.hpp src/fsparser.hpp)
|
||||
message("gowin support enabled")
|
||||
else()
|
||||
message("gowin support disabled")
|
||||
endif(ENABLE_GOWIN)
|
||||
|
||||
if (ENABLE_LATTICE)
|
||||
add_definitions(-DENABLE_LATTICE=1)
|
||||
target_sources(openFPGALoader PRIVATE src/lattice.cpp
|
||||
src/feaparser.cpp src/latticeBitParser.cpp
|
||||
)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/lattice.hpp
|
||||
src/feaparser.hpp src/latticeBitParser.hpp
|
||||
)
|
||||
message("lattice support enabled")
|
||||
else()
|
||||
message("lattice support disabled")
|
||||
endif(ENABLE_LATTICE)
|
||||
|
||||
if (ENABLE_XILINX)
|
||||
add_definitions(-DENABLE_XILINX=1)
|
||||
target_sources(openFPGALoader PRIVATE src/xilinx.cpp src/xilinxMapParser.cpp
|
||||
src/mcsParser.cpp src/bitparser.cpp
|
||||
)
|
||||
list (APPEND OPENFPGALOADER_HEADERS src/xilinx.hpp src/xilinxMapParser.hpp
|
||||
src/mcsParser.hpp src/bitparser.hpp
|
||||
)
|
||||
message("xilinx support enabled")
|
||||
else()
|
||||
message("xilinx support disabled")
|
||||
endif(ENABLE_XILINX)
|
||||
|
||||
install(TARGETS openFPGALoader DESTINATION bin)
|
||||
|
||||
file(GLOB GZ_FILES spiOverJtag/spiOverJtag_*.*.gz)
|
||||
|
|
|
|||
62
src/main.cpp
62
src/main.cpp
|
|
@ -13,26 +13,40 @@
|
|||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#ifdef ENABLE_ALTERA
|
||||
#include "altera.hpp"
|
||||
#endif
|
||||
#ifdef ENABLE_ANLOGIC
|
||||
#include "anlogic.hpp"
|
||||
#endif
|
||||
#include "board.hpp"
|
||||
#include "cable.hpp"
|
||||
#ifdef ENABLE_COLOGNECHIP
|
||||
#include "colognechip.hpp"
|
||||
#endif
|
||||
#include "cxxopts.hpp"
|
||||
#include "device.hpp"
|
||||
#include "dfu.hpp"
|
||||
#include "display.hpp"
|
||||
#ifdef ENABLE_EFINIX
|
||||
#include "efinix.hpp"
|
||||
#endif
|
||||
#include "ftdispi.hpp"
|
||||
#ifdef ENABLE_GOWIN
|
||||
#include "gowin.hpp"
|
||||
#endif
|
||||
#include "ice40.hpp"
|
||||
#ifdef ENABLE_LATTICE
|
||||
#include "lattice.hpp"
|
||||
#endif
|
||||
#include "libusb_ll.hpp"
|
||||
#include "jtag.hpp"
|
||||
#include "part.hpp"
|
||||
#include "spiFlash.hpp"
|
||||
#include "rawParser.hpp"
|
||||
#ifdef ENABLE_XILINX
|
||||
#include "xilinx.hpp"
|
||||
#endif
|
||||
#include "svf_jtag.hpp"
|
||||
#ifdef ENABLE_XVC
|
||||
#include "xvc_server.hpp"
|
||||
|
|
@ -265,19 +279,29 @@ int main(int argc, char **argv)
|
|||
int spi_ret = EXIT_SUCCESS;
|
||||
|
||||
if (board && board->manufacturer != "none") {
|
||||
Device *target;
|
||||
Device *target = NULL;
|
||||
if (board->manufacturer == "efinix") {
|
||||
#ifdef ENABLE_EFINIX
|
||||
target = new Efinix(spi, args.bit_file, args.file_type,
|
||||
board->reset_pin, board->done_pin, board->oe_pin,
|
||||
args.verify, args.verbose);
|
||||
#else
|
||||
printError("Error: Efinix support disable");
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
} else if (board->manufacturer == "lattice") {
|
||||
target = new Ice40(spi, args.bit_file, args.file_type,
|
||||
args.prg_type,
|
||||
board->reset_pin, board->done_pin, args.verify, args.verbose);
|
||||
} else if (board->manufacturer == "colognechip") {
|
||||
#ifdef ENABLE_COLOGNECHIP
|
||||
target = new CologneChip(spi, args.bit_file, args.file_type, args.prg_type,
|
||||
board->reset_pin, board->done_pin, DBUS6, board->oe_pin,
|
||||
args.verify, args.verbose);
|
||||
#else
|
||||
printError("Error: CologneChip support disable");
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
if (args.prg_type == Device::RD_FLASH) {
|
||||
if (args.file_size == 0) {
|
||||
|
|
@ -541,39 +565,69 @@ int main(int argc, char **argv)
|
|||
string fab = fpga_list[idcode].manufacturer;
|
||||
|
||||
|
||||
Device *fpga;
|
||||
Device *fpga = NULL;
|
||||
try {
|
||||
if (fab == "xilinx") {
|
||||
#ifdef ENABLE_XILINX
|
||||
fpga = new Xilinx(jtag, args.bit_file, args.secondary_bit_file,
|
||||
args.file_type, args.prg_type, args.fpga_part, args.bridge_path,
|
||||
args.target_flash, args.verify, args.verbose, args.skip_load_bridge, args.skip_reset);
|
||||
#else
|
||||
printError("Error: Xilinx support disable");
|
||||
#endif
|
||||
} else if (fab == "altera") {
|
||||
#ifdef ENABLE_ALTERA
|
||||
fpga = new Altera(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.fpga_part, args.bridge_path, args.verify,
|
||||
args.verbose, args.skip_load_bridge, args.skip_reset);
|
||||
#else
|
||||
printError("Error: Altera support disable");
|
||||
#endif
|
||||
} else if (fab == "anlogic") {
|
||||
#ifdef ENABLE_ANLOGIC
|
||||
fpga = new Anlogic(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.verify, args.verbose);
|
||||
#else
|
||||
printError("Error: Anlogic support disable");
|
||||
#endif
|
||||
} else if (fab == "efinix") {
|
||||
#ifdef ENABLE_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);
|
||||
#else
|
||||
printError("Error: Efinix support disable");
|
||||
#endif
|
||||
} else if (fab == "Gowin") {
|
||||
#ifdef ENABLE_GOWIN
|
||||
fpga = new Gowin(jtag, args.bit_file, args.file_type, args.mcufw,
|
||||
args.prg_type, args.external_flash, args.verify, args.verbose);
|
||||
#else
|
||||
printError("Error: Gowin support disable");
|
||||
#endif
|
||||
} else if (fab == "lattice") {
|
||||
#ifdef ENABLE_LATTICE
|
||||
fpga = new Lattice(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.flash_sector, args.verify, args.verbose);
|
||||
#else
|
||||
printError("Error: Lattice support disable");
|
||||
#endif
|
||||
} else if (fab == "colognechip") {
|
||||
#ifdef ENABLE_COLOGNECHIP
|
||||
fpga = new CologneChip(jtag, args.bit_file, args.file_type,
|
||||
args.prg_type, args.board, args.cable, args.verify, args.verbose);
|
||||
#else
|
||||
printError("Error: CologneChip support disable");
|
||||
#endif
|
||||
} else {
|
||||
printError("Error: manufacturer " + fab + " not supported");
|
||||
delete(jtag);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} catch (std::exception &e) {
|
||||
printError("Error: Failed to claim FPGA device: " + string(e.what()));
|
||||
fpga = NULL;
|
||||
}
|
||||
|
||||
if (!fpga) {
|
||||
delete(jtag);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue