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.
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!
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.
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
- Add tutorial for command-line GDB debugging for those who want to avoid eclipse.
- Add debugging tips (increasing timeouts, disabling compiler optimization)
Try to load bladeRF2 fast lock profiles into the RFFE as the scheduled
retune requests are enqueued. This has the potential to speed up retune
times because the profile will be ready before the request goes 'live'.
The '-fshort-enums' optimization will tell GCC to pack enums into the
smallest data type it can instead of defaulting to 32 bits. This means
most enums will be packed into 8-bit data types, saving some
memory. On newer processors, 8-bit data access can be slower than
32-bit or 64-bit accesses, but that should not be a problem on something
like the Nios.
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
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.
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.
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.
Add a weak pull-up on fx3_uart_rxd
This is a bus used for both FPGA-to-FX3 UART data and FX3-to-Flash
SPI data, and without something driving it, it tends to float around
0.55 volts (which is very much a low/asserted signal for the UART).
When the FX3 SPI interface has the bus, it puts the FPGA into reset
via fx3_ctl(7), and fx3_uart_rxd goes high-Z accordingly.
I suspect what we're running into is a race condition between the FX3
reconfiguring the pin to UART mode and bringing the FPGA out of reset,
and the FPGA shifting from high-Z to high/idle, given:
- All of the "junk bytes" seen so far have been all ones followed by
all zeroes, e.g. 0xF0, 0xFC, etc
- Being low for 5 clocks and then going high is indistinguishable from
a start bit followed by 0xF0 followed by a stop bit.
Thus, by maintaining a constant weak pull-up on this bus, we can
ensure it's a logic high when idle.
There are possible side effects when the bus is in its SPI MOSI role,
but I believe they are minor. The FX3 is not expecting a pull-up/down
on this signal, and this is a critical pin for flash access. But,
C5's R_pu is 25 kohms, which means sinking 1.4 mA to pull it low, and
the FX3's absolute maximum output current is 20 mA, so I think we are
good here.
The 16 LSBs of the flag word are overwritten by the GPIF state machine. The
other half is under control by the fifo_writer. Care should be taken when
appropriating new bits.
Bit 1 now encodes no "underrun", and bit 0 continues to encode "underrun."