Commit graph

3,016 commits

Author SHA1 Message Date
Brian Glod
098705cce8 hdl: command_uart: add retune2 packet magic 2018-11-26 16:03:46 -05:00
Brian Glod
15d8781f8b nios: add retune2 packet handler
Process retune2 packets for bladeRF2 devices.
2018-11-26 16:03:46 -05:00
Brian Glod
4d9cc217f9 nios: add fast lock save via 8x32 packet ID 0x05
When an 8x32 packet is received with target ID 0x05, the
ad9361_fastlock_save() function is executed. The packet requires an
address to be specified, which is used to determine whether the
operation is for the RX or TX module. Valid addresses are:

  0x00  : receive module
  0x01  : transmit module
  others: do not use, but would be passed to the receive module
2018-11-26 16:03:46 -05:00
Brian Glod
28ea59c83b fpga_common: add retune2 Nios packet format
This is the retune packet for use with bladeRF2 devices.
2018-11-26 16:03:46 -05:00
Brian Glod
1302a0b23a nios: add fast lock functions for bladeRF2, increase RAM
Adds fast lock functions to save/load/recall, and change port/spdt
settings:

 - ad9361_fastlock_save(): save fast lock profile from AD9361 to BBP
 - ad9361_fastlock_load(): load fast lock profile from BBP to AD9361
 - ad9361_fastlock_recall(): use a previously loaded fast lock profile
 - ad9361_rfport_select(): change RF port selection on AD9361
 - ad9361_rfspdt_select(): change external RF SPDT switch settings

Increased the RAM size of the Nios from 16 KB to 32 KB in order to
hold 512 AD9361 fast lock profile structures (256 RX profiles, 256 TX
profiles). Each profile contains 20 bytes, of which 16 bytes are
consumed by the AD9361 profile data.

The value of 256 RX/TX fast lock profiles was chosen because it seemed
high enough for most applications, but not so large that it would waste
a lot of FPGA resources. However, the number of profiles may be
increased or decreased (as resources allow) to meet application demand.
2018-11-26 16:03:46 -05:00
Brian Glod
a8e3e67568 host: libbladeRF/bladeRF2: implement bladerf2_get_quick_tune()
Update bladerf_quick_tune structure for bladeRF2 data. It now contains:
- profile (profile number, integer)
- data    (profile data, 16 bytes)

Fill in the bladerf2_get_quick_tune() function. The bladeRF2's RFIC uses
the concept of fast lock profiles, of which there are 8 for TX and 8 for
RX. These profiles store the VCO information needed to quickly change
frequencies. To use more than 8 profiles, the profiles may be stored
off-chip, which is what we're doing here.

1. It is assumed the RFIC has been tuned to a particular frequency.
2. The profile is created using ad9361_fastlock_store().
3. The profile is read back and stored in host memory using
   ad9361_fastlock_save().
2018-11-26 16:03:46 -05:00
Rey Tucker
0bc1f8cfcd host: test_ctrl: fix rounding, types, and casts
Windows build fixes...
2018-11-19 16:14:59 -05:00
Rey Tucker
2c7ceb5560 host: test_ctrl: improved direction/channel iterators
Windows was not happy with how I was doing things. And honestly, I
wasn't entirely happy either :)

This seems to work better, with less weird punctuation.
2018-11-19 16:14:59 -05:00
Rey Tucker
dc72e2cc64 host: test_ctrl: typedef failure_count as an alias for size_t 2018-11-19 16:14:59 -05:00
Rey Tucker
3a9f1ceaa8 host: test_repeated_stream: don't initialize pthreads
On Windows, pthread_t is a struct {void *p; unsigned int x;} and
initializing it to 0 is unwise.

On Linux, pthread_t is unsigned long int.

Fixes MSVC Error C2440
2018-11-19 16:14:59 -05:00
Rey Tucker
a4bdef90d4 host: test_ctrl: skip test_threads if using bladerf2+host tuning
This puts the RFIC driver into a bad state, and I'm not entirely sure
why yet.
2018-11-19 13:23:04 -05:00
Rey Tucker
4f1d9c08fd host: test_ctrl: fix lockup during test_threads
test_gain now enables a channel before poking the gain, which is
required to pass the test on bladerf2.  however, test_threads
already enables the channels in question, which resulted in the
test locking up and failing.
2018-11-19 13:23:04 -05:00
Rey Tucker
9425859a48 host: test_ctrl: fix up gain test to work with bladerf2 2018-11-19 13:23:04 -05:00
Rey Tucker
df5354b156 host: test_ctrl: factor out direction/channel iteration 2018-11-19 13:23:04 -05:00
Rey Tucker
9c77978195 host: test_ctrl: update channel types, clang-format
Replaces bladerf_module with bladerf_channel throughout.

Cleans up formatting, code style, etc
2018-11-19 13:23:04 -05:00
Rey Tucker
812b54cbbd host: test_ctrl: fixup some tests to work with bladerf2 2018-11-19 13:23:04 -05:00
Rey Tucker
2d3b53f9ea host: test_ctrl: exit early if hardware is not supported 2018-11-19 13:23:04 -05:00
Rey Tucker
8ba6223638 host: test_ctrl: add --tuningmode command line option 2018-11-19 13:23:04 -05:00
Rey Tucker
90c07051e6 host: bladerf2: fix overeager FIR filter setting in set_sample_rate
If we've already done the FIR filter change for low sample rates,
we don't need to do it again when changing to another low sample
rate.
2018-11-16 16:01:41 -05:00
Rey Tucker
c2d991b09e host: bladerf1: fix apportioning of overall gain
_apportion_gain did not pay heed to the step size of the gain
range, causing it to end up with invalid values for LNA and
RXVGA2.

We now ensure that the allocation mod <stepsize> is 0, so that
other, more flexible gain stages can be used to pick up the
remainder.
2018-11-16 14:34:31 -05:00
Rey Tucker
3211d25f4e libbladeRF: configfile.c: fixup biastee options
Rename configuration keys to "biastee_tx" and "biastee_rx"

Use str2bool for consistency

clang-format

Add documentation
2018-11-12 18:35:04 -05:00
Mark Topham
611397ac67 Added rx_biastee_en and tx_biastee_en as keys in config
To enable:

rx_biastee_en 1
tx_biastee_en 1

To disable:

rx_biastee_en 0
tx_biastee_en 0
2018-11-12 18:35:04 -05:00
Mark Topham
2b1dea64bf Added rx_biastee_en to enable BT 200 - LNA via config 2018-11-12 18:35:04 -05:00
Rey Tucker
35e38e7e6b libbladeRF: bladerf_load_fpga: release mutex on error (fixes #680)
In the event dev->backend->load_fpga fails, we need to unlock
the mutex or else we're gonna have a bad time tearing everything
down.
2018-11-12 18:18:16 -05:00
Rey Tucker
cd6d78c76f libbladeRF: bladerf1: improve AGC-unavailable messaging (fixes #686)
New messages have a lower severity, explain what will happen
instead (manual gain control), and include an info message with
guidance for solving the issue.
2018-11-12 18:18:03 -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
d943246c92 libbladeRF: bladerf1.c: fix null ptr dereference (fixes #696) 2018-11-12 17:20:33 -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
146215e2f3 fpga_common: lms.h: check return val in lms_set_frequency (fixes #691)
If lms_calculate_tuning_params is unsuccessful, then
lms_set_precalculated_frequency is called with an uninitialized
lms_freq struct.
2018-11-12 17:20:33 -05:00
Rey Tucker
f6d78e1e58 libbladeRF: bladerf2.c: fix typo in _check_total_sample_rate (fixes #692) 2018-11-12 17:20:33 -05:00
Rey Tucker
7e2f883db3 libbladeRF: libusb.c: fix unread status variable warning (fixes #693) 2018-11-12 17:20:33 -05:00
Rey Tucker
084587b776 bladeRF-cli: fix memory leak in CSV-to-SC16Q11 conversion (fixes #694) 2018-11-12 17:20:33 -05:00
Rey Tucker
6f4c155077 libbladeRF_test: fix spurious uninitialized variable warning (fixes #695) 2018-11-12 17:20:33 -05:00
Rey Tucker
e098b3c1a5 host: docker: quality-of-life tweaks
freshen now cleans up old containers

parallel build temp dir has a template
2018-11-12 16:12:00 -05:00
Brian Glod
8cc9538629 hdl: build: Fix escaping for Windows
Escaping the double quotes worked on Linux, but not on whatever
abomination of Cygwin's bash. The work-around uses braces. This works
because Tcl interprets them as single quotes while bash ignores them,
allowing the substitution to happen.
2018-11-11 16:18:09 -05:00
Brian Glod
6220a09fc8 hdl: build: Add device and device family to Qsys scripts
Previously, the device and device family were just hard-coded in the
Qsys scripts. This wasn't a problem because the generated code/system is
compatible within a device family. However, this change makes things
more explicit to avoid confusion and perhaps take advantage of any
optimizations, warnings, or limitations that may be differ among devices
within a family.
2018-11-09 19:13:59 -05:00
Brian Glod
8d8dc7ea04 hdl: nios: Fix Eclipse project and update README 2018-11-01 19:12:58 -04:00
Rey Tucker
4a61cfb568 docker: add opensuse-latest build test 2018-10-31 16:43:17 -04:00
Rey Tucker
98414e862b docker: allow specifying targets, omitting _base 2018-10-31 16:42:55 -04:00
Rey Tucker
db24d41023 bladeRF 2018.10-rc1 2018.10-rc1
This release introduces new functionality and bug fixes, generally expanding
support for the bladeRF 2.0 Micro. It consists of the following versions:

    * FPGA bitstream                v0.9.0
    * FX3 firmware                  v2.3.1
    * libbladeRF                    v2.1.0
    * bladeRF-cli                   v1.7.0
    * MATLAB & Simulink bindings    v1.0.2
    * Python bindings               v1.1.0

Note to bladerf1 (x40/x115) users: AGC will not work with FPGA versions
older than v0.8.0, due to a change in the control register mapping. A warning
will be printed during device initialization if you are using an affected
FPGA version.

Summary of changes since 2018.08:

* FPGA
    - Support for the ADS-B core on bladeRF micro
    - Add metadata flags for miniexp{1,2} IO pin status
    - Fix race condition during FX3/Nios UART initialization
    - Fix bugs in bladeRF AGC control
    - Timing closure improvements
    - Build system fixes

* FX3
    - Fix USB device reset interrupting SPI flash autoloading of FPGA images
    - Add BLADE_USB_CMD_QUERY_FLASH_ID command
    - Add BLADE_USB_CMD_QUERY_FPGA_SOURCE command

* libbladeRF
    - API additions:
        - Add format macros for bladerf_frequency and bladerf_timestamp
        - Add 'manufacturer' and 'product' device description strings to
          bladerf_devinfo struct
        - Add bladerf_get_serial_struct() API function
        - Add bladerf_get_flash_size() API function
        - Add bladerf_trigger_signal values for J51-1 (bladerf2) and Miniexp-1
          (generic)
        - Add bladerf_get_fpga_source() API function
        - Add meta RX hardware flags for underflow, miniexp{1,2}
    - Fixes:
        - bladerf2: support TX frequencies down to 47 MHz
        - bladerf2: support sample rates down to 0.521 Msps
        - bladerf1: fix BLADERF_GPIO_AGC_ENABLE
        - bladerf2: fix bladerf_trigger_arm implementation
        - streaming: extend USB transfer timeout to match the configured stream
          timeout
    - Misc:
        - Install the doxygen docs, if generated
        - Adjust RX gain mode lists for clarity
        - bladerf1: implement bladerf_{get,set}_rf_port[s]
        - bladerf1: skip initialization if BLADERF_FORCE_NO_FPGA_PRESENT is set

* bladeRF-cli
    - Add libedit support
    - Ensure device is initialized after deferred open
    - info: display manufacturer, product, flash size
    - print: show RF routing on bladerf1
    - print: display supported ranges for sample rate, bandwidth, frequency
    - probe: handle already-open devices
    - version: display FPGA configuration source

* MATLAB & Simulink bindings
    - Add missing BB_TXVGA1_RXLPF loopback option
    - Fix tx_gain property handling in simulink

* Python
    - Fix rx_channel_count, tx_channel_count
    - Update with latest API functions

* Windows installer
    - install-drivers: install a driver for the bootloader VID/PID (04b4:00f3),
      allowing easier FX3 bootloader recovery operations
    - Upgrade to libusb 1.0.22
2018-10-30 17:12:29 -04:00
Rey Tucker
c490baa215 Python bindings v1.1.0 python_v1.1.0
Note: an erroneous python_v1.0.2 tag was created, which is basically
identical to this, but had the wrong version number. I apologize for any
confusion this may cause.
2018-10-30 16:45:24 -04:00
Rey Tucker
01e2dc6e22 MATLAB v1.0.2 matlab_v1.0.2 2018-10-30 16:41:29 -04:00
Rey Tucker
6b659c2dcc bladeRF-cli v1.7.0 bladeRF-cli_v1.7.0 2018-10-30 16:40:20 -04:00
Rey Tucker
97d0cfae2f libbladeRF v2.1.0 libbladeRF_v2.1.0 2018-10-30 16:34:14 -04:00
Rey Tucker
344e677dea host: backend/cyapi: fix cyapi_get_flash_id compile fail on Windows 2018-10-30 16:08:26 -04:00
Rey Tucker
d69b71f396 debian: update firmware pointer to v2.3.1 2018-10-30 15:24:54 -04:00
Rey Tucker
238ac3a8e7 debian: update FPGA pointer v0.8.0 -> v0.9.0 2018-10-30 15:23:35 -04:00
Rey Tucker
dc83ca473f hdl: build: add -S option to specify fitter seed
Optional argument to set the seed for a build.
2018-10-26 20:10:17 -04:00
Rey Tucker
a0f89f40ad hdl: fpga_v0.9.0 fpga_v0.9.0 2018-10-26 16:38:41 -04:00
Rey Tucker
95aa1837fb host: libbladeRF: add FPGA v0.9.0 compat 2018-10-26 16:37:24 -04:00