From 0fc46cb91aff948448d1d10e7da03d7e7ae1dcc7 Mon Sep 17 00:00:00 2001 From: TitanMKD Date: Fri, 17 May 2013 23:39:19 +0200 Subject: [PATCH 1/4] Added cmake script to find libhackrf. --- host/hackrf-tools/CMakeLists.txt | 6 +++-- host/hackrf-tools/FindLIBHACKRF.cmake | 36 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 host/hackrf-tools/FindLIBHACKRF.cmake diff --git a/host/hackrf-tools/CMakeLists.txt b/host/hackrf-tools/CMakeLists.txt index c970f1c4..130d2369 100644 --- a/host/hackrf-tools/CMakeLists.txt +++ b/host/hackrf-tools/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright 2012 Jared Boone +# Copyright 2013 Benjamin Vernoux # # This file is part of HackRF. # @@ -37,7 +38,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") find_package(USB1 REQUIRED) include_directories(${LIBUSB_INCLUDE_DIR}) -include_directories(${CMAKE_SOURCE_DIR}/../libhackrf/src) -link_directories(${CMAKE_SOURCE_DIR}/../libhackrf/src) +find_package(LIBHACKRF REQUIRED) +include_directories(${LIBHACKRF_INCLUDE_DIR}) +link_directories(${LIBHACKRF_LIBRARIES} ${CMAKE_SOURCE_DIR}/../libhackrf/src) add_subdirectory(src) diff --git a/host/hackrf-tools/FindLIBHACKRF.cmake b/host/hackrf-tools/FindLIBHACKRF.cmake new file mode 100644 index 00000000..af5cfebe --- /dev/null +++ b/host/hackrf-tools/FindLIBHACKRF.cmake @@ -0,0 +1,36 @@ +# - Try to find the libhackrf library +# Once done this defines +# +# LIBHACKRF_FOUND - system has libhackrf +# LIBHACKRF_INCLUDE_DIR - the libhackrf include directory +# LIBHACKRF_LIBRARIES - Link these to use libhackrf + +# Copyright (c) 2013 Benjamin Vernoux +# + + +if (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES) + + # in cache already + set(LIBHACKRF_FOUND TRUE) + +else (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES) + IF (NOT WIN32) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + pkg_check_modules(PC_LIBHACKRF libhackrf) + ENDIF(NOT WIN32) + + FIND_PATH(LIBHACKRF_INCLUDE_DIR hackrf.h + PATHS ${PC_LIBHACKRF_INCLUDEDIR} ${PC_LIBHACKRF_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) + + FIND_LIBRARY(LIBHACKRF_LIBRARIES NAMES libhackrf + PATHS ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) + + include(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBHACKRF DEFAULT_MSG LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIR) + + MARK_AS_ADVANCED(LIBHACKRF_INCLUDE_DIR LIBHACKRF_LIBRARIES) + +endif (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES) \ No newline at end of file From 18932692ab0dd0efb53c5c6e4368e9f3b4cba51b Mon Sep 17 00:00:00 2001 From: TitanMKD Date: Fri, 17 May 2013 23:41:32 +0200 Subject: [PATCH 2/4] Updated hackrf_transfer(host) and ubs_performance(firmware) extended frequency range from 5MHz to 6800MHz. --- firmware/usb_performance/usb_performance.c | 7 ++++--- host/hackrf-tools/src/hackrf_transfer.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/firmware/usb_performance/usb_performance.c b/firmware/usb_performance/usb_performance.c index fbba364e..4abfa7a3 100644 --- a/firmware/usb_performance/usb_performance.c +++ b/firmware/usb_performance/usb_performance.c @@ -1,5 +1,6 @@ /* * Copyright 2012 Jared Boone + * Copyright 2013 Benjamin Vernoux * * This file is part of HackRF. * @@ -79,20 +80,20 @@ void update_switches(void) #define FREQ_ONE_MHZ (1000*1000) -#define MIN_LP_FREQ_MHZ (30) +#define MIN_LP_FREQ_MHZ (5) #define MAX_LP_FREQ_MHZ (2300) #define MIN_BYPASS_FREQ_MHZ (2300) #define MAX_BYPASS_FREQ_MHZ (2700) #define MIN_HP_FREQ_MHZ (2700) -#define MAX_HP_FREQ_MHZ (6000) +#define MAX_HP_FREQ_MHZ (6800) #define MAX2837_FREQ_NOMINAL_HZ (2600000000) #define MAX2837_FREQ_NOMINAL_MHZ (MAX2837_FREQ_NOMINAL_HZ / FREQ_ONE_MHZ) /* - * Set freq/tuning between 30MHz to 6000 MHz (less than 16bits really used) + * Set freq/tuning between 5MHz to 6800 MHz (less than 16bits really used) * hz between 0 to 999999 Hz (not checked) * return false on error or true if success. */ diff --git a/host/hackrf-tools/src/hackrf_transfer.c b/host/hackrf-tools/src/hackrf_transfer.c index 2136eba1..b5a0d76a 100644 --- a/host/hackrf-tools/src/hackrf_transfer.c +++ b/host/hackrf-tools/src/hackrf_transfer.c @@ -48,8 +48,8 @@ #define FREQ_ONE_MHZ (1000000ull) #define DEFAULT_FREQ_HZ (900000000ull) /* 900MHz */ -#define FREQ_MIN_HZ (30000000ull) /* 30MHz */ -#define FREQ_MAX_HZ (6000000000ull) /* 6000MHz */ +#define FREQ_MIN_HZ (5000000ull) /* 5MHz */ +#define FREQ_MAX_HZ (6800000000ull) /* 6800MHz */ #define DEFAULT_SAMPLE_RATE_HZ (10000000) /* 10MHz default sample rate */ From cc74842b7826eafdba2c647fa4df1a05e7094bbc Mon Sep 17 00:00:00 2001 From: TitanMKD Date: Sat, 18 May 2013 00:03:00 +0200 Subject: [PATCH 3/4] Fix FindLIBHACKRF.cmake --- host/hackrf-tools/FindLIBHACKRF.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/hackrf-tools/FindLIBHACKRF.cmake b/host/hackrf-tools/FindLIBHACKRF.cmake index af5cfebe..469e6ec7 100644 --- a/host/hackrf-tools/FindLIBHACKRF.cmake +++ b/host/hackrf-tools/FindLIBHACKRF.cmake @@ -25,7 +25,7 @@ else (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES) FIND_PATH(LIBHACKRF_INCLUDE_DIR hackrf.h PATHS ${PC_LIBHACKRF_INCLUDEDIR} ${PC_LIBHACKRF_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) - FIND_LIBRARY(LIBHACKRF_LIBRARIES NAMES libhackrf + FIND_LIBRARY(LIBHACKRF_LIBRARIES NAMES hackrf PATHS ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) include(FindPackageHandleStandardArgs) From a38c20d4401ac22d8310e1af494d53b35ee01be0 Mon Sep 17 00:00:00 2001 From: TitanMKD Date: Sat, 18 May 2013 10:25:01 +0200 Subject: [PATCH 4/4] Fixed hackrf-tools CMake scripts to build them out of tree. --- host/hackrf-tools/CMakeLists.txt | 1 - host/hackrf-tools/FindLIBHACKRF.cmake | 29 ++++++++++++++++---- host/hackrf-tools/src/CMakeLists.txt | 38 +++++++++++++-------------- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/host/hackrf-tools/CMakeLists.txt b/host/hackrf-tools/CMakeLists.txt index 130d2369..229eccfa 100644 --- a/host/hackrf-tools/CMakeLists.txt +++ b/host/hackrf-tools/CMakeLists.txt @@ -40,6 +40,5 @@ include_directories(${LIBUSB_INCLUDE_DIR}) find_package(LIBHACKRF REQUIRED) include_directories(${LIBHACKRF_INCLUDE_DIR}) -link_directories(${LIBHACKRF_LIBRARIES} ${CMAKE_SOURCE_DIR}/../libhackrf/src) add_subdirectory(src) diff --git a/host/hackrf-tools/FindLIBHACKRF.cmake b/host/hackrf-tools/FindLIBHACKRF.cmake index 469e6ec7..6a4a919c 100644 --- a/host/hackrf-tools/FindLIBHACKRF.cmake +++ b/host/hackrf-tools/FindLIBHACKRF.cmake @@ -19,14 +19,33 @@ else (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_package(PkgConfig) - pkg_check_modules(PC_LIBHACKRF libhackrf) + pkg_check_modules(PC_LIBHACKRF QUIET libhackrf) ENDIF(NOT WIN32) - FIND_PATH(LIBHACKRF_INCLUDE_DIR hackrf.h - PATHS ${PC_LIBHACKRF_INCLUDEDIR} ${PC_LIBHACKRF_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) + FIND_PATH(LIBHACKRF_INCLUDE_DIR + NAMES hackrf.h + HINTS $ENV{LIBHACKRF_DIR}/include ${PC_LIBHACKRF_INCLUDEDIR} + PATHS /usr/local/include/libhackrf /usr/local/include + /usr/include ${CMAKE_SOURCE_DIR}/../libhackrf/src + /opt/local/include/libhackrf + ${LIBHACKRF_INCLUDE_DIR} + ) - FIND_LIBRARY(LIBHACKRF_LIBRARIES NAMES hackrf - PATHS ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src) + set(libhackrf_library_names hackrf) + + FIND_LIBRARY(LIBHACKRF_LIBRARIES + NAMES ${libhackrf_library_names} + HINTS $ENV{LIBHACKRF_DIR}/lib ${PC_LIBHACKRF_LIBDIR} + PATHS /usr/local/lib /usr/lib /opt/local/lib ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src + ) + + if(LIBHACKRF_INCLUDE_DIR) + set(CMAKE_REQUIRED_INCLUDES ${LIBHACKRF_INCLUDE_DIR}) + endif() + + if(LIBHACKRF_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${LIBHACKRF_LIBRARIES}) + endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBHACKRF DEFAULT_MSG LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIR) diff --git a/host/hackrf-tools/src/CMakeLists.txt b/host/hackrf-tools/src/CMakeLists.txt index 097a8ad2..ff1f588a 100644 --- a/host/hackrf-tools/src/CMakeLists.txt +++ b/host/hackrf-tools/src/CMakeLists.txt @@ -21,24 +21,22 @@ # Based heavily upon the libftdi cmake setup. -option(EXAMPLES "Build example programs" ON) +add_executable(hackrf_max2837 hackrf_max2837.c) +add_executable(hackrf_si5351c hackrf_si5351c.c) +add_executable(hackrf_transfer hackrf_transfer.c) +add_executable(hackrf_rffc5071 hackrf_rffc5071.c) +add_executable(hackrf_spiflash hackrf_spiflash.c) +add_executable(hackrf_cpldjtag hackrf_cpldjtag.c) +add_executable(hackrf_info hackrf_info.c) + +include_directories(${LIBHACKRF_INCLUDE_DIR}) + +target_link_libraries(hackrf_max2837 ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_si5351c ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_transfer ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_rffc5071 ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_spiflash ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_cpldjtag ${LIBHACKRF_LIBRARIES}) +target_link_libraries(hackrf_info ${LIBHACKRF_LIBRARIES}) + -IF( EXAMPLES ) - add_executable(hackrf_max2837 hackrf_max2837.c) - add_executable(hackrf_si5351c hackrf_si5351c.c) - add_executable(hackrf_transfer hackrf_transfer.c) - add_executable(hackrf_rffc5071 hackrf_rffc5071.c) - add_executable(hackrf_spiflash hackrf_spiflash.c) - add_executable(hackrf_cpldjtag hackrf_cpldjtag.c) - add_executable(hackrf_info hackrf_info.c) - - target_link_libraries(hackrf_max2837 hackrf) - target_link_libraries(hackrf_si5351c hackrf) - target_link_libraries(hackrf_transfer hackrf) - target_link_libraries(hackrf_rffc5071 hackrf) - target_link_libraries(hackrf_spiflash hackrf) - target_link_libraries(hackrf_cpldjtag hackrf) - target_link_libraries(hackrf_info hackrf) - - include_directories(BEFORE ${CMAKE_SOURCE_DIR}/../libhackrf/src) -endif(EXAMPLES)