1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-11-10 20:10:05 +00:00

Improve detection of the dma_proxy module and the spidev driver

This commit is contained in:
Carles Fernandez 2024-09-06 15:46:23 +02:00
parent 951520f581
commit 85f935afe9
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -3444,46 +3444,23 @@ if(ENABLE_MAX2771)
if(DEFINED ENV{SDKTARGETSYSROOT}) if(DEFINED ENV{SDKTARGETSYSROOT})
set(TARGET_ROOTFS_PATH $ENV{SDKTARGETSYSROOT}) set(TARGET_ROOTFS_PATH $ENV{SDKTARGETSYSROOT})
else() else()
set(TARGET_ROOTFS_PATH "") string(REGEX MATCH "(.*/tmp-glibc)" MATCHED_PATH "${GNURADIO_RUNTIME_INCLUDE_DIRS}")
endif() if(MATCHED_PATH)
find_program(STRINGS_EXECUTABLE strings) set(TARGET_ROOTFS_PATH "${MATCHED_PATH}/sysroots-components")
if(NOT STRINGS_EXECUTABLE)
message(STATUS "The 'strings' command could not be found. See https://www.gnu.org/software/binutils/")
message(STATUS " You can try to install it by typing:")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|kFreeBSD|GNU")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(STATUS " sudo yum install binutils")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(STATUS " sudo zypper install binutils")
else()
message(STATUS " sudo apt-get install binutils")
endif()
endif()
message(FATAL_ERROR "Binutils are required to build GNSS-SDR for SoC FPGA devices using the MAX2771 option.")
endif()
set(DTB_FILE "${TARGET_ROOTFS_PATH}/boot/devicetree/system-top.dtb")
if(EXISTS "${DTB_FILE}")
message(STATUS "Found DTB file: ${DTB_FILE}")
# Run the strings command and grep for "spidev"
execute_process(
COMMAND ${STRINGS_EXECUTABLE} ${DTB_FILE}
COMMAND grep "spidev"
OUTPUT_VARIABLE GREP_OUTPUT
RESULT_VARIABLE GREP_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(GREP_RESULT EQUAL 0)
message(STATUS "Found spidev-compatible peripheral in ${DTB_FILE}.")
else() else()
message(STATUS "SPIdev driver not found, its installation is required.") set(TARGET_ROOTFS_PATH "")
if(ENABLE_PACKAGING)
set(ENABLE_MAX2771 OFF)
else()
message(FATAL_ERROR "SPIdev driver is required for building gnss-sdr with -DENABLE_MAX2271=ON.")
endif()
endif() endif()
endif()
file(GLOB_RECURSE SPIDEV_FILE "${TARGET_ROOTFS_PATH}/*/spidev.h")
if(EXISTS "${SPIDEV_FILE}")
message(STATUS "SPIdev driver found: ${SPIDEV_FILE}")
else() else()
message(FATAL_ERROR "The device tree (DTB) file ${DTB_FILE} cannot be found.") message(STATUS "SPIdev driver not found, its installation is required.")
if(ENABLE_PACKAGING)
set(ENABLE_MAX2771 OFF)
else()
message(FATAL_ERROR "SPIdev driver is required for building gnss-sdr with -DENABLE_MAX2271=ON.")
endif()
endif() endif()
endif() endif()
@ -3498,9 +3475,14 @@ if(ENABLE_DMA_PROXY)
if(DEFINED ENV{SDKTARGETSYSROOT}) if(DEFINED ENV{SDKTARGETSYSROOT})
set(TARGET_ROOTFS_PATH $ENV{SDKTARGETSYSROOT}) set(TARGET_ROOTFS_PATH $ENV{SDKTARGETSYSROOT})
else() else()
set(TARGET_ROOTFS_PATH "") string(REGEX MATCH "(.*/tmp-glibc)" MATCHED_PATH "${GNURADIO_RUNTIME_INCLUDE_DIRS}")
if(MATCHED_PATH)
set(TARGET_ROOTFS_PATH "${MATCHED_PATH}/sysroots-components")
else()
set(TARGET_ROOTFS_PATH "")
endif()
endif() endif()
set(DMA_PROXY_FILE "${TARGET_ROOTFS_PATH}/lib/modules/5.10.0-xilinx-v2021.2/extra/dma-proxy.ko") file(GLOB_RECURSE DMA_PROXY_FILE "${TARGET_ROOTFS_PATH}/*/dma-proxy.ko")
if(EXISTS "${DMA_PROXY_FILE}") if(EXISTS "${DMA_PROXY_FILE}")
message(STATUS "Found dma-proxy.ko file: ${DMA_PROXY_FILE}") message(STATUS "Found dma-proxy.ko file: ${DMA_PROXY_FILE}")
else() else()