Commit graph

54 commits

Author SHA1 Message Date
Robert Ghilduta
6905c37642 host: finish off cross-platform support for Windows
libbladeRF now compiles under MinGW as well as MSVC under Windows
2025-04-24 04:36:36 -07:00
Robert Ghilduta
34fce67f4f host: remove pthreadswin32 cmake 2025-04-24 04:36:36 -07:00
Rey Tucker
48ec0a40a6
Move vendor library code for ad936x RFIC to /thirdparty; use git submodule (#689)
This PR creates a git submodule for the analogdevicesinc/no-OS code, moving it from host/libraries/libbladeRF/src/driver/thirdparty/adi/ to thirdparty/analogdevicesinc/no-OS and adjusting the build process accordingly.

The build process will handle the git submodule init / git submodule update as required, or it may be done manually before the build. It will then copy the necessary files to the build tree, apply a series of patches for local modifications, and then build it as libad936x.

There are no changes to the build steps, although the build will fail if git submodule init/update needs to happen but can't (e.g. if github is not reachable).

* thirdparty: add no-OS library submodule

Adds a submodule for https://github.com/analogdevicesinc/no-OS/, pinned
at commit 0bba46e.

* thirdparty: patch and build libad936x

Add cmake file for libad936x

Move our local mods into patch files

* host: libbladeRF: transition to libad936x

Transitions libbladeRF (particularly bladerf2.c) to use the libad936x
package, compiled separately.

This also adds ad936x.h, a driver header file that contains the
necessary things from libad936x.  This is cleaner than just importing
ad9361_api.h, due to the significant dependency/include challenges that
ensue...

* host: fix up libad936x build

Don't use ExternalProject, instead just add it as a subdirectory

Create a FindPatcher.cmake for the patch-or-git selector

Clean up and streamline the ad936x cmakelists

Clean up libbladeRF cmakelist formatting

* thirdparty: fix no-OS patch 0003

* host: ad936x: fixup build errors/warnings on macOS

* thirdparty/adi: patch to chop out ad9361_parse_fir

ad9361_parse_fir refers to sscanf, which is not readily available in the
Nios II library. We don't use this function, so it can go.

* libbladeRF: remove vestigial adi files

* debian: rm thirdparty ADI tree from license file

* host: thirdparty: fix git package handling

* host: thirdparty/ad936x: specify patches in order

It turns out that there's no guarantee that file(GLOB)
will output the patch files in the alphabetical order.

* Revert "debian: rm thirdparty ADI tree from license file"

This reverts commit 36cf335c0e.

* debian: update path in ADI copyright
2018-11-12 18:13:58 -05:00
Dan Robertson
f4228d2f9f bladeRF-cli: Add libedit support
* Add libedit support to the bladeRF-cli utility
   * Add a libedit input backend
   * Allow the build system to be configured to link to libedit
     * Add FindLibEdit cmake module
     * Update bladeRF-cli build to use libedit if ENABLE_LIBEDIT is set or
       libedit is found and libtecla is not
 * Fix memory leak when a unterminated quoted string is given in
   interactive mode
2018-09-04 12:35:53 -04:00
Rey Tucker
6e78b7b952
host: define SHORT_FILE_ during cmake builds (#61)
* host: cmake: add function to set SHORT_FILE_ def

The function, based heavily off of a Stack Overflow example :), goes
through all of the source files defined for a given target and sets the
SHORT_FILE_ definition for them.

This results in debug log messages relative to the top directory of the
project, i.e.:

[DEBUG @ host/libraries/libbladeRF/src/board/bladerf2/bladerf2.c:930]
_set_tx_mute: muting TX1 (cached: 10000)

* host: libbladeRF: enable Shortfile for libbladerf_shared
2018-06-01 15:52:32 -04:00
Rey Tucker
0fcf5f8ed4 host: cmake: add missing quotes in STREQUAL compare
Without this, recent CMake releases can't handle an empty
VERSION_INFO_EXTRA.
2018-03-26 15:32:43 -04:00
Rey Tucker
ad0e61049a host: cmake: make the search for libtecla quiet
This eliminates an unnecessary "libtecla not found" error during cmake.
2018-01-15 19:13:58 -05:00
Rey Tucker
1a9eb9d371 host: update with fixes from public-facing repo
This includes everything but AGC-related stuff.

Squashed commit of the following:

commit ab00f2a68353024c5faf14dedbb5fd05a8438f26
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Wed Aug 9 10:58:08 2017 -0400

    libbladeRF: add compilation hint to boilerplate.c

    h/t owen on IRC

commit 3cbeaf72dbe22525a5c907dfb9643db81c7aca85
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Mon Aug 7 12:27:21 2017 -0400

    host/CMakeLists: dequote variables in ifs (CMP0054) #511

    Per CMake Policy CMP0054, the meaning of constructs like

    if("${FOOBAR}" STREQUAL "quux")

    is ambigious, and the old meaning is deprecated.

    https://cmake.org/cmake/help/git-stage/policy/CMP0054.html

commit 73376b7aac65d945c5399a5130aca33265080653
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Fri Aug 4 13:40:37 2017 -0400

    host/README.md: add pthreads-win32 build instructions (#447)

    On recent versions of Windows / Visual Studio, struct timespec is
    already defined, and the definition is subtly different than what
    pthreads-win32 is built with.

    It may be possible to handle this in a more automatic fashion via CMake,
    but this is TBD.

commit b90ff648e5cf754a29264f2a2c2c19d924c5c070
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Mon Aug 7 18:09:30 2017 -0400

    host/cmake/CyAPI: define Windows 10 support

    This requires that the user get special additional drivers in addition
    to the ones provided by the usual SDK; a URL will point in the right
    direction.

    Note that this does not remove the requirement for driver signing.  Some
    work will be needed to document how to do this.

commit 888254b975f3b64ec787c741b937a561a08ccc44
Author: Jon Szymaniak <jon.szymaniak@nuand.com>
Date:   Thu Jun 9 17:47:21 2016 -0400

    libbladeRF: Treat incompatible OS version as "not found" in FindCyAPI.cmake

commit a9e97b2de6c22539266447f755e5a42cdf9a4f70
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Mon Aug 7 11:35:16 2017 -0400

    host/libbladeRF/cyapi: ReleaseMutex before CloseHandle

    When working on mutexes for the libusb backend, I noticed that I needed
    to ReleaseMutex() when closing the device, or else that device would not
    be usable again until all of the mutexes were released.

    I have not tested this with CyAPI as yet, but I believe the same problem
    will occur, and I also believe this may fix it.

commit b897475aa1a5b80358fcf2c8902089740d04582f
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Fri Aug 4 18:00:34 2017 -0400

    host/libusb.c: properly release/close handles

commit f9b99ee7715af1ccb64d41d3363a3cc8e66aa063
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Fri Aug 4 17:17:29 2017 -0400

    host/libusb.c: fix create_device_mutex errors (#484)

    This builds and correctly enforces exclusive access under Windows 10.

commit 6e9c048ff2e8321052c3e72e14f51eb2aa66b5dc
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Thu Aug 3 13:14:51 2017 -0400

    host/backend/libusb: enforce exclusive access (#484)

    Windows seems to allow multiple instances of libbladeRF to open the same
    device, which is problematic in many ways.  This borrows the mutex
    approach from cyapi.c to enforce exclusivity.

commit 519f26b6b88d1cbdfec7138fe9a0fc13715c7f93
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Fri Aug 4 16:07:49 2017 -0400

    host/cmake: search for pthreadVC2.dll more vigorously (#517)

    With the pre-built binary pack, pthreadVC2.dll lives in a
    dll/${ARCHITECTURE}/ directory.  However, when compiling from scratch,
    it just lives in the source code's root directory.  Look in both places
    and set a LIBPTHREADSWIN32_DLL variable accordingly.

commit b7617cda8e87396da19101f10de02619d0fd8e1d
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Wed Aug 2 18:05:33 2017 -0400

    CONTRIBUTORS: self-updating

commit 3a4e57b3c2f2b9ac27db832de0bbc945c3217dd7
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Tue Jul 25 15:07:54 2017 -0400

    debian: chmod 0444 downloaded fpga/fw images

    The mktemp/wget workflow creates the data files chmod 0600, which breaks
    loading of firmware for non-root users.  Explicitly chmod 0444 to allow
    all users to read.

commit 24594d3e34eca05c2fc738dc2fa5d1fcc9ab0bda
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Wed Aug 2 17:34:11 2017 -0400

    host: add note about Fedora and /usr/local (#490)

commit 6219e15a38c8dfe957e12ce38fbd76e0bf40a177
Author: Rey Tucker <rey.tucker@nuand.com>
Date:   Wed Aug 2 15:35:27 2017 -0400

    nios: fix si5338_write typo (#491)

    Unnecessary bit is being set when writing address.

commit 0d14e6ec0a3d438c206f4d02a95aa4b250ec3674
Author: Oliver Jowett <oliver@mutability.co.uk>
Date:   Thu Apr 27 21:03:12 2017 +0100

    Document why postinst should succeed if the FPGA download fails

commit 84042b6aa5bcc761c631a06687dc690343f4d952
Author: Oliver Jowett <oliver@mutability.co.uk>
Date:   Thu Apr 27 13:20:25 2017 +0100

    Don't make postinst fail entirely (producing half-configured packages and
    making the overall install operation fail) if the FPGA download fails.

    (cherry picked from commit 13befc071b3cddb913ce961c3cd7b08216bba2e5)

commit b203fbca8c789d8a99bbef34e20feda9d1a6e940
Author: ifrasch <fraschi17@gmail.com>
Date:   Sat Feb 18 17:28:59 2017 -0500

    hdl: Fixed simulation files

    -Added missing ports to nios_system.vhd
    -Added missing files to nuand.do
    -Compile.do will now compile successfully in Modelsim
2017-12-21 12:55:07 -05:00
Rey Tucker
0f84cc76af
Merge pull request #531 from Nuand/rtucker-host-fix-versioninfoextra
host/cmake: fix regression from #511
2017-12-08 11:35:12 -05:00
Robert Ghilduta
3a6742b716 Remove unused CMake macro file 2017-12-07 17:10:28 -08:00
Rey Tucker
a7b2445d87 host/cmake: fix regression from #511
We explicitly set VERSION_INFO_EXTRA to "" for release builds, which
causes (${VERSION_INFO_EXTRA} STREQUAL "") to evaluate to
( STREQUAL ""), a syntax error.

Quoting ${VERSION_INFO_EXTRA} should not cause the ambigious condition
foretold in CMP0054, so doing that.
2017-10-24 16:15:22 -04:00
Rey Tucker
1d41ada308 Merge pull request #525 from Nuand/rtucker-issue-511
host/CMakeLists: dequote variables in ifs (CMP0054) #511
2017-08-07 18:18:17 -04:00
Rey Tucker
33da458132 host/cmake/CyAPI: define Windows 10 support
This requires that the user get special additional drivers in addition
to the ones provided by the usual SDK; a URL will point in the right
direction.

Note that this does not remove the requirement for driver signing.  Some
work will be needed to document how to do this.
2017-08-07 18:09:30 -04:00
Jon Szymaniak
70d5fb14b2 libbladeRF: Treat incompatible OS version as "not found" in FindCyAPI.cmake 2017-08-07 18:08:34 -04:00
Rey Tucker
a075d0149b host/CMakeLists: dequote variables in ifs (CMP0054) #511
Per CMake Policy CMP0054, the meaning of constructs like

if("${FOOBAR}" STREQUAL "quux")

is ambigious, and the old meaning is deprecated.

https://cmake.org/cmake/help/git-stage/policy/CMP0054.html
2017-08-07 12:27:21 -04:00
Rey Tucker
bafb0b5ca0 host/cmake: search for pthreadVC2.dll more vigorously (#517)
With the pre-built binary pack, pthreadVC2.dll lives in a
dll/${ARCHITECTURE}/ directory.  However, when compiling from scratch,
it just lives in the source code's root directory.  Look in both places
and set a LIBPTHREADSWIN32_DLL variable accordingly.
2017-08-04 16:07:49 -04:00
Jon Szymaniak
d5718ca816 cmake: Updated FindLibUSB path default for v1.0.20 2016-06-27 15:17:35 -04:00
Jon Szymaniak
f74c8ee071 host: Updated CMake files for different CyUSB3 INF paths 2016-01-03 21:26:50 -05:00
Nick "Darkfiber" Wolff
327dce57b1 host: Minimal build fixes for FreeBSD
Work still needs to be done to troubleshoot libusb issues.
2015-12-14 11:36:15 -05:00
Jon Szymaniak
8a867db62b host: Fixed copy of WdfCoInstaller from FX3 SDK to build dir
Cypress FX3 SDK 1.3.x ships version 01009 for <= Vista and
01011 for >= Win 7.
2015-10-08 13:32:22 -04:00
Jon Szymaniak
28b1d281de host: Copy licenses alongside their associated DLLs/drivers 2014-10-31 10:50:32 -04:00
Jon Szymaniak
4fe977c7f8 cmake: Copy CYUSB3 driver based upon host processor, not build config
A 64-bit CYUSB3 driver should be installed on 64-bit machines, regardless of the
userspace software being configured for a 32-bit build.
2014-10-28 06:43:43 -04:00
Jon Szymaniak
90741dbd94 cmake: Set Windows-specific LIBUSB_PATH default only for WIN32 systems 2014-10-27 11:52:58 -04:00
Jon Szymaniak
97a44f94e4 cmake: Explicitly link libusb at runtime for version check in Windows
FindLibUSB.cmake presents issues with its try_compile() invocation
when using some dated CMake versions, such as 2.8.7 and 2.8.11, while
operating fine with more recent versions (e.g., 2.8.12.2, 3.0.0).

Using try_run() is a cleaner solution than a combination of try_compile() and
execute_process(). However, in Windows we need to stage libusb-1.0.dll in the
directory containing the resulting libusb_version.exe. As try_run() creates a
a temporary build directory and deletes it when done, this originally
posed a challenge to copying libusb-1.0.dll to the correct directory.

To address both of these challenges, the Windows version of this program now
explicitly links libusb at runtime, provided the path to the libusb DLL.

OSX and Linux variants assume libusb is in the library path, and link against
the library at compile-time.
2014-10-22 02:54:15 -04:00
Jon Szymaniak
34151f6e71 host: Added a config-time libusb version check and errors/warnings
FindLibUSB.cmake now fetches the libusb version via libusb_get_version()
so that we can warn (or error out) about the system containing an
outdated libusb version.

The following policies have been based upon support experiences and the
libusb changelog:

    Windows: Error out for libusb < 1.0.19
        v1.0.19 provides Windows 8 SuperSpeed detection support,
        and appears to address a number of issues bladeRF users
        have reported with v1.0.18 and earlier.

        We force users to update here, given that some of the failures
        on earlier versions were yielding corrupted samples.

    OSX: Warn for libusb < 1.0.18:
        v1.0.16 - v1.0.18 introduced SuperSpeed and 64-bit support,
        as well as fixes for compile-time and run-time issues.

    Linux: Warn for libusb < 1.0.16:
        This is largely based upon feedback from bladeRF users. While
        older versions may work, a number of users reported that issues
        appeared to be resolved after updating libusb to >= 1.0.16.
        (It isn't always clear if the reported update included Linux
         distro upgrades that included kernel updates.)

The version check may be skipped via LIBUSB_SKIP_VERSION_CHECK=Yes.
This is intentionally not noted in the warnings/errors, as it's
preferred that users update libusb rather than just skip the check.
2014-10-15 20:06:53 -04:00
Jon Szymaniak
7767c9756a cmake: Set FX3 SDK path variable's default value from environment variable
The FX3 SDK installer creates the FX3_INSTALL_PATH variable, so there's
no need to hardcode a default path.
2014-10-13 09:55:31 -04:00
Jon Szymaniak
0b7f43712c libbladeRF: Added support for Cypress Windows Driver & API backend
A USB backend based atop of the Cypress CyAPI (which is based atop the
Cypress CyUSB3 driver) has been introduced. This is intended to provide
Windows users with an additional driver to use if they encounter issues
with their USB host controller and libusb.

To build and use this backend, the Cypress FX3 SDK must be installed and
the following CMake flags should be provided:
    -DENABLE_BACKEND_CYAPI=Yes -DFX3_SDK_PATH=<path to SDK>

A modified cyusb3.inf is provided in host/drivers/windows/cyusb3. Upon
performing a build this inf file and the associated driver files from
the FX3 SDK will be copied into the "output" directory along with the
bladeRF.dll and bladeRF-cli.exe. To install the driver, point the
Windows driver update to this location and accept the warning about the
driver being unsigned; this occurs because the Cypress driver wasn't
signed with bladeRF VID/PID values.

The libbladeRF device string for this backend is: "cypress"

Many thanks go out to LazyDodo for all his efforts in spearheading the
development of this backend -- much of this code is either his doing or
is directly based upon his efforts.
2014-10-12 21:55:26 -04:00
Jon Szymaniak
7c0969a44d host: Enable short source file name and line # in log output by default
When making log_* calls, add these two lines to the corresponding
CMake file prior to add_library() or add_executable():

    set(SRC_TO_SHORTEN ${MY_SRC_LIST})
    include(ShortFileMacro)

Many thanks to LazyDodo for providing the CMake approach for doing this,
and to rwr for suggesting this change.
2014-10-02 12:29:14 -04:00
Jon Szymaniak
a8d6065e61 cmake: Fixed if()/endif() mismatch
This was mistake was introduced in 62a0ab5e.
2014-10-02 11:47:33 -04:00
Jon Szymaniak
62a0ab5ee8 cmake: Skip libc & libusb version checks when cross-compiling
These checks break cross-compilation, as they require code to be
run on the host machine.
2014-10-01 02:44:49 -04:00
Jon Szymaniak
f607510500 cmake: Defaulted Windows LIBUSB_PATH to libusb-1.0.19 2014-07-22 23:26:58 -04:00
Jon Szymaniak
9c651b5996 cmake: Fixed default for LIBUSB_PATH (Windows) 2014-07-05 14:56:29 -04:00
Jon Szymaniak
2a90a56d55 host: Added additional configuration-time libusb function checks
Added checks for the following functions so that builds on older setups
will error out with error messages at configuration time, rather than
compilation errors at build time.
    - libusb_error_name()
    - libusb_get_device_speed()
    - libusb_handle_events_timeout()
    - libusb_handle_events_timeout_completed()
2014-05-13 00:09:53 -04:00
Jon Szymaniak
288258d58e host: Fixed FindLibUSB.cmake issues on OSX Mavericks, cmake touch-ups
Fixed Issue #242, where the FindLibUSB.cmake script wasn't finding a
libusb installed to /usr/local/ in the case where pkg-config wasn't
installed. This should also help in cases where pkg-config isn't
installed on Linux systems.

Other touch-ups include removal of an unnecessary warning message,
and some re-arrangement of operations.
2014-05-06 23:45:01 -04:00
Jon Szymaniak
95a6c1d0e0 cmake: Fixes and cleanup for libusb detection and version checks
The version checks are now enforced. (Fixes #130)

FindLibUsb now warns if the user is using < libusb-1.0.16, as this or
1.0.17 are *highly* recommended.

The redundant version check in Windows (ver.c) has been removed. Testing
with CMake 2.8.11.2 has shown check_library_exists() to be sufficient.
2013-12-09 23:53:38 -05:00
Ryan Tucker
98eca856f9 Inject the current Debian snapshot version
This figures out the version number of the source package we're
building, then injects it into the VERSION_INFO within CMake.
2013-10-27 15:51:32 -04:00
Ryan Tucker
edc468dbb2 Update debian/copyright to match current state
Second/third/fourth pairs of eyes are welcome...

h/t to A. Maitland Bottoms' Debian package for spotting the
Altera and OpenCores packages
2013-10-27 00:18:13 -04:00
Jon Szymaniak
625694eaa5 license: License changes on various portions of the codebase
Where possible (and with contributor permission), items have been
changed to LGPLv2.1 or MIT licenses to avoid issues with any proprietary
libraries from vendors (HDL and FW), allow static linking (with headless
mode operation in mind), and to generally present users with more
permissive licenses.

File headers and the COPYING have been updated accordingly. Third party
sources have been either removed, replaced, or relocated in the source
tree, in accordance with the licenses decided upon for each part of the tree.

Contributor Assignment Agreements have been added, and it is required
that these be submitted before significant patches and pull requests
are accepted.
2013-10-27 00:17:35 -04:00
Jon Szymaniak
3891711766 cmake: Cleaned up git version info
If rev and dirty flag are not set properly, the version won't wind up
with a dangling '-' character.
2013-10-21 23:01:44 -04:00
Jon Szymaniak
6343982cd6 cmake: Copyright/attibution cleanup
Most of these files had inaccurate copy-paste headers, as the files are
now vastly different than those mentioned. These will all just fall under
the "meta-data" category in upcoming licenses.

Per discussion with FindLibBladeRF.cmake author, the text in
FindLibTecla.cmake was unnecessary, and has been removed.
2013-10-21 21:00:15 -04:00
Ryan Tucker
c27a67fa63 Warn the user if pkg-config isn't installed
Helpfully suggest installing pkg-config if FindLibUSB.cmake fails.
This change should not impact the build mechanics.
2013-10-05 20:53:43 -04:00
Jon Szymaniak
553985478b cmake: Added check for libusb_get_version (github edit)
This function is used by libbladeRF. This check effectively ensures the library is >= 1.0.10.
2013-09-19 10:03:35 -04:00
Robert Ghilduta
00ba848e6b Cmake: fix error that caused all build versions to be labelled -dirty 2013-09-14 23:31:49 -07:00
Robert Ghilduta
03ef44b21e copy Windows DLLs into the bladeRF-cli.exe build directory 2013-09-02 12:14:03 -07:00
Jon Szymaniak
b30446293e Added pthreads-win32, and getopt/getopt_long to Windows build. 2013-09-03 00:19:39 -04:00
Jon Szymaniak
056c296b90 Fixed linking issue for Win64 hosts.
CMake's WIN32 is true for both 32 and 64-bit hosts, so we must
instead use CMAKE_CL_64 or CMAKE_SIZEOF_VOID_P.
2013-09-02 23:22:58 -04:00
Jon Szymaniak
e1f4dcd3de bladeRF-cli: ENABLE_INTERACTIVE_TECLA set to OFF if libtecla is not found 2013-08-31 21:14:06 -04:00
Jon
b23b540cc1 Update Version.cmake
Fixed warning message when git is not available.
2013-08-31 15:45:55 -04:00
Jon Szymaniak
d394f68084 host: Fixed build items broken by Windows build-related commits.
This includes freqmod's fixes provided in pull request/issue #57,
in addition to some other misc. cleanup items noted while reviewing
the aforementioned changset.
2013-08-25 11:16:07 -04:00
Jon Szymaniak
33365c196c host: Fixed a few minor CMake issues for Windows builds 2013-08-25 00:09:15 -04:00