cmake,usbBlaster: add option to fix firmware path at build time

This commit is contained in:
Gwenhael Goavec-Merou 2023-03-05 23:20:16 +01:00
parent 5e63ac5782
commit d5f5593421
2 changed files with 11 additions and 3 deletions

View File

@ -21,6 +21,7 @@ else()
endif() endif()
option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON) option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON)
option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF) option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF)
set(BLASTERII_PATH "" CACHE STRING "usbBlasterII firmware directory")
set(ISE_PATH "/opt/Xilinx/14.7" CACHE STRING "ise root directory (default: /opt/Xilinx/14.7)") set(ISE_PATH "/opt/Xilinx/14.7" CACHE STRING "ise root directory (default: /opt/Xilinx/14.7)")
## specify the C++ standard ## specify the C++ standard
@ -41,6 +42,7 @@ include(GNUInstallDirs)
add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\") add_definitions(-DDATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\")
add_definitions(-DISE_DIR=\"${ISE_PATH}\") add_definitions(-DISE_DIR=\"${ISE_PATH}\")
add_definitions(-DBLASTERII_DIR=\"${BLASTERII_PATH}\")
if (USE_PKGCONFIG) if (USE_PKGCONFIG)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)

View File

@ -432,14 +432,20 @@ int UsbBlasterI::write(uint8_t *wr_buf, int wr_len,
UsbBlasterII::UsbBlasterII(const string &firmware_path) UsbBlasterII::UsbBlasterII(const string &firmware_path)
{ {
std::string fpath;
uint8_t buf[5]; uint8_t buf[5];
if (firmware_path.empty()) { if (firmware_path.empty() && BLASTERII_DIR == "") {
printError("missing FX2 firmware"); printError("missing FX2 firmware");
printError("use --probe-firmware with something"); printError("use --probe-firmware with something");
printError("like /opt/altera/quartus/linux64/blaster_6810.hex"); printError("like /opt/intelFPGA/VERSION/quartus/linux64/blaster_6810.hex");
printError("Or use -DBLASTERII_PATH=/opt/intelFPGA/VERSION/quartus/linux64");
throw std::runtime_error("usbBlasterII: missing firmware"); throw std::runtime_error("usbBlasterII: missing firmware");
} }
fx2 = new FX2_ll(0x09fb, 0x6810, 0x09fb, 0x6010, firmware_path); if (firmware_path.empty())
fpath = BLASTERII_DIR "/blaster_6810.hex";
else
fpath = firmware_path;
fx2 = new FX2_ll(0x09fb, 0x6810, 0x09fb, 0x6010, fpath);
if (!fx2->read_ctrl(0x94, 0, buf, 5)) { if (!fx2->read_ctrl(0x94, 0, buf, 5)) {
throw std::runtime_error("Unable to read firmware version."); throw std::runtime_error("Unable to read firmware version.");
} }