Commit graph

135 commits

Author SHA1 Message Date
Ryan Thompson
15b7d9c3b6 host: squashed cmake warnings
updated cmake requirement from 2.8 to 2.8.12
2023-02-13 03:28:19 -08:00
Robert Ghilduta
f1a07d0134 common: only generate AGC LUT for bladeRF 1.0 devices
The AGC DC LUT is only a requirement for the bladeRF x40's and x115's AGC.
2019-04-02 01:59:07 -07:00
Robert Ghilduta
150bc1bbdf bladeRF-cli: add tuning_mode print/set parameter
libbladeRF supports host and FPGA based tuning. This print/set can be used to
query and set a device's tuning mode by running:

> print tuning_mode
> set tuning_mode <FPGA|host>
2019-04-02 01:59:07 -07:00
Rey Tucker
7d58cdfada host: common: conversions: add tuningmode2str conversion 2018-12-12 16:42:52 -05:00
Rey Tucker
bdac315aab host: common: range.c: only build these if necessary on Nios 2018-12-06 14:45:24 -05:00
Rey Tucker
f644ceca63 host: common: add iterators.h
Adds iterators.h, which contains macros useful for iterating over
directions and/or channels.
2018-11-26 18:03:45 -05:00
Rey Tucker
05f7fd571a host: refactoring bladerf2.c
General documentation cleanup, function name adjustments, merging of
redundant structures, etc.

fpga_common/ad936x_helpers:
    Contains wrappers for AD936x RFIC functionality.

fpga_common/bladerf2_common:
    Contains bladeRF2-specific helper functions and constants.

fpga_common/ad936x_params:
    Reformat (no more tabs, phew)

    Move ina219 shunt const to bladerf2_common

host/common/range:
    Move functions and macros for handling bladerf_range structs

../libbladeRF/include/bladeRF2.h:
    Explicitly index RX/TX FIR enums

    Update references to ad936x_params.c

../libbladeRF/src/board/bladerf2/common:
    New macros for boilerplate:
        - WITH_MUTEX: wrap around locked blocks
        - CHECK_STATUS: calls function, checks return code
        - CHECK_AD936X: calls function, checks return code, translates
          from AD936x to libbladeRF error codes
        - CHECK_*_LOCKED: above, but unlocks mutex before erroring
        - NULL_CHECK: checks a var for null

    Move helper functions into here

../libbladeRF/src/board/bladerf2/bladerf2.c:
    Use new macros

    Code style fixes

    Remove redundant code
2018-11-26 18:03:45 -05:00
Rey Tucker
7939453551 host/fpga_common/thirdparty: move ad936x.h, params.c, config.h
Move these files into more common places, so they can be
used from the FPGA side of the world as well.
2018-11-26 18:03:45 -05:00
Brian Glod
881c3e1fd4 host: common/devcfg: check board name before setting gains
Wrap bladeRF1-only gain functions around a conditional so they are not
executed on bladeRF2 boards.

This commit is intended to be a stopgap to get the quick tune tests to
build and function on bladeRF2 devices. A follow-up commit using the
more generic 'system gain' functions would be optimal.
2018-11-26 16:03:46 -05: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
Rey Tucker
1631d827a8 host: parse.c: fix possible memory leak on realloc fail (fixes #690)
In the event the realloc fails, argout would be clobbered, losing
our only pointer to all of the allocated memory.

So, realloc into a new temporary variable, and then if that is
valid, set argout to it.

Also fixes an incorrect sizeof(int**)
2018-11-12 17:20:33 -05:00
Rey Tucker
c9a2230cf4
host: common: include pthread.h in nanosleep.h (#669) (#671)
* host: common: include pthread.h in nanosleep.h (#669)

default header sort on nanosleep.c puts nanosleep.h above
pthread.h, which creates an implicit definition of struct
timespec.

Fixes #669

* host: common/nanosleep: cleanup includes
2018-10-08 18:04:29 -04:00
Rey Tucker
fb9e6d02d0 host: libbladeRF/common: allow more accurate trigger labeling
This adds two new values for the bladerf_trigger_signal enum,
BLADERF_TRIGGER_J51_1 and BLADERF_TRIGGER_MINI_EXP_1, as well
as the necessary backend processing to make them work.

It turns out that it doesn't actually matter which one is chosen;
they all behave identically and interchangeably once they're passed
to the Nios interface functions.

The reason for this change is to reduce confusion, as the bladeRF
x40/x115 use J71-4 for mini_exp[1] and the bladeRF xA4/xA9 use
J51-1.
2018-09-26 12:43:16 -04:00
Mark Topham
4b7a72b2f0 host: common: Memory deallocation fix (#649)
parse.c is releasing memory for strings, after it assigns the memory location to a struct. This results in the memory potentially being overwritten by subsequent allocations before it's referenced.

Fixes #643
2018-09-21 12:09:59 -04: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
8fdfa6abcd
host: add nanosleep shim for Windows (#589)
Windows does not have nanosleep(), so this PR emulates it with a wrapper that calls Sleep().

* host/common: add nanosleep shim for Windows

* bladeRF-cli: on Windows, use nanosleep shim

* host/common: nanosleep: fixes for Windows building...

* host: common/nanosleep: convert to milliseconds, not microseconds

whoops
2018-08-24 15:36:04 -04:00
Rey Tucker
78286d47f9 host: common: add log_get_verbosity function
log_get_verbosity returns the current logging level, which may be useful
for situations where a lot of processing is required for verbose
logging, etc.
2018-08-01 16:24:54 -04:00
Rey Tucker
a6a58e5ed6
host: Windows build fixes (#62) 2018-06-01 18:29:02 -04:00
Rey Tucker
bd03766f20 host: parse.c: fix strnlen warning
Fixes:

host/common/src/parse.c:378:14: error: 'strncpy' specified bound depends
on the length of the source argument [-Werror=stringop-overflow=]

Allocating 128 bytes all the time resolves this.
2018-06-01 16:41:19 -04:00
Rey Tucker
fff07e422c
host: bladeRF_cli: add support for MIMO RX and TX (#57)
Adds support for multi-channel RX and TX via the bladeRF-cli utility
2018-05-30 15:27:54 -04:00
Rey Tucker
1dc6317b93
host: make low-level API calls generic by removing part numbers (#49)
Instead of using specific part numbers for low-level API calls on the bladeRF micro, use generic functionality-based names.
2018-05-25 10:55:04 -04:00
Rey Tucker
14c4cfeda1 host: common: add loopback2str conversion (#40)
Implements a loopback2str() function to convert a bladerf_loopback into a C string.

Also, formatting fixes by clang-format
2018-05-22 13:00:03 -04:00
Rey Tucker
03c687605b host: common/channel2str: fix misleading port names (#29) 2018-05-22 12:58:15 -04:00
Rey Tucker
ee55f859b9
host: clean up build warnings across multiple platforms (#21)
With this commit, we build without warnings on Arch Linux; CentOS 7; Debian 8 and 9; latest Fedora; Ubuntu 14.04, 16.04, 17.10, and 18.04; Visual Studio 2017; and macOS 10.13.3 w/ Homebrew.

* host: libbladeRF: compile AD9361 srcs with -std=gnu11

Fixes compile errors involving ‘for’ loop initial declarations only
allowed in C99 or C11 mode, on older GCCs.

* host: libbladeRF/adi: remove stdbool workaround

This is not necessary now that we're building to -std=gnu11, and in
fact, it seems to create a conflict.

* host: libbladeRF: pre-declare loop variables

Some compilers are not happy with declaring the loop variable in the for
statement.  Begrudgingly placate them.

* host: libbladeRF_test: pre-declare loop variables

Some compilers are not happy with declaring the loop variable in the for
statement.  Begrudgingly placate them.

* host: bladeRF-cli: pre-declare loop variables

Some compilers are not happy with declaring the loop variable in the for
statement.  Begrudgingly placate them.

* host: libbladeRF: remove refs to strings.h

Windows doesn't have strings.h, but string.h seems to do just fine.

* host: libbladeRF: fix windows compile errors (WIP)

* host: libbladeRF/ad9361: fix windows compile error

"IGNORE" is #define'd in the Windows environment, creating a conflict.
Renaming this to solve the conflict.

* host: common: add setenv implementation for Windows

* host: libbladeRF: build setenv.c stub on Windows

* host: bladeRF-cli: use setenv stub on Windows

* host: common: fixup spacing consistency in setenv

* host: libbladeRF: cast channel macros to bladerf_channel

Visual Studio is picky about this, and throws warnings.

* host: libbladeRF: bladerf2.c: undo workaround for bladerf_channel

* host: libbladeRF: bladerf_get_gain_stages count type is now size_t

This fixes a Windows compile error, and is also generally more sensible.

* host: bladeRF-cli: fix windows compile errors

* host: ad9361: fix variadic macro syntax

Fixes Windows build errors

* host: ad9361: rename _DEBUG to AD9361_DEBUG

Visual Studio automagically sets _DEBUG if the /MDd option is set. Turns
out that a lot of the debugging sections don't build in Visual Studio,
so this accounts for a large number of the build errors...

* host: libbladeRF: fixes for Visual Studio builds

* host: common: fixes for Visual Studio builds

* host: libbladeRF/ad9361: fixes for Visual Studio builds

* host: libbladeRF_test: fixes for Visual Studio builds

* host: bladeRF-cli: fixes for Visual Studio builds

* host: bladeRF-cli: fix static analysis warnings

Fixes potential memory leak in main

Fixes unused values in set_adf_refclk, set_samplerate

* host: common: fix static analysis warnings

fixes:
unread variable in perform_rx_cal
memory leaks in add_arg, add_opt

* host: libbladeRF: fix static analysis warnings

fixes unused variables in bladerf2_set_gain and xb100_enable
2018-04-03 18:20:51 -04:00
Rey Tucker
dc7094abb9 host: libbladeRF_test: win32 fixes for test_config_file (#546)
* host: common: add mkdtemp implementation for Win32

Windows does not have mkdtemp, which is something used by at least one
test case. This is a simple-enough implementation thereof.

* host: common/host_config: add more defs on Win32

chdir, getcwd, rmdir, unlink, and mkdir are all somewhat special on
Win32, so they need special handling.

* host: test_config_file: fix builds on Win32
2018-03-30 14:04:40 -04:00
Rey Tucker
14e7f317a2 host: common/conversions: add str2channel
Converts from a string to a bladerf_channel
2018-02-05 15:35:28 -05:00
Rey Tucker
b9db604801 host: common/conversions: add firmware and rf_bist loopback options 2018-02-05 15:35:28 -05:00
Rey Tucker
1bf9f4e9af host: common/host_config.h: add macro for fallthrough cases
GCC 7.x adds a warning for implicit fallthroughs in switch cases. We
intentionally do this sometimes, so adding an EXPLICIT_FALLTHROUGH macro
to denote this.

The __attribute__((fallthrough)) on a null statement is only supported
by GCC 7.x as well, hence the macro.
2018-01-15 17:55:17 -05:00
Vanya A. Sergeev
bccd7e19f7 libbladeRF: migrate api to 64-bit frequency 2017-12-21 12:54:58 -05:00
Vanya A. Sergeev
9062b66d9c libbladeRF: migrate bladerf_module to bladerf_channel and bladerf_direction 2017-12-21 12:54:58 -05:00
Vanya A. Sergeev
562243c80d libbladeRF: refactor codebase for multi-board support
Includes fixups for clean rebase atop bladeRF commit 8b420eb
2017-12-15 18:15:06 -05:00
Robert Ghilduta
a39a81d700 Add config option file parsing capabilities
This commit adds functions that parse config option files
2017-12-07 20:34:34 -08:00
Robert Ghilduta
68bf8e231a Add string parsing functions
The line to argumenet parser uses a two pass approach. The first pass
finds beginning and end of arguments, and counts the number of quotes.
The second pass copies the characters into the argument buffers.
2017-12-07 20:34:33 -08:00
Robert Ghilduta
82c424cc8c Add string manipulation functions 2017-12-07 20:34:33 -08:00
Robert Ghilduta
38664eaa10 Add bladeRF and libbladeRF specific look-ups and conversion 2017-12-07 17:10:28 -08:00
Robert Ghilduta
579199768c Cleanup files to add options file parser 2017-12-07 17:10:28 -08:00
Robert Ghilduta
dccc4edc2f Filenames are starting to become ambiguous without full pathnames 2017-12-07 17:10:28 -08:00
Rey Tucker
f680b9ba8c host: dc_calibration.c: fix int conversion in rx_cal_dc_off (#515)
MSVC warns of loss of precision on implicit conversion from float to
int16_t.  Instead of relying on truncation, do a proper round with
bounds-checking.
2017-08-04 15:21:22 -04:00
Rey Tucker
236753aaea clock_gettime.c: remove HAVE_CLOCK_GETTIME check
This is not necessary due to the fact that cmake only includes this file
if clock_gettime is missing in the first place.
2017-08-03 10:56:17 -04:00
Rey Tucker
5ba5f16221 clock_gettime.h: include host_config.h 2017-08-02 19:25:49 -04:00
Rey Tucker
0779109841 host: explicitly test for clock_gettime (#508)
Instead of using version-based guessing on macOS (which appears to fail
with newer versions of Xcode on older versions of macOS), use an
explicit test for clock_gettime in CMake.
2017-08-02 15:02:38 -04:00
Robert Ghilduta
b31d4e6d5c bladeRF-cli: print verbose output for DC LUT calculation 2017-07-05 08:59:08 -07:00
Robert Ghilduta
7aff155a97 libbladeRF: add gain specific mean errors to DC calibration table
The DC calibration table will now include mean residual errors for 3 different
gains (that will be used by the AGC amont other things) including:
    Max : LNA=6dB, RXVGA1=30dB, RXVGA2=15dB
    Mid : LNA=6dB, RXVGA1=30dB, RXVGA2= 0dB
    Low : LNA=3dB, RXVGA1=12dB, RXVGA2= 0dB

The DC cal table version has been bumped to 2. This commit will allow backward
compatibility with existing DC cal tables.
2017-07-05 08:59:08 -07:00
Thomas Brown
21690e5da0 libbladeRF: Use system clock_gettime on macOS >= 10.12. 2017-07-05 08:58:17 -07:00
Ian Frasch
63afe69ac5 bladeRF-fsk: Added support for Visual studio 2012
- Added round() and roundf() functions for VS version 2012 and below, since
    they lack implementation of these functions

- Minor formatting edits to make the compiler (v17.00.50727.1) happy
2016-08-22 16:13:20 -04:00
Jon Szymaniak
210591e8e2 host: common: Added conversion routines for bladerf_smb_mode 2016-05-17 00:20:01 -04:00
Jon Szymaniak
7656724db7 host: common: Added trigger role conversion routines 2016-05-17 00:20:01 -04:00
Jon Szymaniak
8c0ac5629d host/common: Added string <-> trigger enum conversion functions 2016-05-17 00:19:53 -04:00
Jon Szymaniak
2e042f122a host: common: Whitespace fix 2016-04-25 19:03:34 -04:00
Jon Szymaniak
3537c3a49a host: common: Added str2bool() conversion routine
This is intended for use with functions that require
enable/disable, on/off, true/false.
2016-04-25 19:03:34 -04:00