updated for python library.
This commit is contained in:
parent
4d3460eede
commit
f325c2ebca
514
CMakeLists.txt
514
CMakeLists.txt
|
|
@ -6,18 +6,18 @@ add_definitions(-DVERSION=\"v${PROJECT_VERSION}\")
|
||||||
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")
|
||||||
set(ENABLE_UDEV OFF)
|
set(ENABLE_UDEV OFF)
|
||||||
else()
|
else()
|
||||||
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON)
|
option(ENABLE_UDEV "use udev to search JTAG adapter from /dev/xx" ON)
|
||||||
endif()
|
endif()
|
||||||
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ON)
|
option(ENABLE_CMSISDAP "enable cmsis DAP interface (requires hidapi)" ON)
|
||||||
option(ENABLE_GOWIN_GWU2X "enable Gowin GWU2X interface" ON)
|
option(ENABLE_GOWIN_GWU2X "enable Gowin GWU2X interface" ON)
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
option(ENABLE_LIBGPIOD "enable libgpiod bitbang driver (requires libgpiod)" ON)
|
option(ENABLE_LIBGPIOD "enable libgpiod bitbang driver (requires libgpiod)" ON)
|
||||||
option(ENABLE_REMOTEBITBANG "enable remote bitbang driver" ON)
|
option(ENABLE_REMOTEBITBANG "enable remote bitbang driver" ON)
|
||||||
else()
|
else()
|
||||||
set(ENABLE_LIBGPIOD OFF)
|
set(ENABLE_LIBGPIOD OFF)
|
||||||
set(ENABLE_REMOTEBITBANG OFF)
|
set(ENABLE_REMOTEBITBANG OFF)
|
||||||
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)
|
||||||
|
|
@ -29,12 +29,12 @@ set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra ${CMAKE_CXX_FLAGS_DEBUG}")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
if(ENABLE_OPTIM AND NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
if(ENABLE_OPTIM AND NOT(CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||||
set(CMAKE_CXX_FLAGS "-O3 ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "-O3 ${CMAKE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (BUILD_STATIC)
|
if (BUILD_STATIC)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static ${CMAKE_EXE_LINKER_FLAGS}")
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
@ -45,290 +45,290 @@ add_definitions(-DISE_DIR=\"${ISE_PATH}\")
|
||||||
add_definitions(-DBLASTERII_DIR=\"${BLASTERII_PATH}\")
|
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)
|
pkg_check_modules(LIBFTDI REQUIRED libftdi1)
|
||||||
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
|
||||||
if (NOT HIDAPI_FOUND)
|
if (NOT HIDAPI_FOUND)
|
||||||
pkg_check_modules(HIDAPI hidapi-hidraw)
|
pkg_check_modules(HIDAPI hidapi-hidraw)
|
||||||
endif()
|
endif()
|
||||||
if (NOT HIDAPI_FOUND)
|
if (NOT HIDAPI_FOUND)
|
||||||
pkg_check_modules(HIDAPI hidapi)
|
pkg_check_modules(HIDAPI hidapi)
|
||||||
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)
|
||||||
# try zlib-ng
|
# try zlib-ng
|
||||||
pkg_check_modules(ZLIB zlib-ng)
|
pkg_check_modules(ZLIB zlib-ng)
|
||||||
if (ZLIB_FOUND)
|
if (ZLIB_FOUND)
|
||||||
add_definitions(-DHAS_ZLIBNG)
|
add_definitions(-DHAS_ZLIBNG)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Could find ZLIB")
|
message(FATAL_ERROR "Could find ZLIB")
|
||||||
endif()
|
endif()
|
||||||
endif(NOT ZLIB_FOUND)
|
endif(NOT ZLIB_FOUND)
|
||||||
|
|
||||||
if (ENABLE_UDEV)
|
if (ENABLE_UDEV)
|
||||||
pkg_check_modules(LIBUDEV libudev)
|
pkg_check_modules(LIBUDEV libudev)
|
||||||
if (LIBUDEV_FOUND)
|
if (LIBUDEV_FOUND)
|
||||||
add_definitions(-DUSE_UDEV)
|
add_definitions(-DUSE_UDEV)
|
||||||
else()
|
else()
|
||||||
message("libudev not found, disabling udev support and -D parameter")
|
message("libudev not found, disabling udev support and -D parameter")
|
||||||
set(ENABLE_UDEV OFF)
|
set(ENABLE_UDEV OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_LIBGPIOD)
|
if (ENABLE_LIBGPIOD)
|
||||||
pkg_check_modules(LIBGPIOD libgpiod)
|
pkg_check_modules(LIBGPIOD libgpiod)
|
||||||
if (NOT LIBGPIOD_FOUND)
|
if (NOT LIBGPIOD_FOUND)
|
||||||
message("libgpiod not found, disabling gpiod support")
|
message("libgpiod not found, disabling gpiod support")
|
||||||
set(ENABLE_LIBGPIOD OFF)
|
set(ENABLE_LIBGPIOD OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(OPENFPGALOADER_SOURCE
|
set(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/ch552_jtag.cpp
|
||||||
src/common.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/efinix.cpp
|
||||||
src/efinixHexParser.cpp
|
src/efinixHexParser.cpp
|
||||||
src/fx2_ll.cpp
|
src/fx2_ll.cpp
|
||||||
src/ihexParser.cpp
|
src/ihexParser.cpp
|
||||||
src/pofParser.cpp
|
src/pofParser.cpp
|
||||||
src/rawParser.cpp
|
src/rawParser.cpp
|
||||||
src/spiFlash.cpp
|
src/spiFlash.cpp
|
||||||
src/spiInterface.cpp
|
src/spiInterface.cpp
|
||||||
src/usbBlaster.cpp
|
src/usbBlaster.cpp
|
||||||
src/epcq.cpp
|
src/epcq.cpp
|
||||||
src/svf_jtag.cpp
|
src/svf_jtag.cpp
|
||||||
src/display.cpp
|
src/display.cpp
|
||||||
src/jtag.cpp
|
src/jtag.cpp
|
||||||
src/ftdiJtagBitbang.cpp
|
src/ftdiJtagBitbang.cpp
|
||||||
src/ftdiJtagMPSSE.cpp
|
src/ftdiJtagMPSSE.cpp
|
||||||
src/configBitstreamParser.cpp
|
src/configBitstreamParser.cpp
|
||||||
src/ftdipp_mpsse.cpp
|
src/ftdipp_mpsse.cpp
|
||||||
src/main.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/progressBar.cpp
|
||||||
src/fsparser.cpp
|
src/fsparser.cpp
|
||||||
src/mcsParser.cpp
|
src/mcsParser.cpp
|
||||||
src/ftdispi.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/colognechip.cpp
|
||||||
src/colognechipCfgParser.cpp
|
src/colognechipCfgParser.cpp
|
||||||
src/esp_usb_jtag.cpp
|
src/esp_usb_jtag.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(OPENFPGALOADER_HEADERS
|
set(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/ch552_jtag.hpp
|
||||||
src/common.hpp
|
src/common.hpp
|
||||||
src/cxxopts.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/efinix.hpp
|
||||||
src/efinixHexParser.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/progressBar.hpp
|
||||||
src/rawParser.hpp
|
src/rawParser.hpp
|
||||||
src/usbBlaster.hpp
|
src/usbBlaster.hpp
|
||||||
src/bitparser.hpp
|
src/bitparser.hpp
|
||||||
src/ftdiJtagBitbang.hpp
|
src/ftdiJtagBitbang.hpp
|
||||||
src/ftdiJtagMPSSE.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/part.hpp
|
||||||
src/board.hpp
|
src/board.hpp
|
||||||
src/display.hpp
|
src/display.hpp
|
||||||
src/mcsParser.hpp
|
src/mcsParser.hpp
|
||||||
src/ftdipp_mpsse.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/device.hpp
|
||||||
src/gowin.hpp
|
src/gowin.hpp
|
||||||
src/cable.hpp
|
src/cable.hpp
|
||||||
src/ftdispi.hpp
|
src/ftdispi.hpp
|
||||||
src/xilinx.hpp
|
src/xilinx.hpp
|
||||||
src/xilinxMapParser.hpp
|
src/xilinxMapParser.hpp
|
||||||
src/colognechip.hpp
|
src/colognechip.hpp
|
||||||
src/colognechipCfgParser.hpp
|
src/colognechipCfgParser.hpp
|
||||||
src/esp_usb_jtag.hpp
|
src/esp_usb_jtag.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Lattice Drivers / Files parsers.
|
# Lattice Drivers / Files parsers.
|
||||||
list(APPEND OPENFPGALOADER_SOURCE
|
list(APPEND OPENFPGALOADER_SOURCE
|
||||||
src/ice40.cpp
|
src/ice40.cpp
|
||||||
src/lattice.cpp
|
src/lattice.cpp
|
||||||
src/latticeSSPI.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/ice40.hpp
|
||||||
src/lattice.hpp
|
src/lattice.hpp
|
||||||
src/latticeSSPI.hpp
|
src/latticeSSPI.hpp
|
||||||
src/jedParser.hpp
|
src/jedParser.hpp
|
||||||
src/feaparser.hpp
|
src/feaparser.hpp
|
||||||
src/latticeBitParser.hpp
|
src/latticeBitParser.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
link_directories(
|
link_directories(
|
||||||
${LIBUSB_LIBRARY_DIRS}
|
${LIBUSB_LIBRARY_DIRS}
|
||||||
${LIBFTDI_LIBRARY_DIRS}
|
${LIBFTDI_LIBRARY_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (ENABLE_LIBGPIOD)
|
if (ENABLE_LIBGPIOD)
|
||||||
link_directories(${LIBGPIOD_LIBRARY_DIRS})
|
link_directories(${LIBGPIOD_LIBRARY_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_CMSISDAP AND HIDAPI_FOUND)
|
if (ENABLE_CMSISDAP AND HIDAPI_FOUND)
|
||||||
link_directories(${HIDAPI_LIBRARY_DIRS})
|
link_directories(${HIDAPI_LIBRARY_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(openFPGALoader
|
add_executable(openFPGALoader
|
||||||
${OPENFPGALOADER_SOURCE}
|
${OPENFPGALOADER_SOURCE}
|
||||||
${OPENFPGALOADER_HEADERS}
|
${OPENFPGALOADER_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${LIBUSB_INCLUDE_DIRS}
|
${LIBUSB_INCLUDE_DIRS}
|
||||||
${LIBFTDI_INCLUDE_DIRS}
|
${LIBFTDI_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(openFPGALoader
|
target_link_libraries(openFPGALoader
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${LIBFTDI_LIBRARIES}
|
${LIBFTDI_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Gowin GWU2X JTAG interface
|
# Gowin GWU2X JTAG interface
|
||||||
if(ENABLE_GOWIN_GWU2X)
|
if(ENABLE_GOWIN_GWU2X)
|
||||||
target_sources(openFPGALoader PRIVATE src/gwu2x_jtag.cpp)
|
target_sources(openFPGALoader PRIVATE src/gwu2x_jtag.cpp)
|
||||||
list (APPEND OPENFPGALOADER_HEADERS src/gwu2x_jtag.hpp)
|
list (APPEND OPENFPGALOADER_HEADERS src/gwu2x_jtag.hpp)
|
||||||
add_definitions(-DENABLE_GOWIN_GWU2X=1)
|
add_definitions(-DENABLE_GOWIN_GWU2X=1)
|
||||||
message("Gowin GWU2X support enabled")
|
message("Gowin GWU2X support enabled")
|
||||||
else()
|
else()
|
||||||
message("Gowin GWU2X support disabled")
|
message("Gowin GWU2X support disabled")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
# winsock provides ntohs
|
# winsock provides ntohs
|
||||||
target_link_libraries(openFPGALoader ws2_32)
|
target_link_libraries(openFPGALoader ws2_32)
|
||||||
|
|
||||||
target_sources(openFPGALoader PRIVATE src/pathHelper.cpp)
|
target_sources(openFPGALoader PRIVATE src/pathHelper.cpp)
|
||||||
list(APPEND OPENFPGALOADER_HEADERS src/pathHelper.hpp)
|
list(APPEND OPENFPGALOADER_HEADERS src/pathHelper.hpp)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libusb_attach_kernel_driver is only available on Linux.
|
# libusb_attach_kernel_driver is only available on Linux.
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
add_definitions(-DATTACH_KERNEL)
|
add_definitions(-DATTACH_KERNEL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_UDEV)
|
if (ENABLE_UDEV)
|
||||||
include_directories(${LIBUDEV_INCLUDE_DIRS})
|
include_directories(${LIBUDEV_INCLUDE_DIRS})
|
||||||
target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES})
|
target_link_libraries(openFPGALoader ${LIBUDEV_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_LIBGPIOD)
|
if (ENABLE_LIBGPIOD)
|
||||||
include_directories(${LIBGPIOD_INCLUDE_DIRS})
|
include_directories(${LIBGPIOD_INCLUDE_DIRS})
|
||||||
target_link_libraries(openFPGALoader ${LIBGPIOD_LIBRARIES})
|
target_link_libraries(openFPGALoader ${LIBGPIOD_LIBRARIES})
|
||||||
add_definitions(-DENABLE_LIBGPIOD=1)
|
add_definitions(-DENABLE_LIBGPIOD=1)
|
||||||
target_sources(openFPGALoader PRIVATE src/libgpiodJtagBitbang.cpp)
|
target_sources(openFPGALoader PRIVATE src/libgpiodJtagBitbang.cpp)
|
||||||
list (APPEND OPENFPGALOADER_HEADERS src/libgpiodJtagBitbang.hpp)
|
list (APPEND OPENFPGALOADER_HEADERS src/libgpiodJtagBitbang.hpp)
|
||||||
if (LIBGPIOD_VERSION VERSION_GREATER_EQUAL 2)
|
if (LIBGPIOD_VERSION VERSION_GREATER_EQUAL 2)
|
||||||
message("libgpiod v2 support enabled")
|
message("libgpiod v2 support enabled")
|
||||||
add_definitions(-DGPIOD_APIV2)
|
add_definitions(-DGPIOD_APIV2)
|
||||||
else()
|
else()
|
||||||
message("libgpiod v1 support enabled")
|
message("libgpiod v1 support enabled")
|
||||||
endif()
|
endif()
|
||||||
endif(ENABLE_LIBGPIOD)
|
endif(ENABLE_LIBGPIOD)
|
||||||
|
|
||||||
if (ENABLE_JETSONNANOGPIO)
|
if (ENABLE_JETSONNANOGPIO)
|
||||||
add_definitions(-DENABLE_JETSONNANOGPIO=1)
|
add_definitions(-DENABLE_JETSONNANOGPIO=1)
|
||||||
target_sources(openFPGALoader PRIVATE src/jetsonNanoJtagBitbang.cpp)
|
target_sources(openFPGALoader PRIVATE src/jetsonNanoJtagBitbang.cpp)
|
||||||
list (APPEND OPENFPGALOADER_HEADERS src/jetsonNanoJtagBitbang.hpp)
|
list (APPEND OPENFPGALOADER_HEADERS src/jetsonNanoJtagBitbang.hpp)
|
||||||
message("Jetson Nano GPIO support enabled")
|
message("Jetson Nano GPIO support enabled")
|
||||||
endif(ENABLE_JETSONNANOGPIO)
|
endif(ENABLE_JETSONNANOGPIO)
|
||||||
|
|
||||||
if (ENABLE_UDEV OR ENABLE_LIBGPIOD OR ENABLE_JETSONNANOGPIO)
|
if (ENABLE_UDEV OR ENABLE_LIBGPIOD OR ENABLE_JETSONNANOGPIO)
|
||||||
add_definitions(-DUSE_DEVICE_ARG)
|
add_definitions(-DUSE_DEVICE_ARG)
|
||||||
endif(ENABLE_UDEV OR ENABLE_LIBGPIOD OR ENABLE_JETSONNANOGPIO)
|
endif(ENABLE_UDEV OR ENABLE_LIBGPIOD OR ENABLE_JETSONNANOGPIO)
|
||||||
|
|
||||||
if (BUILD_STATIC)
|
if (BUILD_STATIC)
|
||||||
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
|
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_CMSISDAP)
|
if (ENABLE_CMSISDAP)
|
||||||
if (HIDAPI_FOUND)
|
if (HIDAPI_FOUND)
|
||||||
include_directories(${HIDAPI_INCLUDE_DIRS})
|
include_directories(${HIDAPI_INCLUDE_DIRS})
|
||||||
target_link_libraries(openFPGALoader ${HIDAPI_LIBRARIES})
|
target_link_libraries(openFPGALoader ${HIDAPI_LIBRARIES})
|
||||||
add_definitions(-DENABLE_CMSISDAP=1)
|
add_definitions(-DENABLE_CMSISDAP=1)
|
||||||
target_sources(openFPGALoader PRIVATE src/cmsisDAP.cpp)
|
target_sources(openFPGALoader PRIVATE src/cmsisDAP.cpp)
|
||||||
list (APPEND OPENFPGALOADER_HEADERS src/cmsisDAP.hpp)
|
list (APPEND OPENFPGALOADER_HEADERS src/cmsisDAP.hpp)
|
||||||
message("cmsis_dap support enabled")
|
message("cmsis_dap support enabled")
|
||||||
else()
|
else()
|
||||||
message("hidapi-libusb not found: cmsis_dap support disabled")
|
message("hidapi-libusb not found: cmsis_dap support disabled")
|
||||||
endif()
|
endif()
|
||||||
endif(ENABLE_CMSISDAP)
|
endif(ENABLE_CMSISDAP)
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
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)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "-pthread ${CMAKE_EXE_LINKER_FLAGS}")
|
set(CMAKE_EXE_LINKER_FLAGS "-pthread ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
message("Xilinx Virtual Server support enabled")
|
message("Xilinx Virtual Server support enabled")
|
||||||
else()
|
else()
|
||||||
message("Xilinx Virtual Server support disabled")
|
message("Xilinx Virtual Server support disabled")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_REMOTEBITBANG)
|
if (ENABLE_REMOTEBITBANG)
|
||||||
add_definitions(-DENABLE_REMOTEBITBANG=1)
|
add_definitions(-DENABLE_REMOTEBITBANG=1)
|
||||||
target_sources(openFPGALoader PRIVATE src/remoteBitbang_client.cpp)
|
target_sources(openFPGALoader PRIVATE src/remoteBitbang_client.cpp)
|
||||||
list (APPEND OPENFPGALOADER_HEADERS src/remoteBitbang_client.hpp)
|
list (APPEND OPENFPGALOADER_HEADERS src/remoteBitbang_client.hpp)
|
||||||
message("Remote bitbang client support enabled")
|
message("Remote bitbang client support enabled")
|
||||||
else()
|
else()
|
||||||
message("Remote bitbang client support disabled")
|
message("Remote bitbang client support disabled")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ZLIB_FOUND)
|
if (ZLIB_FOUND)
|
||||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||||
target_link_libraries(openFPGALoader ${ZLIB_LIBRARIES})
|
target_link_libraries(openFPGALoader ${ZLIB_LIBRARIES})
|
||||||
add_definitions(-DHAS_ZLIB=1)
|
add_definitions(-DHAS_ZLIB=1)
|
||||||
else()
|
else()
|
||||||
message("zlib library not found: can't flash intel/altera devices")
|
message("zlib library not found: can't flash intel/altera devices")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LINK_CMAKE_THREADS)
|
if (LINK_CMAKE_THREADS)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(openFPGALoader Threads::Threads)
|
target_link_libraries(openFPGALoader Threads::Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# libftdi < 1.4 as no usb_addr
|
# libftdi < 1.4 as no usb_addr
|
||||||
|
|
@ -350,34 +350,74 @@ list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||||
include(FindGZIP)
|
include(FindGZIP)
|
||||||
|
|
||||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND GZIP_PRG)
|
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND GZIP_PRG)
|
||||||
set(SPIOVERJTAG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/spiOverJtag")
|
set(SPIOVERJTAG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/spiOverJtag")
|
||||||
file(GLOB BITS_FILES RELATIVE ${SPIOVERJTAG_DIR} spiOverJtag/spiOverJtag_*.bit)
|
file(GLOB BITS_FILES RELATIVE ${SPIOVERJTAG_DIR} spiOverJtag/spiOverJtag_*.bit)
|
||||||
file(GLOB RBF_FILES RELATIVE ${SPIOVERJTAG_DIR} spiOverJtag/spiOverJtag_*.rbf)
|
file(GLOB RBF_FILES RELATIVE ${SPIOVERJTAG_DIR} spiOverJtag/spiOverJtag_*.rbf)
|
||||||
|
|
||||||
STRING(REGEX REPLACE ".bit" ".bit.gz" BIT_GZ_FILES "${BITS_FILES}")
|
STRING(REGEX REPLACE ".bit" ".bit.gz" BIT_GZ_FILES "${BITS_FILES}")
|
||||||
STRING(REGEX REPLACE ".rbf" ".rbf.gz" RBF_GZ_FILES "${RBF_FILES}")
|
STRING(REGEX REPLACE ".rbf" ".rbf.gz" RBF_GZ_FILES "${RBF_FILES}")
|
||||||
|
|
||||||
FOREACH(bit ${BITS_FILES} ${RBF_FILES})
|
FOREACH(bit ${BITS_FILES} ${RBF_FILES})
|
||||||
ADD_CUSTOM_COMMAND(OUTPUT ${bit}.gz
|
ADD_CUSTOM_COMMAND(OUTPUT ${bit}.gz
|
||||||
COMMAND ${GZIP_PRG} -9 -c ${bit} > ${CMAKE_CURRENT_BINARY_DIR}/${bit}.gz
|
COMMAND ${GZIP_PRG} -9 -c ${bit} > ${CMAKE_CURRENT_BINARY_DIR}/${bit}.gz
|
||||||
DEPENDS ${SPIOVERJTAG_DIR}/${bit}
|
DEPENDS ${SPIOVERJTAG_DIR}/${bit}
|
||||||
WORKING_DIRECTORY ${SPIOVERJTAG_DIR}
|
WORKING_DIRECTORY ${SPIOVERJTAG_DIR}
|
||||||
COMMENT "Building ${bit}.gz")
|
COMMENT "Building ${bit}.gz")
|
||||||
list(APPEND GZ_FILES ${CMAKE_CURRENT_BINARY_DIR}/${bit}.gz)
|
list(APPEND GZ_FILES ${CMAKE_CURRENT_BINARY_DIR}/${bit}.gz)
|
||||||
ENDFOREACH(bit)
|
ENDFOREACH(bit)
|
||||||
|
|
||||||
ADD_CUSTOM_TARGET(bit ALL DEPENDS ${BIT_GZ_FILES} ${RBF_GZ_FILES})
|
ADD_CUSTOM_TARGET(bit ALL DEPENDS ${BIT_GZ_FILES} ${RBF_GZ_FILES})
|
||||||
else()
|
else()
|
||||||
file(GLOB BITS_FILES spiOverJtag/spiOverJtag_*.bit)
|
file(GLOB BITS_FILES spiOverJtag/spiOverJtag_*.bit)
|
||||||
file(GLOB RBF_FILES spiOverJtag/spiOverJtag_*.rbf)
|
file(GLOB RBF_FILES spiOverJtag/spiOverJtag_*.rbf)
|
||||||
install(FILES
|
install(FILES
|
||||||
${BITS_FILES}
|
${BITS_FILES}
|
||||||
${RBF_FILES}
|
${RBF_FILES}
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
${GZ_FILES}
|
${GZ_FILES}
|
||||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
|
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/openFPGALoader
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Python bindings support
|
||||||
|
option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
|
||||||
|
|
||||||
|
if(BUILD_PYTHON_BINDINGS)
|
||||||
|
find_package(Python COMPONENTS Interpreter Development REQUIRED)
|
||||||
|
find_package(pybind11 CONFIG REQUIRED)
|
||||||
|
|
||||||
|
pybind11_add_module(_openfpgaloader python/bindings.cpp
|
||||||
|
${OPENFPGALOADER_SOURCE}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(_openfpgaloader PRIVATE
|
||||||
|
${LIBUSB_INCLUDE_DIRS}
|
||||||
|
${LIBFTDI_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(_openfpgaloader PRIVATE
|
||||||
|
${LIBUSB_LIBRARIES}
|
||||||
|
${LIBFTDI_LIBRARIES}
|
||||||
|
${ZLIB_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (ENABLE_UDEV)
|
||||||
|
target_link_libraries(_openfpgaloader PRIVATE ${LIBUDEV_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_CMSISDAP AND HIDAPI_FOUND)
|
||||||
|
target_link_libraries(_openfpgaloader PRIVATE ${HIDAPI_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_LIBGPIOD)
|
||||||
|
target_link_libraries(_openfpgaloader PRIVATE ${LIBGPIOD_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS _openfpgaloader
|
||||||
|
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/openfpgaloader
|
||||||
|
COMPONENT python
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -31,6 +31,16 @@ Also checkout the vendor-specific documentation:
|
||||||
|
|
||||||
OpenFPGALoader has a dedicated channel: [#openFPGALoader at libera.chat](https://web.libera.chat/#openFPGALoader).
|
OpenFPGALoader has a dedicated channel: [#openFPGALoader at libera.chat](https://web.libera.chat/#openFPGALoader).
|
||||||
|
|
||||||
|
## Python Bindings
|
||||||
|
|
||||||
|
openFPGALoader can be used from Python! Install via pip:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install openfpgaloader
|
||||||
|
```
|
||||||
|
|
||||||
|
See the [Python README](python/README.md) for usage examples.
|
||||||
|
|
||||||
## Building with Pixi
|
## Building with Pixi
|
||||||
|
|
||||||
This project supports [Pixi](https://pixi.sh) for cross-platform dependency management and building.
|
This project supports [Pixi](https://pixi.sh) for cross-platform dependency management and building.
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Example usage of openFPGALoader Python bindings
|
||||||
|
"""
|
||||||
|
|
||||||
|
import openfpgaloader as ofl
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("openFPGALoader Python Bindings Example")
|
||||||
|
print(f"Version: {ofl.__version__}\n")
|
||||||
|
|
||||||
|
# List supported boards
|
||||||
|
boards = ofl.list_boards()
|
||||||
|
print(f"Total supported boards: {len(boards)}")
|
||||||
|
print(f"First 10 boards: {boards[:10]}\n")
|
||||||
|
|
||||||
|
# List supported cables
|
||||||
|
cables = ofl.list_cables()
|
||||||
|
print(f"Total supported cables: {len(cables)}")
|
||||||
|
print(f"First 10 cables: {cables[:10]}\n")
|
||||||
|
|
||||||
|
# List supported FPGAs
|
||||||
|
fpgas = ofl.list_fpgas()
|
||||||
|
print(f"Total supported FPGAs: {len(fpgas)}")
|
||||||
|
print(f"First 10 FPGAs: {fpgas[:10]}\n")
|
||||||
|
|
||||||
|
# Create an OpenFPGALoader instance
|
||||||
|
print("Creating OpenFPGALoader instance for Arty board...")
|
||||||
|
loader = ofl.OpenFPGALoader(board="arty", verbose=0)
|
||||||
|
print("Instance created successfully!\n")
|
||||||
|
|
||||||
|
# Example of how to use the loader (would need actual bitstream file)
|
||||||
|
# loader.program_sram("my_design.bit")
|
||||||
|
# loader.program_flash("my_design.bit", offset=0)
|
||||||
|
|
||||||
|
# Using convenience function
|
||||||
|
# ofl.load_bitstream("my_design.bit", board="arty", to_flash=False)
|
||||||
|
|
||||||
|
# ofl.load_bitstream("my_design.bit", board="arty", to_flash=False)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
13
pixi.toml
13
pixi.toml
|
|
@ -14,6 +14,10 @@ libftdi = "*"
|
||||||
libusb = ">=1.0"
|
libusb = ">=1.0"
|
||||||
zlib = "*"
|
zlib = "*"
|
||||||
libhidapi = "*"
|
libhidapi = "*"
|
||||||
|
python = ">=3.8"
|
||||||
|
pybind11 = "*"
|
||||||
|
scikit-build-core = "*"
|
||||||
|
pip = "*"
|
||||||
|
|
||||||
[target.linux-64.dependencies]
|
[target.linux-64.dependencies]
|
||||||
libudev = "*"
|
libudev = "*"
|
||||||
|
|
@ -48,15 +52,18 @@ list-fpga = { cmd = "./build/openFPGALoader --list-fpga", depends-on = ["build"]
|
||||||
all = { depends-on = ["build", "test"] }
|
all = { depends-on = ["build", "test"] }
|
||||||
rebuild = { depends-on = ["clean", "build"] }
|
rebuild = { depends-on = ["clean", "build"] }
|
||||||
|
|
||||||
|
# Python wheel tasks
|
||||||
|
build-python = "cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON_BINDINGS=ON && cmake --build build"
|
||||||
|
build-wheel = "python -m pip wheel . --no-deps -w dist"
|
||||||
|
install-wheel = "python -m pip install dist/*.whl --force-reinstall"
|
||||||
|
test-python = "python -c 'import openfpgaloader; print(openfpgaloader.__version__)'"
|
||||||
|
|
||||||
[feature.dev.dependencies]
|
[feature.dev.dependencies]
|
||||||
|
|
||||||
[feature.dev.target.linux-64.dependencies]
|
[feature.dev.target.linux-64.dependencies]
|
||||||
gdb = "*"
|
gdb = "*"
|
||||||
valgrind = "*"
|
valgrind = "*"
|
||||||
|
|
||||||
[feature.dev.target.osx-64.dependencies]
|
|
||||||
gdb = "*"
|
|
||||||
|
|
||||||
[feature.dev.target.osx-arm64.dependencies]
|
[feature.dev.target.osx-arm64.dependencies]
|
||||||
gdb = "*"
|
gdb = "*"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["scikit-build-core", "pybind11"]
|
||||||
|
build-backend = "scikit_build_core.build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "openfpgaloader"
|
||||||
|
version = "1.0.0"
|
||||||
|
description = "Python bindings for openFPGALoader - Universal FPGA programming tool"
|
||||||
|
readme = "python/README.md"
|
||||||
|
authors = [
|
||||||
|
{name = "Gwenhael Goavec-Merou", email = "gwenhael.goavec-merou@trabucayre.com"}
|
||||||
|
]
|
||||||
|
license = {text = "Apache-2.0"}
|
||||||
|
classifiers = [
|
||||||
|
"Development Status :: 4 - Beta",
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"License :: OSI Approved :: Apache Software License",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.8",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Programming Language :: C++",
|
||||||
|
"Topic :: Software Development",
|
||||||
|
"Topic :: System :: Hardware",
|
||||||
|
]
|
||||||
|
requires-python = ">=3.8"
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
[project.urls]
|
||||||
|
Homepage = "https://github.com/trabucayre/openFPGALoader"
|
||||||
|
Documentation = "https://trabucayre.github.io/openFPGALoader"
|
||||||
|
Repository = "https://github.com/trabucayre/openFPGALoader"
|
||||||
|
Issues = "https://github.com/trabucayre/openFPGALoader/issues"
|
||||||
|
|
||||||
|
[tool.scikit-build]
|
||||||
|
minimum-version = "0.8"
|
||||||
|
build-dir = "build/{wheel_tag}"
|
||||||
|
cmake.build-type = "Release"
|
||||||
|
wheel.packages = ["python/openfpgaloader"]
|
||||||
|
|
||||||
|
[tool.scikit-build.cmake.define]
|
||||||
|
BUILD_PYTHON_BINDINGS = "ON"
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
# openFPGALoader Python Bindings
|
||||||
|
|
||||||
|
Python bindings for openFPGALoader - Universal utility for programming FPGAs.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install openfpgaloader
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```python
|
||||||
|
import openfpgaloader as ofl
|
||||||
|
|
||||||
|
# List supported boards
|
||||||
|
boards = ofl.list_boards()
|
||||||
|
print(f"Supported boards: {boards[:5]}")
|
||||||
|
|
||||||
|
# List supported cables
|
||||||
|
cables = ofl.list_cables()
|
||||||
|
print(f"Supported cables: {cables[:5]}")
|
||||||
|
|
||||||
|
# Detect connected FPGA
|
||||||
|
detected = ofl.detect_fpga()
|
||||||
|
|
||||||
|
# Load bitstream to SRAM
|
||||||
|
ofl.load_bitstream("my_design.bit", board="arty")
|
||||||
|
|
||||||
|
# Load bitstream to Flash
|
||||||
|
ofl.load_bitstream("my_design.bit", board="arty", to_flash=True)
|
||||||
|
|
||||||
|
# Using the class interface
|
||||||
|
loader = ofl.OpenFPGALoader(board="arty", verbose=1)
|
||||||
|
loader.program_sram("my_design.bit")
|
||||||
|
loader.program_flash("my_design.bit", offset=0)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building from Source
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using pixi (recommended)
|
||||||
|
pixi run build-wheel
|
||||||
|
|
||||||
|
# Or using pip
|
||||||
|
pip install .
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Apache-2.0
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
/*
|
||||||
|
* Python bindings for openFPGALoader
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
|
#include <pybind11/functional.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "../src/board.hpp"
|
||||||
|
#include "../src/cable.hpp"
|
||||||
|
#include "../src/part.hpp"
|
||||||
|
#include "../src/device.hpp"
|
||||||
|
#include "../src/jtag.hpp"
|
||||||
|
#include "../src/spiFlash.hpp"
|
||||||
|
|
||||||
|
namespace py = pybind11;
|
||||||
|
|
||||||
|
class OpenFPGALoader {
|
||||||
|
public:
|
||||||
|
OpenFPGALoader(const std::string& board_name = "",
|
||||||
|
const std::string& cable_name = "",
|
||||||
|
int verbose = 0)
|
||||||
|
: board_name_(board_name), cable_name_(cable_name), verbose_(verbose) {}
|
||||||
|
|
||||||
|
bool program_sram(const std::string& bitstream_file) {
|
||||||
|
// Implementation would integrate with the existing Device classes
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool program_flash(const std::string& bitstream_file, unsigned int offset = 0) {
|
||||||
|
// Implementation would integrate with the existing Device classes
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool detect() {
|
||||||
|
// Implementation would integrate with JTAG detection
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string board_name_;
|
||||||
|
std::string cable_name_;
|
||||||
|
int verbose_;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper functions to expose list commands
|
||||||
|
std::vector<std::string> list_boards() {
|
||||||
|
std::vector<std::string> boards;
|
||||||
|
for (const auto& board : board_list) {
|
||||||
|
boards.push_back(board.first);
|
||||||
|
}
|
||||||
|
return boards;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> list_cables() {
|
||||||
|
std::vector<std::string> cables;
|
||||||
|
for (const auto& cable : cable_list) {
|
||||||
|
cables.push_back(cable.first);
|
||||||
|
}
|
||||||
|
return cables;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> list_fpgas() {
|
||||||
|
std::vector<std::string> fpgas;
|
||||||
|
for (const auto& fpga : fpga_list) {
|
||||||
|
fpgas.push_back(fpga.second.model);
|
||||||
|
}
|
||||||
|
return fpgas;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simple convenience functions
|
||||||
|
bool load_bitstream(const std::string& bitstream_file,
|
||||||
|
const std::string& board = "",
|
||||||
|
const std::string& cable = "",
|
||||||
|
bool to_flash = false,
|
||||||
|
unsigned int offset = 0,
|
||||||
|
int verbose = 0) {
|
||||||
|
OpenFPGALoader loader(board, cable, verbose);
|
||||||
|
if (to_flash) {
|
||||||
|
return loader.program_flash(bitstream_file, offset);
|
||||||
|
} else {
|
||||||
|
return loader.program_sram(bitstream_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool detect_fpga(const std::string& cable = "", int verbose = 0) {
|
||||||
|
OpenFPGALoader loader("", cable, verbose);
|
||||||
|
return loader.detect();
|
||||||
|
}
|
||||||
|
|
||||||
|
PYBIND11_MODULE(_openfpgaloader, m) {
|
||||||
|
m.doc() = "Python bindings for openFPGALoader";
|
||||||
|
|
||||||
|
// Main class
|
||||||
|
py::class_<OpenFPGALoader>(m, "OpenFPGALoader")
|
||||||
|
.def(py::init<const std::string&, const std::string&, int>(),
|
||||||
|
py::arg("board") = "",
|
||||||
|
py::arg("cable") = "",
|
||||||
|
py::arg("verbose") = 0)
|
||||||
|
.def("program_sram", &OpenFPGALoader::program_sram,
|
||||||
|
py::arg("bitstream_file"),
|
||||||
|
"Program FPGA SRAM with bitstream")
|
||||||
|
.def("program_flash", &OpenFPGALoader::program_flash,
|
||||||
|
py::arg("bitstream_file"),
|
||||||
|
py::arg("offset") = 0,
|
||||||
|
"Program FPGA flash with bitstream")
|
||||||
|
.def("detect", &OpenFPGALoader::detect,
|
||||||
|
"Detect connected FPGA");
|
||||||
|
|
||||||
|
// Convenience functions
|
||||||
|
m.def("load_bitstream", &load_bitstream,
|
||||||
|
py::arg("bitstream_file"),
|
||||||
|
py::arg("board") = "",
|
||||||
|
py::arg("cable") = "",
|
||||||
|
py::arg("to_flash") = false,
|
||||||
|
py::arg("offset") = 0,
|
||||||
|
py::arg("verbose") = 0,
|
||||||
|
"Load a bitstream to FPGA SRAM or Flash");
|
||||||
|
|
||||||
|
m.def("detect_fpga", &detect_fpga,
|
||||||
|
py::arg("cable") = "",
|
||||||
|
py::arg("verbose") = 0,
|
||||||
|
"Detect connected FPGA");
|
||||||
|
|
||||||
|
m.def("list_boards", &list_boards,
|
||||||
|
"List all supported boards");
|
||||||
|
|
||||||
|
m.def("list_cables", &list_cables,
|
||||||
|
"List all supported cables");
|
||||||
|
|
||||||
|
m.def("list_fpgas", &list_fpgas,
|
||||||
|
"List all supported FPGAs");
|
||||||
|
|
||||||
|
m.attr("__version__") = "1.0.0";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Example usage of openFPGALoader Python bindings
|
||||||
|
"""
|
||||||
|
|
||||||
|
import openfpgaloader as ofl
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("openFPGALoader Python Bindings Example")
|
||||||
|
print(f"Version: {ofl.__version__}\n")
|
||||||
|
|
||||||
|
# List supported boards
|
||||||
|
boards = ofl.list_boards()
|
||||||
|
print(f"Total supported boards: {len(boards)}")
|
||||||
|
print(f"First 10 boards: {boards[:10]}\n")
|
||||||
|
|
||||||
|
# List supported cables
|
||||||
|
cables = ofl.list_cables()
|
||||||
|
print(f"Total supported cables: {len(cables)}")
|
||||||
|
print(f"First 10 cables: {cables[:10]}\n")
|
||||||
|
|
||||||
|
# List supported FPGAs
|
||||||
|
fpgas = ofl.list_fpgas()
|
||||||
|
print(f"Total supported FPGAs: {len(fpgas)}")
|
||||||
|
print(f"First 10 FPGAs: {fpgas[:10]}\n")
|
||||||
|
|
||||||
|
# Create an OpenFPGALoader instance
|
||||||
|
print("Creating OpenFPGALoader instance for Arty board...")
|
||||||
|
loader = ofl.OpenFPGALoader(board="arty", verbose=0)
|
||||||
|
print("Instance created successfully!\n")
|
||||||
|
|
||||||
|
# Example of how to use the loader (would need actual bitstream file)
|
||||||
|
# loader.program_sram("my_design.bit")
|
||||||
|
# loader.program_flash("my_design.bit", offset=0)
|
||||||
|
|
||||||
|
# Using convenience function
|
||||||
|
# ofl.load_bitstream("my_design.bit", board="arty", to_flash=False)
|
||||||
|
|
||||||
|
# ofl.load_bitstream("my_design.bit", board="arty", to_flash=False)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
"""
|
||||||
|
openFPGALoader Python bindings
|
||||||
|
|
||||||
|
Python wrapper for the openFPGALoader library.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from ._openfpgaloader import (
|
||||||
|
load_bitstream,
|
||||||
|
detect_fpga,
|
||||||
|
list_boards,
|
||||||
|
list_cables,
|
||||||
|
list_fpgas,
|
||||||
|
OpenFPGALoader,
|
||||||
|
)
|
||||||
|
|
||||||
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"load_bitstream",
|
||||||
|
"detect_fpga",
|
||||||
|
"list_boards",
|
||||||
|
"list_cables",
|
||||||
|
"list_fpgas",
|
||||||
|
"OpenFPGALoader",
|
||||||
|
]
|
||||||
Binary file not shown.
Loading…
Reference in New Issue