Commit graph

1,136 commits

Author SHA1 Message Date
Rey Tucker
7a0aeaba38 host: libbladeRF: add FPGA 0.7.3 compat 2018-08-07 17:46:09 -04:00
Rey Tucker
4b8a02ad8d host: libbladeRF: readability on nios_ad9361_spi_* verbose logging
Fix up the verbose logging on nios_ad9361_spi_read/write so that the
numbers line up, and so that it expands out multi-reads and multi-writes
in a useful fashion.
2018-08-01 16:23:47 -04:00
Rey Tucker
dbe0f12c3f
host: libbladeRF: add additional debugging to sync streaming (#64)
In the event of a timeout, an error is emitted from the actual place where the timeout occurred.

Also, if ENABLE_LIBBLADERF_SYNC_LOG_VERBOSE is defined, it will now print out a condensed status of all the buffers on each run through the sync state machine.

* host: sync: add error message when wait_for_buffer times out

* host: libusb: add error message for timeout

* clean up wording on libusb.c err a bit

* host: sync_worker: add debug prints on init failures

* host: bladerf2: print wallclock time on enable_module

* host: sync: add more super-verbose debug print

* host: sync: simplify ifdef

* host: libbladeRF: clang-format modified functions
2018-07-24 16:21:51 -04:00
Rey Tucker
98d4452597 host: libbladeRF/bladerf2: quick clang-format fixes 2018-07-18 15:47:06 -04:00
Rey Tucker
52605a0ef4
host: libbladeRF/bladerf2: reset RX FIFO when enabling a second RX channel; refactor/cleanup (#63)
Corrects an issue where enabling multiple RX channels would create some confusing discontinuities in the sample stream.

The first RX channel configured would start samples buffering in the FIFO, but the second configuration would not be apparent until after those samples were read.

This PR also does a general refactoring of bladerf2_enable_module and associated helper functions to make the logic flow more clear.
2018-07-12 16:14:40 -04:00
Robert Ghilduta
63f8162e6e libbladeRF: update fx3 firmware compatibility 2018-06-20 05:42:03 -04:00
Robert Ghilduta
70acf8a303 libbladeRF: load bladeRF2 size and calibration value from flash
This effectivelly makes the bladeRF2 behave similarly to the bladeRF1.
2018-06-20 00:50:31 -04:00
Rey Tucker
a6a58e5ed6
host: Windows build fixes (#62) 2018-06-01 18:29:02 -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
769a9c98c2
host: libbladeRF: clean up magic numbers in bladerf2.c (#60) 2018-06-01 15:52:03 -04:00
Rey Tucker
7dc32cc56f
host: bladerf_get_channel_count now takes a bladerf_direction (#58)
This is more intuitive than 'bool tx'.
2018-06-01 15:49:04 -04:00
Rey Tucker
36291292db host: libbladeRF: fix formatting error on version.h.in 2018-05-30 15:33:41 -04:00
Rey Tucker
2c950ad246 host: libbladeRF: clang-format doc examples (#56) 2018-05-30 15:27:07 -04:00
Rey Tucker
2d62faa36f
host: libbladeRF: clang-format the *.h files (#55) 2018-05-30 15:26:28 -04:00
Rey Tucker
ae129c5ccd
host: libbladeRF: improve consistency of 'const' modifier location (#54)
I have a tendency to put 'const' in the middle of the type, e.g. struct bladerf_range const **range

I can argue that it is superior to do it that way, but I don't want to, as it makes no difference and just looks weird :)

* libbladeRF.h: put const at start of type

* board.h: move const to the start of types
2018-05-29 13:11:05 -04:00
Rey Tucker
5ef5199d88
host: bladerf_get_*_range now expect struct bladerf_range** (#53)
* libbladeRF: brf_get_*_range expect bladerf_range**

Previously, the bladerf_get_*_range family of functions expected a
struct bladerf_range *

The gain-related functions turned out to require a double ptr to work
properly. For consistency, this commit changes libbladeRF to use a
double ptr on all the range functions, instead of just the gain ones.

* bladeRF-cli: update get-range function calls
2018-05-29 13:10:49 -04:00
Rey Tucker
a0d498e723
host: typedef common parameter types (#51)
* libbladeRF: add typedefs for common parameter types

This adds typedefs for, and changes libbladeRF.h to use said typedefs
for, the following:

bladerf_gain -> int
bladerf_sample_rate -> unsigned int
bladerf_bandwidth -> unsigned int
bladerf_frequency -> uint64_t
bladerf_timestamp -> uint64_t
bladerf_correction_value -> int16_t
2018-05-25 11:45:38 -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
c74c6282ad
host: improve platform-independence of bladerf_{set,get}_gain (#48)
The bladerf_{set,get}_gain functions are now reasonably hardware-independent.

On TX channels, setting a gain of 60 dB should result in a CW TX power of roughly 0 dBm.

On RX channels, 60 dB is the maximum gain level.

The ranges returned by bladerf_get_gain_range are adjusted to reflect this.
2018-05-25 10:53:58 -04:00
Brian Glod
cf50e88480 host: bladeRF2: remove set/clr of BLADERF_GPIO_TIMESTAMP_DIV2 (#52)
The Nios config GPIO bit used for BLADERF_GPIO_TIMESTAMP_DIV2 was
repurposed in bladeRF2 to be used as the UFL output clock enable
bit. Commit fixes unintentional clearing of this bit when timestamps are
not used.
2018-05-25 10:53:21 -04:00
Rey Tucker
7f32bf40c0
host/libbladeRF: move config file handling to its own file (#50) 2018-05-24 13:53:52 -04:00
Rey Tucker
8ebd48ce05
host: Release notes for libbladeRF 2 (#46) 2018-05-23 12:15:20 -04:00
Rey Tucker
5023f0cb03
host: fix build errors and clang-scan warnings (#47)
* devinfo: fix strncpy error

Fix two build errors on Arch:

/root/bladeRF/host/libraries/libbladeRF/src/devinfo.c:308:5:
error: ‘strncpy’ destination unchanged after copying no bytes
[-Werror=stringop-truncation]
/root/bladeRF/host/libraries/libbladeRF/src/devinfo.c:308:5:
error: ‘strncpy’ output truncated before terminating nul copying as many
bytes from a string as its length [-Werror=stringop-truncation]

* bladerf2/params: fix implicit conversion error

/root/bladeRF/host/libraries/libbladeRF/src/board/bladerf2/params.c:437:7:
error: implicit conversion from 'int' to 'int16_t' (aka 'short') changes
value from 32768 to -32768 [-Werror,-Wconstant-conversion]
      32768,      0,      0,      0,      0,      0,      0,      0,
      ^~~~~

* Doxyfile: fix CLANG_ASSISTED_PARSING warning

fixes:

warning: Tag `CLANG_ASSISTED_PARSING' at line 1033 of file
`/root/bladeRF/build/host/libraries/libbladeRF/doc/doxygen/Doxyfile'
belongs to an option that was not enabled at compile time.
         To avoid this warning please remove this line from your
configuration file or upgrade it using "doxygen -u", or recompile
doxygen with this feature enabled.
warning: Tag `CLANG_OPTIONS' at line 1041 of file
`/root/bladeRF/build/host/libraries/libbladeRF/doc/doxygen/Doxyfile'
belongs to an option that was not enabled at compile time.
         To avoid this warning please remove this line from your
configuration file or upgrade it using "doxygen -u", or recompile
doxygen with this feature enabled.

* libbladeRF: fix doxygen build error

fixes:
/home/rtucker/dev/privatebladeRF/host/libraries/libbladeRF/include/libbladeRF.h:2284:
warning: unable to resolve link to `sync_tx_meta.html' for \link command

* bladeRF-fsk: fix clangscan warning

/root/bladeRF/host/utilities/bladeRF-fsk/c/src/correlator.c:261:59:
warning: The left operand of '/' is a garbage value
        corr->ins1->real = corr->ins2->real = samples[i].i/2048.0f;
                                              ~~~~~~~~~~~~^
1 warning generated.

* fpga_common/lms.c: fix clangscan warning

/root/bladeRF/fpga_common/src/lms.c:2329:14: warning: 3rd function call
argument is an uninitialized value
    status = write_vcocap(dev, base, f->vcocap, vcocap_reg_state);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* test_repeated_stream: fix clangscan warning

/root/bladeRF/host/libraries/libbladeRF_test/test_repeated_stream/src/main.c:284:9:
warning: 1st function call argument is an uninitialized value
        pthread_join(rx_thread, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* test_interleaver: fix clangscan warning

/root/bladeRF/host/libraries/libbladeRF_test/test_interleaver/src/main.c:119:17:
warning: 4th function call argument is an uninitialized value
                snprintf((rowstr + rowidx), rowsize - rowidx, "%02x",
*u8buf++);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* test_tx_gmsk_bursts: fix clangscan warning

/root/bladeRF/host/libraries/libbladeRF_test/test_timestamps/src/test_tx_gmsk_bursts.c:69:5:
warning: 2nd function call argument is an uninitialized value
    printf("  Frequency: %u\n", s->frequency);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* ad9361_api.c: fix clangscan warning

/root/bladeRF/host/libraries/libbladeRF/src/driver/thirdparty/adi/ad9361_api.c:445:3: warning: Value stored to 'ret' is never read
                ret = -ENODEV;
                ^     ~~~~~~~
1 warning generated.

* correlator: another attempt to fix clangscan warning

* Revert "fpga_common/lms.c: fix clangscan warning"

This reverts commit 8cbb5f03f0d0927befa5053e9564df06d13ede72.

* test_interleaver: fixup clang-scan warning

some sloppy init, some messy iteration, the usual :)

/root/bladeRF/host/libraries/libbladeRF_test/test_interleaver/src/main.c:124:17:
warning: 4th function call argument is an uninitialized value

* Revert "ad9361_api.c: fix clangscan warning"

This reverts commit 14a7f8f53f84aeff721a752259ca9596a13e3a2a.

* bladeRF-fsk: fixup clang-scan warning fix
2018-05-23 12:14:26 -04:00
Rey Tucker
df8b3cbe67 host: libbladeRF/bladerf2: improve clamp warning (#45)
Fix the accuracy of the warning message when clamping a value within the
range.
2018-05-22 13:00:21 -04:00
Rey Tucker
a8588792b6 host: libbladeRF: remove unnecessary locks from informational functions (#44)
The functions which return ranges, available modes, gain stages, etc, do
not directly access the hardware and should therefore not need locks
around them.
2018-05-22 13:00:21 -04:00
Rey Tucker
ac127997b0 host: libbladeRF/bladerf2: AD9361 FIR filter revisions (#43)
* host: libbladeRF/bladerf2: FIR filter updates

New FIR filters based upon research and experimentation.  The default RX
FIR filter was built using Analog Devices' filter design tools, which
account for the filters upstream of the RX FIR block.

Additionally, two 128-tap, decimate/interpolate-by-2 filters are
present, for RX and TX, providing an even flatter spectrum under certain
circumstances.

* host: libbladeRF/bladerf2: default bypass TX FIR

The default TX FIR filter configuration literally does nothing, so this
disables it entirely by default.
2018-05-22 13:00:21 -04:00
Rey Tucker
a16a670339 host: libbladeRF: temporary workaround for A9s
To use an A9 board, simply:

BLADERF_FORCE_FPGA_A9=1 bladeRF-cli -i

(this is only important for the FPGA bitstream load after power-on)
2018-05-22 13:00:21 -04:00
Rey Tucker
4cae7e59ee host: libbladeRF: fix compile errors on cyapi.c (#42)
* host: libbladeRF: fix async.h include in cyapi.c

* host: libbladeRF: add devinfo.h include to cyapi.c

* host: libbladeRF: cyapi.c: swear profusely at MSVC
2018-05-22 13:00:21 -04:00
Rey Tucker
3294b225e7 host: libbladeRF: fix status handling on brf2_set*_sample_rate 2018-05-22 13:00:21 -04:00
Rey Tucker
be373f4122 host: libbladeRF/bladerf2: add debug printfs around ad9361_init 2018-05-22 13:00:21 -04:00
Rey Tucker
2483acc334 host: libbladeRF/thirdparty: remove printf from ad9361_init 2018-05-22 13:00:21 -04:00
Rey Tucker
760bfdc026 host: libbladeRF/bladerf2: enable support for RX/TX timestamps (#36) 2018-05-22 13:00:21 -04:00
Rey Tucker
98442e2187 host: libbladeRF/bladerf2: fix TX atten cache scale (#32)
This value needs to be scaled before going into the cache.
2018-05-22 12:58:33 -04:00
Rey Tucker
df36134c7f host: libbladeRF/bladerf2: remove RETURN_ERROR_STATUS_ARG (#31)
it doesn't work in all situations, so it's not a particularly useful
macro
2018-05-22 12:58:27 -04:00
Rey Tucker
8919cac557 host: add support for AD9361's CTRL_OUT pins (#28)
* host: libbladeRF: add bladerf_ad9361_get_ctrl_out

Adds functionality to read the CTRL_OUT pins from the AD9361 RFIC.

* host: bladeRF-cli: add print for AD9361 CTRL_OUT

* host: python: add support for ad9361_ctrl_out
2018-05-22 12:58:06 -04:00
Rey Tucker
9b18caca94
host: doxygen: enable Files tab, ensure rebuild on layout change (#27) 2018-04-06 15:28:51 -04:00
Rey Tucker
790a197aca
host: libbladeRF: deprecate some low-level bladeRF1 function calls (#26)
* host: libbladeRF: deprecate bladeRF1 gain controls

We now have bladerf_{get,set}_gain and bladerf_{get,set}_gain_stage,
which are both general-purpose functions replacing the bladeRF1-specific
VGA/LNA library calls.

* host: libbladeRF: deprecate bladeRF1 trimdac controls

Instead of bladerf_dac_write and bladerf_dac_read, folks should use
bladerf_trim_dac_write and bladerf_trim_dac_read.
2018-04-06 15:28:34 -04:00
Rey Tucker
cc272ff31a
host: libbladeRF: fix segfault when loading wrong FPGA image (#25)
Also streamline FPGA valid check a bit
2018-04-06 15:28:10 -04:00
Rey Tucker
666d031c6c
host: libbladeRF: fix missing cast, logic cleanup (#24)
Missed a spot in apply_config_options...
2018-04-06 15:27:52 -04:00
Rey Tucker
d8717452d2 host: libbladeRF: update compat table for FW 2.1.1 2018-04-06 15:27:07 -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
d23e2c8bf3
host: libbladeRF: bladerf.c formatting/cleanup and updates (#20)
* host: libbladeRF: clang-format of bladerf.c

* host: libbladeRF: update apply_config_options

Update apply_config_options to use new semantics for channel specifiers
and range min/max determination

Also fix a couple typos

* host: libbladeRF/doc: fixup old channel references
2018-04-03 18:16:21 -04:00
Jean-Michel Picod
a832b38993 Fix mutex handling for Windows in libusb backend. (#550)
Calling ReleaseMutex without CloseHandle will let the mutex still exist until the process exists.
In such scenario, further calls to CreateMutex will succeed but GetLastError will return 183 (ERROR_ALREADY_EXISTS) causing libbladerf to fail opening the device. This can be assessed by running ```libbladeRF_test_open.exe -c 2 -v debug```.

Cypress backend is not affected as it systematically closes the handle after releasing the mutex.
2018-03-30 14:04:50 -04:00
Rey Tucker
fe813e3be8 host: libbladeRF/config.c: fix type error (#544) (#545) 2018-03-30 14:04:09 -04:00
Robert Ghilduta
e936b43162 libbladeRF: remove spurious printf 2018-03-30 14:02:25 -04:00
Rey Tucker
9761a90ec2 host: libbladeRF: Add documentation and test program for config file handling (#539)
* host: libbladeRF: fix typo of "bandwidth" cfg file key

* host: libbladeRF: add documentation for config files

* host: libbladeRF: config.c: minor typo fix

* host: libbladeRF_test: add test case for config file parsing

Creates a surrogate config file with a few different scope restrictions,
then makes sure the configuration is applied appropriately in the end.
2018-03-30 14:01:32 -04:00
Christian Inci
e48306d415 Fix wrong usage of str2bool
This leads to AGC being disabled on every call of bladeRF-cli.
Please see https://github.com/Nuand/bladeRF/blob/master/host/utilities/bladeRF-cli/src/cmd/xb300.c#L117 for the proper usage.

I'm not sure if only checking LSB is the proper way to do it, as val (uint32_t) is uninitialized and str2bool sees it as bool (on my machine "off" is 2048 and "on" is 2049), but it would even work if those "else if's" are being
reordered, thus initialized by something else to a non-zero value, or you could zero it right before the str2bool call.
The printf call might not be needed anymore.

Notes:
With the latest changes in kalibrate-bladeRF (add win32 support), changing the buffer sizes of m_x_cb, m_y_cb, m_e_cb, the results of the program look even more odd. Were those changes intended? Either the outputs are correct
before and after the patch, or one BTS has the worst clock in history. I think it's the second one.
With the latest FPGA change (0.7.0 -> 0.7.1, using edge_detector instead of pulse_gen), even setting the sample rate can sometimes lead to a failure. (At least on my board, only shortly after power-on)

Have a nice weekend!

Signed-off-by: Christian Inci <chris.gh@broke-the-inter.net>
2018-03-30 13:58:45 -04:00
Rey Tucker
fabe4f50a1 host: libbladeRF: version 1.9.1
This version is part of development series of changes, not an official
release.

This version of libbladeRF is intended for use with:

FX3 Firmware v2.1.0 (or v1.9.1)
FPGA         v0.7.2

Changes:
 * Refactor to support for multiple product lines
 * Add support for the bladeRF Micro product
 * API: replace bladerf_module with bladerf_channel, a
   reverse-compatible change to handle products with multiple
   independent RF paths in the same direction
 * API: BREAKING CHANGE - on bladerf_set_frequency, et al, the frequency
   parameter is now uint64_t instead of unsigned int
 * Significant code cleanup
 * Various other changes that will be listed in more detail during an
   official release
2018-03-26 15:53:33 -04:00
Rey Tucker
68df533b3c host: libbladeRF: add FPGA 0.7.2 to compat tables 2018-03-26 15:23:39 -04:00
Rey Tucker
27e7273b42
host: formatting fixes for clang-format, libbladeRF.h comment wording/structure tweaks (#16)
* host: libbladeRF: clang-format fixes

* host: bladeRF-cli: clang-format fixes

* host: libbladeRF: spacing/wording/clang-format

Improve wording of various parts, add missing params, clean up various
wrap anomalies, and make it run clean through clang-format.
2018-03-23 11:17:57 -04:00