Commit graph

2,761 commits

Author SHA1 Message Date
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
Brian Glod
c456c889aa gitignore: Add cscope.files and cscope.out 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
fe730209dd fx3: fix spurious 0x40 error when ending loopback (#41)
When ending a loopback test (e.g. with
libbladeRF_test_digital_loopback), a spurious 0x40 error occurred from
trying to clear the glChHandlePtoU DMA channel, which does not get set
up if loopback is enabled.
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
4f634b79d2 hdl: bladerf-micro: latch data to ad9361 DAC
Latch the data heading to the DAC, so that it is valid when the AD9361
interface expects it.

This addresses a bug in single-channel TX mode where samples would get
rearranged under some circumstances.
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
0bdafe9769 host: bladeRF-cli: printset.c refactoring/cleanup (#33)
Moves the actual functions that do things into printset_hardware.c, printset_impl.c, and printset_xb.c, keeping printset.c for utility funcs.

Fixes a segfault when doing 'set agc' with no args.

Prints a warning if 'set gain' will not immediately take effect, as gain changes are not reflected immediately if RX is not active, and RX gain cannot be changed at all if AGC is active.

Renames print/set adf_enable -> print/set clock_ref
Renames print/set adf_refclk -> print/set refin_freq

Documentation update, consistency/display/formatting improvements.
2018-05-22 13:00:21 -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
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
e2475ee468 doc: update test_checklist.md for bladeRF micro (#30) 2018-05-22 12:58:21 -04:00
Rey Tucker
03c687605b host: common/channel2str: fix misleading port names (#29) 2018-05-22 12:58:15 -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
4d8a128758 fx3: version 2.1.1
This version corrects an issue with loading FPGA bitstreams from flash
in a headless configuration (with nothing connected to the USB
connector).
2018-04-06 15:27:07 -04:00
Rey Tucker
b144033168 fx3: skip EP Config during FPGA config if no USB
If the USB interface is not connected, CyU3PUsbGetSpeed() returns
CY_U3P_NOT_CONNECTED.  Previously we treated this as an error, which
caused failures when loading an FPGA bitstream from flash in a headless
configuration.

We now assume a reasonable DMA size and skip the USB configuration
altogether if there is no USB connection.
2018-04-06 15:27:07 -04:00
Rey Tucker
c14ec8d042
host: misc: general docker build improvements (#22)
- new build distinguishers:
  - compiler: gcc or clang
  - buildtype: Release or Debug
  - taggedrelease: NO or YES

- add com.nuand.ci.* labels for image metadata

- create a base image with a pruned checkout, to reduce disk consumption
  and to snapshot the working directory's state at the start of a build
  spree

- add -j$(nproc) to the make invocation

- reorganize Dockerfiles to improve build cache hits

- build.bash: iterate over rel, compiler, and buildtype, for a
  combination of 6 builds per distro version

- build.bash: general restructuring for DRY
2018-04-03 18:21:05 -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
Rey Tucker
0ecf2e1165
hdl: bladeRF-micro: pin-out changes for preprod rev 1.1 (#19)
* hdl: bladeRF-micro: adjust pin layout for rev1.1 hw

Update the pinouts for adi_{rx,tx}_spdt{1,2}_v{1,2} to reflect move from
bank 5A to banks 5B/4A

Move INA219 I2C pins to bank 5A

Move ADP2384 sync pins to bank 7A

Move ADF4002 control pins to bank 5A

* hdl: bladeRF-micro: move {rx,tx}_bias_en from bank 7A to 5A

rx_bias_en moves from J11 to R22
tx_bias_en moves from A13 to R21

* hdl: bladeRF-micro: move mini_exp{1,2}, rm c5_clock1

In Bank 7A,
c5_clock1 is deleted from H16
mini_exp1 moves from J18 to H16
mini_exp2 moves from J17 to H15

* hdl: bladeRF-micro: remove refs to c5_clock1

* hdl: bladeRF-micro: set max toggle rate for SPDT switches

Fixes Critical Warning (12888) for high estimated crosstalk
on adi_rx_data[1] by adi_{rx,tx}_spdt{1,2}_v[{1,2}]
2018-04-03 18:15:48 -04:00
Brian Glod
a8b283d2f0 host: misc: Add Python file conversion scripts
Add two Python scripts to convert between SC16Q11 binary and ASCII CSV.
2018-04-03 16:45:20 -04:00
Rey Tucker
fba7d40ba6 host: misc: add Dockerfiles for multi-distro test builds (#552)
* host: misc: add Dockerfiles for multi-distro test builds

It is now possible to perform test builds automatically across various
releases of Arch, CentOS, Debian, Fedora, and Ubuntu with:

bash host/mis/docker/build.bash

* host: docker: fix ld.so.conf for centos-7
2018-03-30 14:05:15 -04:00
Rey Tucker
f670bedc86 host: test: fix compile errors on test_config_file (#551)
On older compilers, 'for' loop initial declarations are not allowed by
default. So, use the old style for maximum compatibility.

h/t Christophe Devine
2018-03-30 14:05:08 -04:00
Rey Tucker
52f6c08063 host: libbladeRF_bindings: matlab: update libbladeRF_proto.m (#547)
* libbladeRF/matlab: change win64 bool type (#543)

This should fix an error in recent Thunk builds.  I am not sure what the
side effects of this will be (esp. with older Matlab versions) but this
seems to work now.

* host: libbladeRF_bindings: re-sort libbladeRF_proto.m to match recent MATLAB output

* host: matlab: update for libbladeRF 1.9.0

Add a few missing functions:

 bladerf_set_gain_mode
 bladerf_get_gain_mode
 bladerf_set_smb_mode
 bladerf_get_smb_mode
 bladerf_trigger_init
 bladerf_trigger_arm
 bladerf_trigger_fire
 bladerf_trigger_state
 bladerf_set_vctcxo_tamer_mode
 bladerf_get_vctcxo_tamer_mode
 bladerf_xb300_set_trx
 bladerf_xb300_get_trx
 bladerf_xb300_set_amplifier_enable
 bladerf_xb300_get_amplifier_enable
 bladerf_xb300_get_output_power
 bladerf_get_fw_log
 bladerf_init_stream
 bladerf_stream
 bladerf_submit_stream_buffer
 bladerf_submit_stream_buffer_nb
 bladerf_deinit_stream
 bladerf_read_trigger
 bladerf_write_trigger

Add a few missing structs and enums, related to above

Also remove the bool_ret/bool_arg vars, as they aren't really needed any
more.

* host: matlab: fixup uint64s, cleanup

Removed the 'pathsep' from the architecture case, since it's seemingly
set by matlab itself

Not pre-allocating ival, to avoid having to count that high

* host: matlab: comment out stream-related protos

Matlab doesn't support FcnPtrs (bladerf_stream_cb) or voidPtrPtrPtr
(void***), so bladerf_init_stream is not usable.  If bladerf_init_stream
isn't usable, then anything involving struct bladerf_stream isn't
usable.
2018-03-30 14:05:00 -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
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
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
4079d8af78 bladeRF 2018.03-alpha1 2018.03-alpha1
This version is part of development series of changes, not an official
release.

    * FPGA bitstream                v0.7.2
    * FX3 firmware                  v2.1.0
    * libbladeRF                    v1.9.1
    * bladeRF-cli                   v1.5.2
    * MATLAB & Simulink bindings    v0.1.3
    * Python bindings               v0.9.1
2018-03-26 16:30:42 -04:00
Rey Tucker
f7100bfc36 doc: Update outdated/missing release documentation 2018-03-26 16:30:17 -04:00
Rey Tucker
7cc30687c3 host: bladeRF-cli: version v1.5.2 bladeRF-cli_v1.5.2
This version is part of development series of changes, not an official
release.

This version depends upon libbladeRF v1.9.1 or later.

  * Support for bladeRF Micro
  * No longer initializes the bladeRF before loading a new FPGA image,
    to avoid potential catch-22 problems
2018-03-26 16:04:28 -04:00
Rey Tucker
fabe4f50a1 host: libbladeRF: version 1.9.1 libbladeRF_v1.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
0fcf5f8ed4 host: cmake: add missing quotes in STREQUAL compare firmware_v2.1.0
Without this, recent CMake releases can't handle an empty
VERSION_INFO_EXTRA.
2018-03-26 15:32:43 -04:00
Rey Tucker
68df533b3c host: libbladeRF: add FPGA 0.7.2 to compat tables fpga_v0.7.2 2018-03-26 15:23:39 -04:00
Rey Tucker
7a1f577349 hdl: update changelog, set version 0.7.2 2018-03-26 15:22:56 -04:00
Rey Tucker
ba8e485d2f host: python: set version = 0.9.1 (so we can bump to 1.0.0 at release) python_v0.9.1 2018-03-26 12:44:50 -04:00
Rey Tucker
5240d995b0
host: python: Python packaging (#18)
* host: python: reorganize files for packaging

* host: python: move bladerf-tool CLI into main()

* host: python: move cdef string into its own file

Since packaging lets us have multiple files easily, this cleans up
bladerf.py a lot.

* host: python: add __init__.py skeleton

* host: python: fixup py3flakes and pycodestyle

* host: python: fix unused local variable

* host: python: more reorganization to appease Python

* host: python: update .gitignore for setup detritus

* host: python: initial setup.py

* host: python: update accompanying documentation

* host: python: cleanup setup.py

* host: python: move license stuff into files

* host: python: version 1.0.0
2018-03-26 12:26:46 -04:00
Rey Tucker
f857b28b34
host: python: fix up error handling on rssi property (#17) 2018-03-23 16:28:24 -04:00