Commit graph

642 commits

Author SHA1 Message Date
Rey Tucker
9f235ddbe3 hdl: nios: devices_rfic: remove unnecessary shift
The need of this shift was an artifact of a previous bug, since
fixed.
2018-12-21 15:10:43 -05:00
Rey Tucker
1e06cfe0b3 hdl: nios: libbladeRF_nios_compat: avoid redef of PRIx64 macros 2018-12-21 15:07:46 -05:00
Rey Tucker
74e3049306 hdl: update CHANGELOG 2018-12-21 01:28:17 -08:00
Rey Tucker
2227d110ab Bump FPGA to 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
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
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
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
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
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
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 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
Rey Tucker
9c4a2cb091 hdl: build libad936x for bladerf-micro platform
hdl: bladeRF_nios: add missing PRI*64 defines

hdl: nios: add typedef for stubbing out pthread types

hdl: nios: fixup makefile stuff

hdl: nios: include host/common resources

hdl: nios: build system adjustments

hardware-specific includes

hdl: nios: fix typo in bladerf-micro

hdl: nios: clean up include dirs

hdl: nios: conditional define for BLADERF_NIOS_LIBAD936X
2018-12-06 14:45:24 -05:00
Rey Tucker
608bf0b673 hdl: nios: split up build files by platform 2018-12-06 14:45:24 -05:00
Rey Tucker
863b2a75b8 hdl: add build ancillaries for libad936x on nios
hdl: build libad936x for bladerf-micro platform

hdl: nios: initial build skeleton

hdl: nios: make ad936x config.h platform-specific

hdl: nios: libad936x: allow build-time logging configuration

hdl: adi: cmakelists: reduce overly-restrictive version req

hdl: nios: libad936x: build with new ad936x_params.c

hdl: nios/adi: add ARRAY_SIZE to stub host_config.h
2018-12-06 14:45:24 -05:00
Rey Tucker
e3fdf7d7bb hdl: nios: clean up devices.c, wrap fns in platform ifdefs 2018-12-06 14:45:24 -05:00
Rey Tucker
22760ca6b2 hdl: nios: rename ad9361_* accessors
libad936x has its own ad9361_* functions, so rename our local ones
to adi_*
2018-12-06 14:45:24 -05:00
Rey Tucker
3cb4671148 hdl: nios: platform-specific guards for pkt_*.c
significantly reduces memory consumption on smaller FPGAs
2018-12-06 14:45:24 -05:00
Rey Tucker
f5de4e2303 hdl: bladerf-micro: nios: gratuitous screen placebo
ensure there is some console output every second or so, to
keep me from doubting my sanity
2018-12-06 14:45:24 -05:00
Rey Tucker
b9e50e68ca hdl: nios: fixup DBG printf formats
alt_printf will only do %x. not %02x, not %d, just %x and %s and %c.

hdl: nios: pkt_legacy: stub out DBG to reduce screen clutter
2018-12-06 14:45:24 -05:00
Rey Tucker
c0c3a6b6e9 hdl: nios: remove duplicate #includes 2018-12-06 14:45:24 -05:00
Brian Glod
3db286e3ec
nios: update README.md for GDB debugging
Edited for typos and clarity.
2018-12-04 17:55:12 -05:00
Brian Glod
5ff598a1b1
nios: update README.md for GDB debugging
- Add tutorial for command-line GDB debugging for those who want to avoid eclipse.
- Add debugging tips (increasing timeouts, disabling compiler optimization)
2018-12-03 17:08:51 -05:00
Rey Tucker
fd77d9f4a9 hdl: build: parameterize nios2 RAM size by platform/size
On xA4/xA9, we can have a larger memory footprint, and we need
it for libad936x, which is a hefty boi
2018-11-26 16:16:10 -05:00
Brian Glod
e9347af38d nios: preload bladeRF2 fast lock profiles
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'.
2018-11-26 16:03:46 -05:00
Brian Glod
20a61ce17c nios: GCC option: treat warnings as errors
Add -Werror option to GCC to treat warnings as errors when compiling the
Nios code.
2018-11-26 16:03:46 -05:00
Brian Glod
b2149ebbb5 nios: GCC option: enable short-enums
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.
2018-11-26 16:03:46 -05:00
Brian Glod
b80960643a hdl: nios: bump FPGA version to v0.10.0
Version increase primarily reflects the new quick tune feature for
bladeRF2 devices.
2018-11-26 16:03:46 -05:00
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
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
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
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 2018-10-26 16:38:41 -04:00
Rey Tucker
cb5dd4e954 hdl: bladerf-micro: weak pull-up on fx3_uart_rxd (#679)
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.
2018-10-26 16:02:01 -04:00
Rey Tucker
9640eec3b9 hdl: bladerf-micro: add false path for pwr_status 2018-10-24 14:07:49 -04:00
Brian Glod
2ffc216499
hdl: nios: README.md
Clarify import "Existing projects into Workspace"
2018-10-24 13:58:52 -04:00
Robert Ghilduta
803768cd48 hdl: enable miniexp routing to fifo_writer 2018-10-20 20:56:41 -04:00
Robert Ghilduta
54baeb15e8 hdl: add new miniexp flags to fifo_write
fifo_writer encodes when miniexp1 and miniexp2 IO pins are asserted.
2018-10-20 20:56:41 -04:00
Robert Ghilduta
22bc0486e5 hdl: clean up metatdata flags field in GPIF
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."
2018-10-20 20:56:41 -04:00