1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

LibbladeRF2: Debian build

This commit is contained in:
f4exb 2018-09-20 01:19:34 +02:00
parent 5b31982772
commit 13bd448eec
6 changed files with 267 additions and 119 deletions

View File

@ -214,7 +214,11 @@ endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wvla -Woverloaded-virtual -ffast-math -ftree-vectorize ${EXTRA_FLAGS}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10")
if (BUILD_DEBIAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmax-errors=10")
endif()
endif()
##############################################################################

View File

@ -5,79 +5,121 @@ find_package(LibUSB)
add_definitions(-DBLADERF_OS_LINUX)
set(bladerf_SOURCES
${LIBBLADERFLIBSRC}/src/async.c
${LIBBLADERFLIBSRC}/src/bladerf_priv.c
${LIBBLADERFLIBSRC}/src/config.c
${LIBBLADERFLIBSRC}/src/device_identifier.c
src/file_ops.c
${LIBBLADERFLIBSRC}/src/flash_fields.c
${LIBBLADERFLIBSRC}/src/fx3_fw.c
${LIBBLADERFLIBSRC}/src/gain.c
${LIBBLADERFLIBSRC}/src/init_fini.c
${LIBBLADERFLIBSRC}/src/sync.c
${LIBBLADERFLIBSRC}/src/smb_clock.c
${LIBBLADERFLIBSRC}/src/tuning.c
${LIBBLADERFLIBSRC}/src/xb.c
${LIBBLADERFCOMMONSRC}/src/sha256.c
${LIBBLADERFCOMMONSRC}/src/dc_calibration.c
${LIBBLADERFCOMMONSRC}/src/parse.c
${LIBBLADERFCOMMONSRC}/src/devcfg.c
${LIBBLADERFCOMMONSRC}/src/conversions.c
${LIBBLADERFCOMMONSRC}/src/log.c
${LIBBLADERFCOMMONSRC}/src/str_queue.c
${LIBBLADERFSRC}/host/misc/dev/lms_freqsel/freqsel.c
${LIBBLADERFLIBSRC}/src/helpers/interleave.c
${LIBBLADERFLIBSRC}/src/helpers/timeout.c
${LIBBLADERFLIBSRC}/src/helpers/wallclock.c
${LIBBLADERFLIBSRC}/src/helpers/configfile.c
${LIBBLADERFLIBSRC}/src/helpers/file.c
${LIBBLADERFLIBSRC}/src/helpers/version.c
${LIBBLADERFLIBSRC}/src/driver/fpga_trigger.c
${LIBBLADERFLIBSRC}/src/driver/si5338.c
${LIBBLADERFLIBSRC}/src/driver/dac161s055.c
${LIBBLADERFLIBSRC}/src/driver/fx3_fw.c
${LIBBLADERFLIBSRC}/src/driver/smb_clock.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/dac_core.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/ad9361.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/util.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/platform.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/ad9361_api.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/adc_core.c
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/ad9361_conv.c
${LIBBLADERFLIBSRC}/src/driver/spi_flash.c
${LIBBLADERFLIBSRC}/src/driver/ina219.c
${LIBBLADERFLIBSRC}/src/board/bladerf2/compatibility.c
${LIBBLADERFLIBSRC}/src/board/bladerf2/capabilities.c
${LIBBLADERFLIBSRC}/src/board/bladerf2/params.c
${LIBBLADERFLIBSRC}/src/board/bladerf2/bladerf2.c
${LIBBLADERFLIBSRC}/src/board/board.c
${LIBBLADERFLIBSRC}/src/board/bladerf1/flash.c
${LIBBLADERFLIBSRC}/src/board/bladerf1/bladerf1.c
${LIBBLADERFLIBSRC}/src/board/bladerf1/image.c
${LIBBLADERFLIBSRC}/src/board/bladerf1/compatibility.c
${LIBBLADERFLIBSRC}/src/board/bladerf1/calibration.c
${LIBBLADERFLIBSRC}/src/board/bladerf1/capabilities.c
${LIBBLADERFLIBSRC}/src/expansion/xb100.c
${LIBBLADERFLIBSRC}/src/expansion/xb200.c
${LIBBLADERFLIBSRC}/src/expansion/xb300.c
${LIBBLADERFLIBSRC}/src/streaming/async.c
${LIBBLADERFLIBSRC}/src/streaming/sync_worker.c
${LIBBLADERFLIBSRC}/src/streaming/sync.c
${LIBBLADERFLIBSRC}/src/bladerf.c
${LIBBLADERFLIBSRC}/src/capabilities.c
${LIBBLADERFLIBSRC}/src/dc_cal_table.c
${LIBBLADERFLIBSRC}/src/devinfo.c
${LIBBLADERFLIBSRC}/src/flash.c
${LIBBLADERFLIBSRC}/src/fpga.c
${LIBBLADERFLIBSRC}/src/fx3_fw_log.c
${LIBBLADERFLIBSRC}/src/image.c
${LIBBLADERFLIBSRC}/src/si5338.c
${LIBBLADERFLIBSRC}/src/sync_worker.c
${LIBBLADERFLIBSRC}/src/trigger.c
${LIBBLADERFLIBSRC}/src/version_compat.c
${LIBBLADERFLIBSRC}/src/init_fini.c
${LIBBLADERFLIBSRC}/src/backend/dummy/dummy.c
${LIBBLADERFLIBSRC}/src/backend/backend.c
${LIBBLADERFLIBSRC}/src/backend/dummy.c
${LIBBLADERFLIBSRC}/src/backend/usb/libusb.c
${LIBBLADERFLIBSRC}/src/backend/usb/usb.c
${LIBBLADERFLIBSRC}/src/backend/usb/libusb.c
${LIBBLADERFLIBSRC}/src/backend/usb/nios_access.c
${LIBBLADERFLIBSRC}/src/backend/usb/nios_legacy_access.c
${LIBBLADERFSRC}/fpga_common/src/band_select.c
${LIBBLADERFSRC}/fpga_common/src/lms.c
${LIBBLADERFCOMMONSRC}/src/conversions.c
${LIBBLADERFCOMMONSRC}/src/devcfg.c
${LIBBLADERFCOMMONSRC}/src/sha256.c
${LIBBLADERFLIBSRC}/src/devinfo.c
)
set(bladerf_HEADERS
${LIBBLADERFLIBSRC}/src/async.h
${LIBBLADERFLIBSRC}/src/capabilities.h
${LIBBLADERFLIBSRC}/src/dc_cal_table.h
${LIBBLADERFLIBSRC}/src/devinfo.h
${LIBBLADERFLIBSRC}/src/flash.h
${LIBBLADERFLIBSRC}/src/fpga.h
${LIBBLADERFLIBSRC}/src/fx3_fw_log.h
${LIBBLADERFLIBSRC}/src/metadata.h
${LIBBLADERFLIBSRC}/src/sync.h
${LIBBLADERFLIBSRC}/src/smb_clock.h
${LIBBLADERFLIBSRC}/src/tuning.h
${LIBBLADERFLIBSRC}/src/xb.h
${LIBBLADERFLIBSRC}/src/bladerf_priv.h
${LIBBLADERFLIBSRC}/src/config.h
${LIBBLADERFLIBSRC}/src/device_identifier.h
${LIBBLADERFLIBSRC}/src/file_ops.h
${LIBBLADERFLIBSRC}/src/flash_fields.h
${LIBBLADERFLIBSRC}/src/fx3_fw.h
${LIBBLADERFLIBSRC}/src/gain.h
${LIBBLADERFLIBSRC}/src/si5338.h
${LIBBLADERFLIBSRC}/src/sync_worker.h
${LIBBLADERFLIBSRC}/src/trigger.h
${LIBBLADERFLIBSRC}/src/version_compat.h
${LIBBLADERFLIBSRC}/src/backend/backend.h
${LIBBLADERFLIBSRC}/src/backend/dummy.h
${LIBBLADERFLIBSRC}/src/backend/usb/usb.h
${LIBBLADERFLIBSRC}/src/backend/usb/nios_access.h
${LIBBLADERFLIBSRC}/src/backend/usb/nios_legacy_access.h
${LIBBLADERFSRC}/fpga_common/include/band_select.h
${LIBBLADERFSRC}/fpga_common/include/lms.h
./common/include/host_config.h
./libraries/libbladeRF/src/version.h
./libraries/libbladeRF/src/backend/backend_config.h
${LIBBLADERFCOMMONSRC}/include/thread.h
${LIBBLADERFCOMMONSRC}/include/parse.h
${LIBBLADERFCOMMONSRC}/include/minmax.h
${LIBBLADERFCOMMONSRC}/include/rel_assert.h
${LIBBLADERFCOMMONSRC}/include/devcfg.h
${LIBBLADERFCOMMONSRC}/include/str_queue.h
${LIBBLADERFCOMMONSRC}/include/log.h
${LIBBLADERFCOMMONSRC}/include/dc_calibration.h
${LIBBLADERFCOMMONSRC}/include/sha256.h
include/host_config.h
include/backend/backend_config.h
include/version.h
${LIBBLADERFCOMMONSRC}/include/conversions.h
${LIBBLADERFLIBSRC}/src/helpers/interleave.h
${LIBBLADERFLIBSRC}/src/helpers/wallclock.h
${LIBBLADERFLIBSRC}/src/helpers/timeout.h
${LIBBLADERFLIBSRC}/src/helpers/version.h
${LIBBLADERFLIBSRC}/src/helpers/configfile.h
${LIBBLADERFLIBSRC}/src/helpers/file.h
${LIBBLADERFLIBSRC}/src/driver/dac161s055.h
${LIBBLADERFLIBSRC}/src/driver/fpga_trigger.h
${LIBBLADERFLIBSRC}/src/driver/si5338.h
${LIBBLADERFLIBSRC}/src/driver/ina219.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/platform.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/util.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/dac_core.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/config.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/adc_core.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/common.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/ad9361.h
${LIBBLADERFLIBSRC}/src/driver/thirdparty/adi/ad9361_api.h
${LIBBLADERFLIBSRC}/src/driver/spi_flash.h
${LIBBLADERFLIBSRC}/src/driver/fx3_fw.h
${LIBBLADERFLIBSRC}/src/driver/smb_clock.h
${LIBBLADERFLIBSRC}/src/board/bladerf2/capabilities.h
${LIBBLADERFLIBSRC}/src/board/bladerf2/compatibility.h
${LIBBLADERFLIBSRC}/src/board/board.h
${LIBBLADERFLIBSRC}/src/board/bladerf1/calibration.h
${LIBBLADERFLIBSRC}/src/board/bladerf1/capabilities.h
${LIBBLADERFLIBSRC}/src/board/bladerf1/compatibility.h
${LIBBLADERFLIBSRC}/src/board/bladerf1/flash.h
${LIBBLADERFLIBSRC}/src/expansion/xb300.h
${LIBBLADERFLIBSRC}/src/expansion/xb100.h
${LIBBLADERFLIBSRC}/src/expansion/xb200.h
${LIBBLADERFLIBSRC}/src/streaming/sync.h
${LIBBLADERFLIBSRC}/src/streaming/sync_worker.h
${LIBBLADERFLIBSRC}/src/streaming/metadata.h
${LIBBLADERFLIBSRC}/src/streaming/format.h
${LIBBLADERFLIBSRC}/src/streaming/async.h
${LIBBLADERFLIBSRC}/src/backend/backend.h
${LIBBLADERFLIBSRC}/src/backend/dummy/dummy.h
${LIBBLADERFLIBSRC}/src/backend/usb/nios_legacy_access.h
${LIBBLADERFLIBSRC}/src/backend/usb/nios_access.h
${LIBBLADERFLIBSRC}/src/backend/usb/usb.h
${LIBBLADERFLIBSRC}/src/devinfo.h
${LIBBLADERFLIBSRC}/include/bladeRF2.h
${LIBBLADERFLIBSRC}/include/libbladeRF.h
${LIBBLADERFLIBSRC}/include/bladeRF1.h
)
include_directories(
@ -91,6 +133,9 @@ include_directories(
${LIBBLADERFCOMMONSRC}/include
${LIBBLADERFCOMMONSRC}/include/windows
./include
./common/include
./libraries/libbladeRF/src
./libraries/libbladeRF/src/backend
)
add_definitions(-DQT_SHARED)
@ -104,3 +149,4 @@ target_link_libraries(bladerf
)
install(TARGETS bladerf DESTINATION lib)

View File

@ -4,7 +4,7 @@
* This file is part of the bladeRF project:
* http://www.github.com/nuand/bladeRF
*
* Copyright (c) 2013 Nuand LLC.
* Copyright (c) 2013-2018 Nuand LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -27,11 +27,12 @@
#ifndef HOST_CONFIG_H__
#define HOST_CONFIG_H__
//#define BLADERF_OS_LINUX 0
//#define BLADERF_OS_FREEBSD 0
//#define BLADERF_OS_OSX 0
//#define BLADERF_OS_WINDOWS 1
//#define BLADERF_BIG_ENDIAN 0
#define BLADERF_OS_LINUX 1
#define BLADERF_OS_FREEBSD 0
#define BLADERF_OS_OSX 0
#define BLADERF_OS_WINDOWS 0
#define BLADERF_BIG_ENDIAN 0
#define LIBBLADERF_SEARCH_PREFIX "/opt/install/libbladeRF"
#if !(BLADERF_OS_LINUX || BLADERF_OS_OSX || BLADERF_OS_WINDOWS || BLADERF_OS_FREEBSD)
# error "Build not configured for any supported operating systems"
@ -41,6 +42,7 @@
#error "Build configured for multiple operating systems"
#endif
#define HAVE_CLOCK_GETTIME 1
/*******************************************************************************
* Endianness conversions
@ -152,6 +154,63 @@
#error "Encountered an OS that we do not have endian wrappers for?"
#endif
/*******************************************************************************
* Endianness conversions for constants
*
* We shouldn't be using the above items for assigning constants because the
* implementations may be functions [1].
*
* [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17679#c7
******************************************************************************/
#define BLADERF_BYTESWAP16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
#define BLADERF_BYTESWAP32(x) ((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x000000ff) << 24) )
#define BLADERF_BYTESWAP64(x) ((((x) & 0xff00000000000000llu) >> 56) | \
(((x) & 0x00ff000000000000llu) >> 40) | \
(((x) & 0x0000ff0000000000llu) >> 24) | \
(((x) & 0x000000ff00000000llu) >> 8) | \
(((x) & 0x00000000ff000000llu) << 8) | \
(((x) & 0x0000000000ff0000llu) << 24) | \
(((x) & 0x000000000000ff00llu) << 40) | \
(((x) & 0x00000000000000ffllu) << 56) | \
#if BLADERF_BIG_ENDIAN
# define HOST_TO_LE16_CONST(x) (BLADERF_BYTESWAP16(x))
# define LE16_TO_HOST_CONST(x) (BLADERF_BYTESWAP16(x))
# define HOST_TO_BE16_CONST(x) (x)
# define BE16_TO_HOST_CONST(x) (x)
# define HOST_TO_LE32_CONST(x) (BLADERF_BYTESWAP32(x))
# define LE32_TO_HOST_CONST(x) (BLADERF_BYTESWAP32(x))
# define HOST_TO_BE32_CONST(x) (x)
# define BE32_TO_HOST_CONST(x) (x)
# define HOST_TO_LE64_CONST(x) (BLADERF_BYTESWAP64(x))
# define LE64_TO_HOST_CONST(x) (BLADERF_BYTESWAP64(x))
# define HOST_TO_BE64_CONST(x) (x)
# define BE64_TO_HOST_CONST(x) (x)
#else
# define HOST_TO_LE16_CONST(x) (x)
# define LE16_TO_HOST_CONST(x) (x)
# define HOST_TO_BE16_CONST(x) (BLADERF_BYTESWAP16(x))
# define BE16_TO_HOST_CONST(x) (BLADERF_BYTESWAP16(x))
# define HOST_TO_LE32_CONST(x) (x)
# define LE32_TO_HOST_CONST(x) (x)
# define HOST_TO_BE32_CONST(x) (BLADERF_BYTESWAP32(x))
# define BE32_TO_HOST_CONST(x) (BLADERF_BYTESWAP32(x))
# define HOST_TO_LE64_CONST(x) (x)
# define LE64_TO_HOST_CONST(x) (x)
# define HOST_TO_BE64_CONST(x) (BLADERF_BYTESWAP64(x))
# define BE64_TO_HOST_CONST(x) (BLADERF_BYTESWAP64(x))
#endif
/*******************************************************************************
* Miscellaneous Linux fixups
******************************************************************************/
@ -187,19 +246,29 @@
/* Rename a few functions and types */
#include <windows.h>
#include <io.h>
#include <direct.h>
#define usleep(x) Sleep((x+999)/1000)
/* Changes specific to Microsoft Visual Studio and its C89-compliant ways */
#if _MSC_VER
# define strtok_r strtok_s
# define strtoull _strtoui64
#if _MSC_VER < 1900
# define snprintf _snprintf
# define vsnprintf _vsnprintf
#else
#define STDC99
#endif
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
# define fileno _fileno
# define strdup _strdup
# define access _access
# define chdir _chdir
# define getcwd _getcwd
# define rmdir _rmdir
# define unlink _unlink
# define mkdir(n, m) _mkdir(n)
/* ssize_t lives elsewhere */
# include <BaseTsd.h>
@ -211,6 +280,19 @@
# define inline __inline
# endif
/* Visual studio 2012 compiler (v17.00.XX) doesn't have round functions */
# if _MSC_VER <= 1700
# include <math.h>
static inline float roundf(float x)
{
return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f);
}
static inline double round(double x)
{
return x >= 0.0 ? floor(x + 0.5) : ceil(x - 0.5);
}
# endif
#endif // _MSC_VER
#endif
@ -237,4 +319,16 @@
******************************************************************************/
#define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0]))
/**
* GCC 7+ warns on implicit fallthroughs in switch statements
* (-Wimplicit-fallthrough), which we use in a couple places for simplicity.
* The statement attribute syntax used to suppress this warning is not
* supported by anything else.
*/
#if __GNUC__ >= 7
#define EXPLICIT_FALLTHROUGH __attribute__((fallthrough))
#else
#define EXPLICIT_FALLTHROUGH
#endif // __GNUC__ >= 7
#endif

View File

@ -1,10 +0,0 @@
#ifndef VERSION_H__
#define VERSION_H__
#define LIBBLADERF_VERSION "1.9.0-git-23c6379e"
#define LIBBLADERF_VERSION_MAJOR 1
#define LIBBLADERF_VERSION_MINOR 9
#define LIBBLADERF_VERSION_PATCH 0
#endif

View File

@ -22,8 +22,9 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef BLADERF_BACKEND_CONFIG_H__
#define BLADERF_BACKEND_CONFIG_H__
#ifndef BACKEND_BACKEND_CONFIG_H_
#define BACKEND_BACKEND_CONFIG_H_
#define ENABLE_BACKEND_USB
#define ENABLE_BACKEND_LIBUSB
@ -35,52 +36,53 @@
#include "backend/usb/usb.h"
#ifdef ENABLE_BACKEND_DUMMY
extern const struct backend_fns backend_fns_dummy;
# define BACKEND_DUMMY &backend_fns_dummy,
extern const struct backend_fns backend_fns_dummy;
#define BACKEND_DUMMY &backend_fns_dummy,
#else
# define BACKEND_DUMMY
#define BACKEND_DUMMY
#endif
#ifdef ENABLE_BACKEND_USB
extern const struct backend_fns backend_fns_usb;
# define BACKEND_USB &backend_fns_usb,
extern const struct backend_fns backend_fns_usb;
#define BACKEND_USB &backend_fns_usb,
# ifdef ENABLE_BACKEND_LIBUSB
extern const struct usb_driver usb_driver_libusb;
# define BACKEND_USB_LIBUSB &usb_driver_libusb,
# else
# define BACKEND_USB_LIBUSB
# endif
# ifdef ENABLE_BACKEND_CYAPI
extern const struct usb_driver usb_driver_cypress;
# define BACKEND_USB_CYAPI &usb_driver_cypress,
# else
# define BACKEND_USB_CYAPI
# endif
# define BLADERF_USB_BACKEND_LIST { \
BACKEND_USB_LIBUSB \
BACKEND_USB_CYAPI \
}
# if !defined(ENABLE_BACKEND_LIBUSB) && !defined(ENABLE_BACKEND_CYAPI)
# error "No USB backends are enabled. One or more must be enabled."
# endif
#ifdef ENABLE_BACKEND_LIBUSB
extern const struct usb_driver usb_driver_libusb;
#define BACKEND_USB_LIBUSB &usb_driver_libusb,
#else
# define BACKEND_USB
#define BACKEND_USB_LIBUSB
#endif
#if !defined(ENABLE_BACKEND_USB) && \
!defined(ENABLE_BACKEND_DUMMY)
#error "No backends are enabled. One more more must be enabled."
#ifdef ENABLE_BACKEND_CYAPI
extern const struct usb_driver usb_driver_cypress;
#define BACKEND_USB_CYAPI &usb_driver_cypress,
#else
#define BACKEND_USB_CYAPI
#endif
#define BLADERF_USB_BACKEND_LIST \
{ \
BACKEND_USB_LIBUSB \
BACKEND_USB_CYAPI \
}
#if !defined(ENABLE_BACKEND_LIBUSB) && !defined(ENABLE_BACKEND_CYAPI)
#error "No USB backends are enabled. One or more must be enabled."
#endif
#else
#define BACKEND_USB
#endif
#if !defined(ENABLE_BACKEND_USB) && !defined(ENABLE_BACKEND_DUMMY)
#error "No backends are enabled. One more more must be enabled."
#endif
/* This list should be ordered by preference (highest first) */
#define BLADERF_BACKEND_LIST { \
BACKEND_USB \
BACKEND_DUMMY \
}
#define BLADERF_BACKEND_LIST \
{ \
BACKEND_USB \
BACKEND_DUMMY \
}
#endif

View File

@ -0,0 +1,12 @@
#ifndef VERSION_H_
#define VERSION_H_
#define LIBBLADERF_VERSION "2.0.2-git-32058c4"
// clang-format off
#define LIBBLADERF_VERSION_MAJOR 2
#define LIBBLADERF_VERSION_MINOR 0
#define LIBBLADERF_VERSION_PATCH 2
// clang-format on
#endif