From 85f935afe9cb3b8990c9e4352122449550fc44c0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 6 Sep 2024 15:46:23 +0200 Subject: [PATCH] Improve detection of the dma_proxy module and the spidev driver --- CMakeLists.txt | 60 ++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35ccd15a5..b93750b3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3444,46 +3444,23 @@ if(ENABLE_MAX2771) if(DEFINED ENV{SDKTARGETSYSROOT}) set(TARGET_ROOTFS_PATH $ENV{SDKTARGETSYSROOT}) else() - set(TARGET_ROOTFS_PATH "") - endif() - find_program(STRINGS_EXECUTABLE strings) - 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}.") + string(REGEX MATCH "(.*/tmp-glibc)" MATCHED_PATH "${GNURADIO_RUNTIME_INCLUDE_DIRS}") + if(MATCHED_PATH) + set(TARGET_ROOTFS_PATH "${MATCHED_PATH}/sysroots-components") else() - 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() + set(TARGET_ROOTFS_PATH "") endif() + endif() + file(GLOB_RECURSE SPIDEV_FILE "${TARGET_ROOTFS_PATH}/*/spidev.h") + if(EXISTS "${SPIDEV_FILE}") + message(STATUS "SPIdev driver found: ${SPIDEV_FILE}") 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() @@ -3498,9 +3475,14 @@ if(ENABLE_DMA_PROXY) if(DEFINED ENV{SDKTARGETSYSROOT}) set(TARGET_ROOTFS_PATH $ENV{SDKTARGETSYSROOT}) 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() - 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}") message(STATUS "Found dma-proxy.ko file: ${DMA_PROXY_FILE}") else()