CMakeLists.txt,main: added options to enable/disable vendors drivers

This commit is contained in:
Gwenhael Goavec-Merou 2026-01-28 14:52:41 +01:00
parent b3a8ea03d5
commit cc1dc3c868
2 changed files with 244 additions and 71 deletions

View File

@ -54,6 +54,23 @@ else()
set(ENABLE_XILINX_VIRTUAL_CABLE OFF) set(ENABLE_XILINX_VIRTUAL_CABLE OFF)
endif() endif()
####################################################################################################
# VENDORS Options
####################################################################################################
# set all vendor on by default
option(ENABLE_VENDORS_ALL "Enable all vendors support" ON)
option(ENABLE_ALTERA_SUPPORT "enable Altera FPGAs Support" ${ENABLE_VENDORS_ALL})
option(ENABLE_ANLOGIC_SUPPORT "enable Anlogic FPGAs Support" ${ENABLE_VENDORS_ALL})
option(ENABLE_COLOGNECHIP_SUPPORT "enable CologneChip FPGAs Support (requires libftdi)" ${ENABLE_VENDORS_ALL})
option(ENABLE_EFINIX_SUPPORT "enable Efinix FPGAs Support (requires libftdi)" ${ENABLE_VENDORS_ALL})
option(ENABLE_GOWIN_SUPPORT "enable Gowin FPGAs Support" ${ENABLE_VENDORS_ALL})
option(ENABLE_ICE40_SUPPORT "enable Ice40 FPGAs Support (requires libftdi)" ${ENABLE_VENDORS_ALL})
option(ENABLE_LATTICE_SUPPORT "enable Lattice FPGAs Support" ${ENABLE_VENDORS_ALL})
option(ENABLE_LATTICESSPI_SUPPORT "enable Lattice FPGAs Support (SSPI / requires libftdi)" ${ENABLE_VENDORS_ALL})
option(ENABLE_XILINX_SUPPORT "enable Xilinx FPGAs Support" ${ENABLE_VENDORS_ALL})
#################################################################################################### ####################################################################################################
# Variables # Variables
#################################################################################################### ####################################################################################################
@ -146,7 +163,7 @@ if (USE_PKGCONFIG)
endif(USE_LIBUSB) endif(USE_LIBUSB)
if(ENABLE_CMSISDAP) if(ENABLE_CMSISDAP)
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
if (NOT HIDAPI_FOUND) if (NOT HIDAPI_FOUND)
pkg_check_modules(HIDAPI hidapi-hidraw) pkg_check_modules(HIDAPI hidapi-hidraw)
@ -155,6 +172,7 @@ if (USE_PKGCONFIG)
pkg_check_modules(HIDAPI hidapi) pkg_check_modules(HIDAPI hidapi)
endif() endif()
endif() endif()
# zlib support (gzip) # zlib support (gzip)
pkg_check_modules(ZLIB zlib) pkg_check_modules(ZLIB zlib)
if (NOT ZLIB_FOUND) if (NOT ZLIB_FOUND)
@ -217,44 +235,33 @@ set(OPENFPGALOADER_HEADERS
# =========================== # ===========================
# Parsers classes # Parsers classes
# =========================== # ===========================
list(APPEND OPENFPGALOADER_SOURCE list(APPEND OPENFPGALOADER_SOURCE src/rawParser.cpp)
src/anlogicBitParser.cpp list(APPEND OPENFPGALOADER_HEADERS src/rawParser.hpp)
src/bitparser.cpp
src/fsparser.cpp
src/mcsParser.cpp
src/pofParser.cpp
src/rawParser.cpp
src/xilinxMapParser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS if (${ENABLE_LATTICE_SUPPORT} OR ${ENABLE_XILINX_SUPPORT})
src/anlogicBitParser.hpp list(APPEND OPENFPGALOADER_SOURCE
src/bitparser.hpp src/jedParser.cpp
src/fsparser.hpp src/mcsParser.cpp
src/mcsParser.hpp )
src/pofParser.hpp
src/rawParser.hpp list(APPEND OPENFPGALOADER_HEADERS
src/xilinxMapParser.hpp src/jedParser.hpp
) src/mcsParser.hpp
)
endif()
# =========================== # ===========================
# To be sorted # To be sorted
# =========================== # ===========================
list(APPEND OPENFPGALOADER_SOURCE list(APPEND OPENFPGALOADER_SOURCE
src/anlogic.cpp
src/spiFlash.cpp src/spiFlash.cpp
src/spiInterface.cpp src/spiInterface.cpp
src/epcq.cpp src/epcq.cpp
src/svf_jtag.cpp src/svf_jtag.cpp
src/jtag.cpp src/jtag.cpp
src/gowin.cpp
src/altera.cpp
src/xilinx.cpp
) )
list(APPEND OPENFPGALOADER_HEADERS list(APPEND OPENFPGALOADER_HEADERS
src/altera.hpp
src/anlogic.hpp
src/jtag.hpp src/jtag.hpp
src/jtagInterface.hpp src/jtagInterface.hpp
src/spiFlash.hpp src/spiFlash.hpp
@ -262,8 +269,6 @@ list(APPEND OPENFPGALOADER_HEADERS
src/epcq.hpp src/epcq.hpp
src/spiInterface.hpp src/spiInterface.hpp
src/svf_jtag.hpp src/svf_jtag.hpp
src/gowin.hpp
src/xilinx.hpp
) )
# FTDI Based cables # FTDI Based cables
@ -287,52 +292,148 @@ if (${USE_LIBFTDI})
) )
# CologneChip Drivers / Files parsers. # CologneChip Drivers / Files parsers.
list(APPEND OPENFPGALOADER_SOURCE if (ENABLE_COLOGNECHIP_SUPPORT)
src/colognechip.cpp list(APPEND OPENFPGALOADER_SOURCE
src/colognechipCfgParser.cpp src/colognechip.cpp
) src/colognechipCfgParser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS list(APPEND OPENFPGALOADER_HEADERS
src/colognechip.hpp src/colognechip.hpp
src/colognechipCfgParser.hpp src/colognechipCfgParser.hpp
) )
add_definitions(-DENABLE_COLOGNECHIP_SUPPORT=1)
message("CologneChip support enabled")
else()
message("CologneChip support disabled")
endif(ENABLE_COLOGNECHIP_SUPPORT)
# Efinix Drivers / Files parsers. # Efinix Drivers / Files parsers.
list(APPEND OPENFPGALOADER_SOURCE if (ENABLE_EFINIX_SUPPORT)
src/efinix.cpp list(APPEND OPENFPGALOADER_SOURCE
src/efinixHexParser.cpp src/efinix.cpp
) src/efinixHexParser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS list(APPEND OPENFPGALOADER_HEADERS
src/efinix.hpp src/efinix.hpp
src/efinixHexParser.hpp src/efinixHexParser.hpp
) )
add_definitions(-DENABLE_EFINIX_SUPPORT=1)
message("Efinix support enabled")
else()
message("Efinix support disabled")
endif(ENABLE_EFINIX_SUPPORT)
# Lattice Drivers / Files parsers. # ICE40 Driver.
list(APPEND OPENFPGALOADER_SOURCE if (ENABLE_ICE40_SUPPORT)
src/ice40.cpp list(APPEND OPENFPGALOADER_SOURCE src/ice40.cpp)
src/latticeSSPI.cpp list(APPEND OPENFPGALOADER_HEADERS src/ice40.hpp)
) add_definitions(-DENABLE_ICE40_SUPPORT=1)
list(APPEND OPENFPGALOADER_HEADERS message("ICE40 support enabled")
src/ice40.hpp else()
src/latticeSSPI.hpp message("ICE40 support disabled")
) endif(ENABLE_ICE40_SUPPORT)
# Lattice SSPI Driver.
if (ENABLE_LATTICESSPI_SUPPORT)
list(APPEND OPENFPGALOADER_SOURCE src/latticeSSPI.cpp)
list(APPEND OPENFPGALOADER_HEADERS src/latticeSSPI.hpp)
add_definitions(-DENABLE_LATTICESSPI_SUPPORT=1)
message("Lattice SSPI support enabled")
else()
message("Lattice SSPI support disabled")
endif(ENABLE_LATTICESSPI_SUPPORT)
endif() endif()
# Lattice Drivers / Files parsers. # Altera Drivers / Files parsers.
list(APPEND OPENFPGALOADER_SOURCE if (ENABLE_ALTERA_SUPPORT)
src/lattice.cpp list(APPEND OPENFPGALOADER_SOURCE
src/feaparser.cpp src/altera.cpp
src/jedParser.cpp src/pofParser.cpp
src/latticeBitParser.cpp )
)
list(APPEND OPENFPGALOADER_HEADERS list(APPEND OPENFPGALOADER_HEADERS
src/lattice.hpp src/altera.hpp
src/jedParser.hpp src/pofParser.hpp
src/feaparser.hpp )
src/latticeBitParser.hpp add_definitions(-DENABLE_ALTERA_SUPPORT=1)
) message("Altera support enabled")
else()
message("Altera support disabled")
endif(ENABLE_ALTERA_SUPPORT)
# Anlogic Drivers / Files parsers.
if (ENABLE_ANLOGIC_SUPPORT)
list(APPEND OPENFPGALOADER_SOURCE
src/anlogic.cpp
src/anlogicBitParser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS
src/anlogic.hpp
src/anlogicBitParser.hpp
)
add_definitions(-DENABLE_ANLOGIC_SUPPORT=1)
message("Anlogic support enabled")
else()
message("Anlogic support disabled")
endif(ENABLE_ANLOGIC_SUPPORT)
# Gowin Drivers / Files parsers.
if (ENABLE_GOWIN_SUPPORT)
list(APPEND OPENFPGALOADER_SOURCE
src/gowin.cpp
src/fsparser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS
src/gowin.hpp
src/fsparser.hpp
)
add_definitions(-DENABLE_GOWIN_SUPPORT=1)
message("Gowin support enabled")
else()
message("Gowin support disabled")
endif(ENABLE_GOWIN_SUPPORT)
# Xilinx Drivers / Files parsers.
if (ENABLE_XILINX_SUPPORT)
list(APPEND OPENFPGALOADER_SOURCE
src/bitparser.cpp
src/xilinx.cpp
src/xilinxMapParser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS
src/bitparser.hpp
src/xilinx.hpp
src/xilinxMapParser.hpp
)
add_definitions(-DENABLE_XILINX_SUPPORT=1)
message("Xilinx support enabled")
else()
message("Xilinx support disabled")
endif(ENABLE_XILINX_SUPPORT)
# Lattice Drivers / Files parsers.
if (ENABLE_LATTICE_SUPPORT)
list(APPEND OPENFPGALOADER_SOURCE
src/lattice.cpp
src/feaparser.cpp
src/latticeBitParser.cpp
)
list(APPEND OPENFPGALOADER_HEADERS
src/lattice.hpp
src/feaparser.hpp
src/latticeBitParser.hpp
)
add_definitions(-DENABLE_LATTICE_SUPPORT=1)
message("Lattice support enabled")
else()
message("Lattice support disabled")
endif(ENABLE_LATTICE_SUPPORT)
# Cables select # Cables select

View File

@ -13,11 +13,15 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#ifdef ENABLE_ALTERA_SUPPORT
#include "altera.hpp" #include "altera.hpp"
#endif
#ifdef ENABLE_ANLOGIC_SUPPORT
#include "anlogic.hpp" #include "anlogic.hpp"
#endif
#include "board.hpp" #include "board.hpp"
#include "cable.hpp" #include "cable.hpp"
#ifdef USE_LIBFTDI #ifdef ENABLE_COLOGNECHIP_SUPPORT
#include "colognechip.hpp" #include "colognechip.hpp"
#endif #endif
#include "common.hpp" #include "common.hpp"
@ -27,14 +31,22 @@
#include "dfu.hpp" #include "dfu.hpp"
#endif #endif
#include "display.hpp" #include "display.hpp"
#ifdef USE_LIBFTDI #ifdef ENABLE_EFINIX_SUPPORT
#include "efinix.hpp" #include "efinix.hpp"
#endif
#ifdef USE_LIBFTDI
#include "ftdispi.hpp" #include "ftdispi.hpp"
#endif #endif
#ifdef ENABLE_GOWIN_SUPPORT
#include "gowin.hpp" #include "gowin.hpp"
#endif
#ifdef ENABLE_LATTICE_SUPPORT
#include "lattice.hpp" #include "lattice.hpp"
#ifdef USE_LIBFTDI #endif
#ifdef ENABLE_ICE40_SUPPORT
#include "ice40.hpp" #include "ice40.hpp"
#endif
#ifdef ENABLE_LATTICESSPI_SUPPORT
#include "latticeSSPI.hpp" #include "latticeSSPI.hpp"
#endif #endif
#ifdef ENABLE_USB_SCAN #ifdef ENABLE_USB_SCAN
@ -44,7 +56,9 @@
#include "part.hpp" #include "part.hpp"
#include "spiFlash.hpp" #include "spiFlash.hpp"
#include "rawParser.hpp" #include "rawParser.hpp"
#ifdef ENABLE_XILINX_SUPPORT
#include "xilinx.hpp" #include "xilinx.hpp"
#endif
#include "svf_jtag.hpp" #include "svf_jtag.hpp"
#ifdef ENABLE_XVC #ifdef ENABLE_XVC
#include "xvc_server.hpp" #include "xvc_server.hpp"
@ -304,25 +318,45 @@ int main(int argc, char **argv)
if (board && board->manufacturer != "none") { if (board && board->manufacturer != "none") {
Device *target; Device *target;
if (board->manufacturer == "efinix") { if (board->manufacturer == "efinix") {
#ifdef ENABLE_EFINIX_SUPPORT
target = new Efinix(spi, args.bit_file, args.file_type, target = new Efinix(spi, args.bit_file, args.file_type,
board->reset_pin, board->done_pin, board->oe_pin, board->reset_pin, board->done_pin, board->oe_pin,
args.verify, args.verbose); args.verify, args.verbose);
#else
printError("Support for Efinix FPGAs was not enabled at compile time");
return EXIT_FAILURE;
#endif
} else if (board->manufacturer == "lattice") { } else if (board->manufacturer == "lattice") {
if (board->fpga_part == "ice40") { if (board->fpga_part == "ice40") {
#ifdef ENABLE_ICE40_SUPPORT
target = new Ice40(spi, args.bit_file, args.file_type, target = new Ice40(spi, args.bit_file, args.file_type,
args.prg_type, args.prg_type,
board->reset_pin, board->done_pin, args.verify, args.verbose); board->reset_pin, board->done_pin, args.verify, args.verbose);
#else
printError("Support for ICE40 FPGAs was not enabled at compile time");
return EXIT_FAILURE;
#endif
} else if (board->fpga_part == "ecp5") { } else if (board->fpga_part == "ecp5") {
#ifdef ENABLE_LATTICESSPI_SUPPORT
target = new LatticeSSPI(spi, args.bit_file, args.file_type, args.verbose); target = new LatticeSSPI(spi, args.bit_file, args.file_type, args.verbose);
#else
printError("Support for Lattice FPGAs (SSPI mode) was not enabled at compile time");
return EXIT_FAILURE;
#endif
} else { } else {
printError("Error (SPI mode): " + board->fpga_part + printError("Error (SPI mode): " + board->fpga_part +
" is an unsupported/unknown Lattice Model"); " is an unsupported/unknown Lattice Model");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} else if (board->manufacturer == "colognechip") { } else if (board->manufacturer == "colognechip") {
#ifdef ENABLE_COLOGNECHIP_SUPPORT
target = new CologneChip(spi, args.bit_file, args.file_type, args.prg_type, target = new CologneChip(spi, args.bit_file, args.file_type, args.prg_type,
board->reset_pin, board->done_pin, DBUS6, board->oe_pin, board->reset_pin, board->done_pin, DBUS6, board->oe_pin,
args.verify, args.verbose); args.verify, args.verbose);
#else
printError("Support for Gowin FPGAs was not enabled at compile time");
return EXIT_FAILURE;
#endif
} else { } else {
printError("Error (SPI mode): " + board->manufacturer + printError("Error (SPI mode): " + board->manufacturer +
" is an unsupported/unknown target"); " is an unsupported/unknown target");
@ -474,7 +508,7 @@ int main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
#else #else
throw std::runtime_error("DFU support: disabled at build time"); printError("DFU support: disabled at build time");
return EXIT_FAILURE; return EXIT_FAILURE;
#endif #endif
} }
@ -612,33 +646,71 @@ int main(int argc, char **argv)
Device *fpga; Device *fpga;
try { try {
if (fab == "xilinx") { if (fab == "xilinx") {
#ifdef ENABLE_XILINX_SUPPORT
fpga = new Xilinx(jtag, args.bit_file, args.secondary_bit_file, fpga = new Xilinx(jtag, args.bit_file, args.secondary_bit_file,
args.file_type, args.prg_type, args.fpga_part, args.bridge_path, 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, args.target_flash, args.verify, args.verbose, args.skip_load_bridge, args.skip_reset,
args.read_dna, args.read_xadc); args.read_dna, args.read_xadc);
#else
printError("Support for Xilinx FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif
} else if (fab == "altera") { } else if (fab == "altera") {
#ifdef ENABLE_ALTERA_SUPPORT
fpga = new Altera(jtag, args.bit_file, args.file_type, fpga = new Altera(jtag, args.bit_file, args.file_type,
args.prg_type, args.fpga_part, args.bridge_path, args.verify, args.prg_type, args.fpga_part, args.bridge_path, args.verify,
args.verbose, args.flash_sector, args.skip_load_bridge, args.skip_reset); args.verbose, args.flash_sector, args.skip_load_bridge, args.skip_reset);
#else
printError("Support for Altera FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif
} else if (fab == "anlogic") { } else if (fab == "anlogic") {
#ifdef ENABLE_ANLOGIC_SUPPORT
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
printError("Support for Anlogic FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif
} else if (fab == "efinix") { } else if (fab == "efinix") {
#ifdef ENABLE_EFINIX_SUPPORT
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);
#else
printError("Support for Efinix FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif #endif
} else if (fab == "Gowin") { } else if (fab == "Gowin") {
#ifdef ENABLE_GOWIN_SUPPORT
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
printError("Support for Gowin FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif
} else if (fab == "lattice") { } else if (fab == "lattice") {
#ifdef ENABLE_LATTICE_SUPPORT
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
printError("Support for Lattice FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif
} else if (fab == "colognechip") { } else if (fab == "colognechip") {
#ifdef ENABLE_COLOGNECHIP_SUPPORT
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);
#else
printError("Support for Gowin FPGAs was not enabled at compile time");
delete(jtag);
return EXIT_FAILURE;
#endif #endif
} else { } else {
printError("Error: manufacturer " + fab + " not supported"); printError("Error: manufacturer " + fab + " not supported");