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.
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.
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.
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!
_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'
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
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.
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
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.
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
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.
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.
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
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
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.
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.
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.
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
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