Commit graph

3,108 commits

Author SHA1 Message Date
Rey Tucker
6bdec2e32b host: libbladeRF: check for null rfic ptr in bladerf2_close
Fixes segfault after flashing FPGA image
2018-12-21 01:28:17 -08:00
Rey Tucker
cdc05b150b host: libbladeRF: show percentage when doing flash ops
Calculate and display the progress percentage when performing
flash erase/read/write operations.
2018-12-21 01:28:17 -08:00
Rey Tucker
9e9d9126a7 host: bladerf2: formatting fix on prev commit
committed and pushed before running clang-format, oops
2018-12-21 01:28:17 -08:00
Rey Tucker
aefd8d3d3c host: bladerf2: move FPGA-tuning bug check ahead of env check
Permit overriding the fallback to host-based tuning by setting
the env variable.
2018-12-21 01:28:17 -08:00
Rey Tucker
74e3049306 hdl: update CHANGELOG 2018-12-21 01:28:17 -08:00
Rey Tucker
2227d110ab Bump FPGA to v0.10.2 fpga_v0.10.2
host: bladerf2: Disable FPGA tuning mode if using pre-v0.10.2
FPGA.
2018-12-17 20:36:16 -05:00
Rey Tucker
1f692be845 hdl: nios: add -DNUAND_MODIFICATIONS
bladeRF_nios needs NUAND_MODIFICATIONS to pick up local mods in
libad936x header files.
2018-12-17 20:28:07 -05:00
Rey Tucker
ddb0998a18 hdl: nios: adi: add -fshort-enums when building libad936x
libad936x needs -fshort-enums as well, so that structs line up
properly.

I believe this is mostly cosmetic in practice, as libad936x
manages its own memory, but it does cause some distress when
debugging.
2018-12-17 20:28:07 -05:00
Rey Tucker
1e45367785 thirdparty: adi: define ALTERA_PLATFORM for headless platform
libad936x needs ALTERA_PLATFORM because, apparently, memcpy
doesn't work properly on the Nios. This resulted in TX sample
rates being half of the expected value.
2018-12-17 20:28:07 -05:00
Rey Tucker
8fa6c84856 fpga_common: ad936x.h: sync with adi's structs 2018-12-17 20:28:07 -05:00
Rey Tucker
ac9b49226b hdl: nios/devices_rfic: fix TX gain ctrl, handle init fails better
fix validity bitmask for gain setting

 - This caused attempts to get/set TX gain to fail

improve init failure detection

 - Also check pdata for a null value, as this is a canary for a
   mismatch in struct alignments between libad936x and bladeRF_nios.

 - On failure, de-init and free and such.
2018-12-17 20:28:07 -05:00
Rey Tucker
9e5915993b hdl: ip/adi/no_OS: fix patch ordering
This was fixed for the Host CMakeFiles.txt, but did not get fixed
on the Nios side of things.

Fixes:

	-- libad936x: Applying patch: 0001-0bba46e-nuand-modifications.patch
	-- libad936x: Applying patch: 0006-0bba46e-compilefix.patch
	CMake Error at CMakeLists.txt:192 (message):
	  Failed to apply 0006-0bba46e-compilefix.patch: error: patch failed:
	  ad9361.c:40

	  error: ad9361.c: patch does not apply

	-- Configuring incomplete, errors occurred!
2018-12-12 18:44:51 -05:00
Rey Tucker
cea114f5bc host: bladerf2/rfic_fpga: fix windows build errors
_rfic_fpga_get_status_wqlen:
	C4267: 'return': conversion from 'size_t' to 'int'

_rfic_fpga_spinwait:
	C2065: 'useconds_t': undeclared identifier
	C2120: 'void' illegal with all types

_rfic_fpga_set_gain:
	C4244: conversion from 'float' to 'int'
2018-12-12 18:44:51 -05:00
Brian Glod
7e6e3bd69f hdl/build_bladerf.sh: Fix SignalTap variable name
Fix erroneous variable name pointing to the SignalTap file to be used
when creating a Quartus project.
2018-12-12 16:56:04 -05:00
Rey Tucker
ac7a017bd9 host: bladerf2: undo double-MUTEX workaround on bladerf_*_rfic_*_fir
After the RFIC control split, we now directly call the rfic
functions to get/set filters when changing the sample rate.
So, we can go back to MUTEXing the API functions.

This undos the changes in 9e8bd237bc

host: bladerf2: remove unneeded pre-declarations
2018-12-12 16:42:52 -05:00
Rey Tucker
ecc9acba8d host: bladerf2: clean up bladerf2_set_tuning_mode
log message levels are now more chill

generally restructure for some efficiency
2018-12-12 16:42:52 -05:00
Rey Tucker
7dab6748b8 host: bladerf2: add get_init_state controller fn 2018-12-12 16:42:52 -05:00
Rey Tucker
663b74420c host: nios_access: don't globally suppress TIMEOUT on response
In most cases, BLADERF_ERR_TIMEOUT should be reported to the user.
So, for the NIOS_PKT_16x64_TARGET_RFIC target, nios_access_quiet
can be used to suppress all the log_errors.
2018-12-12 16:42:52 -05:00
Rey Tucker
9665189852 host: libbladeRF_test/quick_retune: add ctrl-C handler; modernize
aborting without calling bladerf_close() causes some confusion
with FPGA-based RFIC control.  this likely needs dealt with at
the protocol level, but in the meantime, we can ensure that
bladerf_close() happens and everything spins down by trapping
ctrl-C.

also shift to using BLADERF_CHANNEL_TX(0) instead of
BLADERF_MODULE_TX, BLADERF_TX_X1 for sync_config, and
other minor tweaks
2018-12-12 16:42:52 -05:00
Rey Tucker
9a9eb9f56f host: bladerf2: reset RFIC on close after doing retunes
For expedience, quick retunes directly control the RFIC via SPI.
This works fine as it is, but it puts the RFIC into an unexpected
state, and a reset is needed.

This commit fully de-initializes the RFIC during bladerf_close, if
a bladerf_get_quick_tune is performed sometime during the session.
2018-12-12 16:42:52 -05:00
Rey Tucker
a0c98b4268 host: bladerf2: add FPGA RFIC control
Moves much of the low-level control etc into rfic_{fpga,host}.c

Implements the necessary plumbing to make FPGA RFIC control work,
while still supporting host-based RFIC control.

host: bladerf2: verify that FPGA supports RFIC control before using it

FPGA-based RFIC control is rather memory-heavy, so omitting it
from builds is possible, but the usual capabilities mechanism
won't detect this.

This will throw a couple annoying errors from nios_16x64_read
when checked, but they are ignorable.

host: bladerf2: split bladerf2_get_quick_tune into host/fpga control

also:
common.h: remove vestigial comments

host: bladerf2: support standby state for FPGA RFIC mode

this lets us ensure the RFIC is in a known state when we
call bladerf_close()

host: bladerf2: move rfic_fpga init stuff to FPGA
2018-12-12 16:42:52 -05:00
Rey Tucker
7722e152e0 host: libbladeRF/backend: implement RFIC control messaging 2018-12-12 16:42:52 -05:00
Rey Tucker
9588498576 host: libbladeRF: fpga 0.10.1 support 2018-12-12 16:42:52 -05:00
Rey Tucker
47ca015fd2 host: libbladeRF/board.h: redefine BLADERF_CAP_FPGA_TUNING
BLADERF_CAP_FPGA_TUNING was previously defined to be the same as
BLADERF_CAP_SCHEDULED_RETUNE, but these features are distinct on
the bladeRF 2.
2018-12-12 16:42:52 -05:00
Rey Tucker
7d58cdfada host: common: conversions: add tuningmode2str conversion 2018-12-12 16:42:52 -05:00
Rey Tucker
54fefeb7ac fpga_common: defines and enums for FPGA RFIC control 2018-12-12 16:42:52 -05:00
Rey Tucker
f6aae6cbc7 host: libbladeRF: fix missing include in sync.h 2018-12-12 16:42:52 -05:00
Rey Tucker
bc8eaedf5f hdl: nios/devices_rfic: fix init logic, refactor, cleanup
Ensure that going into standby mode with an uninitialized state.phy
does something graceful.

Perform validity checks before dispatching a command, instead of relying
on each function to do it.

Use uint32_t for data parameters to functions, where possible, as
uint64_t is overkill for most situations.

Refactor RFIC reset into _reset_rfic

Also clean up some code, consistency, add comments, etc.
2018-12-12 16:28:23 -05:00
Rey Tucker
3cdf9419ca hdl: nios/devices_rfic: fix gainmode setting
Somehow, bladerf2_rfic_init_params.gc_rx1_mode is being set to 0,
causing BLADERF_GAIN_DEFAULT to default to MGC.

This also reduces image size by removing dependency on a couple
functions, and pruning gainmode down to uint8_t.
2018-12-12 14:22:07 -05:00
Brian Glod
b2f3072060 host/windows/build: Add '--recursive' to git clone
The --recursive option also fetches all submodules.
2018-12-11 17:24:24 -05:00
Brian Glod
efe4a32707 host/arch/PKGBUILD: Add '--recursive' to git clone
The --recursive option also fetches all submodules.
2018-12-11 17:23:59 -05:00
Brian Glod
a1b0b7e55b README.md: Add '--recursive' to git clone
The --recursive option also fetches all submodules.
2018-12-11 17:19:24 -05:00
Rey Tucker
a7b6888747 host: bladeRF1.h: update docs to reflect deprecation 2018-12-11 13:07:49 -05:00
Rey Tucker
f2c24d2872 fpga_common: assign user-defined space in bladerf_rfic_command 2018-12-11 12:17:55 -05:00
Rey Tucker
d1fd240b2f host: libbladeRF-test/repeated_stream: fix impossible uninit var
I believe this particular situation is impossible in actual
practice (it would require params.rx being false initially but
set to true by the TX thread very quickly, or vice versa), but
it's easy enough to clean up.

Bug reported by the clang static analyzer.

Description: 1st function call argument is an uninitialized value
File: /root/bladeRF/host/libraries/libbladeRF_test/test_repeated_stream/src/main.c
Line: 283
2018-12-07 19:30:07 -05:00
Rey Tucker
b499814341 host: bladeRF-cli: fix incorrect null check in cmd_help
Bug reported by the clang static analyzer.

Description: Access to field 'help' results in a dereference of a null pointer (loaded from variable 'cmd')
File: /root/bladeRF/host/utilities/bladeRF-cli/src/cmd/cmd.c
Line: 404
2018-12-07 19:14:19 -05:00
Rey Tucker
5077b6d0c5 host: udev: split up rules files by hardware platform
The underlying driver for this: Debian/Ubuntu's libbladerf1
package installs the udev rules itself, instead of having a
separate libbladerf-udev package like our PPA does. So,
having libbladerf1 installed creates a conflict with installing
libbladerf2, which is not good.

End result is that we either need to conflict libbladerf1, or
put the udev rules from libbladerf-udev somewhere else, and
there are fewer side effects with the latter option.
2018-12-07 17:43:20 -05:00
Rey Tucker
926757936a host: bladeRF-cli: cmd.c: refactor, code formatting/cleanup
refactor/simplify command declaration

clean up code
2018-12-06 22:08:07 -05:00
Rey Tucker
3d5d28e4db host: bladeRF-cli: cmd.c: sort the commands
These got a little untidy...
2018-12-06 22:08:07 -05:00
Rey Tucker
bfe1b7ca86 host: bladeRF-cli: ADDING_COMMANDS: convert to markdown, freshen
clean up formatting

fix typos

expand discussion of generate.bash
2018-12-06 22:07:26 -05:00
Rey Tucker
18e79836bd hdl: nios: devices_rfic: implement missing frequency reset in standby
oops
2018-12-06 14:45:24 -05:00
Rey Tucker
b8d8667722 hdl: nios: devices_rfic: add standby state, refactor initialization
hdl: nios: devices_rfic: add a standby initialization state

this will be used to indicate that the board is not actively
being driven, but is still initialized and ready to go

improve debugging output

enforce a hard reset at the start of initialization

hdl: nios: devices_rfic: perform init/tuneup on FPGA

Move some of the initialization tasks, previously done on the host and
forwarded up, to the Nios.

Also wee bit of refactoring/cleanup.
2018-12-06 14:45:24 -05:00
Rey Tucker
4e96014457 fpga_common: define bladerf_rfic_init_state enum 2018-12-06 14:45:24 -05:00
Rey Tucker
d3aaf3730a hdl: nios: retune2: invalidate RFIC ctrl freq when fastlocking
hdl: nios: devices_rfic: implement frequency invalidation

when doing a retune via direct SPI writes, libad936x's idea of state is
totally destroyed until the next time a "normal" retune is performed.

hdl: nios: pkt_retune2: inval freq on profile_activate

After doing direct SPI fastlock activities, _rfic_cmd_rd_freq can no
longer provide a valid answer until the next _rfic_cmd_wr_freq. Signal
to the RFIC driver that this has happened, so it can govern itself
accordingly.
2018-12-06 14:45:24 -05:00
Rey Tucker
fbfc4f6373 hdl: nios: devices_rfic: implement BLADERF_RFIC_COMMAND_FASTLOCK 2018-12-06 14:45:24 -05:00
Rey Tucker
8a590e8e0b fpga_common: add BLADERF_RFIC_COMMAND_FASTLOCK 2018-12-06 14:45:24 -05:00
Rey Tucker
dc8440c44b hdl: nios: devices: fix shift in adi_rfspdt_select
p->spdt was not being shifted into the right place, so the SPDTs
were not being properly set on a retune

also reference the magic numbers back to bladerf2_common.h
2018-12-06 14:45:24 -05:00
Rey Tucker
38ab5a0cfb hdl: nios: clean up Makefile indentation
Apparently indentation must consist of a single tab character,
and GNU make is serious about that.

However, elsewhere, use spaces.
2018-12-06 14:45:24 -05:00
Rey Tucker
0e58bbc796 hdl: FPGA version -> v0.10.1 fpga_v0.10.1 2018-12-06 14:45:24 -05:00
Rey Tucker
a964f22786 hdl: nios: implement Nios-based RFIC control
hdl: nios: implement a queuing strategy for RFIC commands

hdl: devices_rfic: all writes now go to queue

hdl: devices_rfic: move queue stuff into its own file

hdl: devices_rfic: cleanup includes, etc

hdl: devices_rfic: debugging improvements...

hdl: devices_rfic: code cleanup/formatting/streamlining

hdl: devices_rfic: track return value of queued jobs

stores a .rv member in the queue entry struct, then copies that to the
queue's .last_rv member at job completion.

standardizes _rfic_command_write_init args for future
function-pointerization.

hdl: devices_rfic: use function pointers

hdl: devices_rfic: remove inline hint, log_error->DBG

hdl: devices_rfic: swap read/write in rfic_command_fns for consistency

hdl: nios/devices_rfic: move stuff into a state struct

hdl: nios/Makefiles: dont build devices_rfic* on bladerf1

devices_rfic.c: remove stubs

devices_rfic.c: formatting

devices_rfic.h: only include if required

pkt_16x64: guard around bladerf2

pkt_16x64: more guards

pkt_16x64 brf2 guard tweak

pkt_16x64.h: guard the PKT_16x64 define

hdl: nios: devices_rfic: implement INIT command

hdl: devices_rfic: de-assert txnrx/enable

hdl: devices_rfic: move init read to its own fn

hdl: nios: devices_rfic: implement FREQUENCY command

hdl: nios: use shortened _rffe_*_enabled fn names

hdl: nios: devices_rfic: implement STATUS command

hdl: devices_rfic: implement RFIC status register

hdl: nios: implement _rfic_command_read_status

hdl: nios: devices_rfic: implement SAMPLERATE command

hdl: nios: devices_rfic: implement BANDWIDTH command

hdl: nios: devices_rfic: implement GAINMODE command

hdl: nios: devices_rfic: implement GAIN command

hdl: nios: devices_rfic: implement ENABLE command

hdl: nios: devices_rfic: implement RSSI command

hdl: nios: devices_rfic: use new common #defines

hdl: nios: devices_rfic: implement FILTER command

hdl: nios: devices_rfic: implement TXMUTE command
2018-12-06 14:45:24 -05:00