Compare commits

..

142 commits

Author SHA1 Message Date
Robert Ghilduta
fcf9423325 Bump pillow 2025-10-06 16:06:05 -07:00
Robert Ghilduta
712d49e28f libbladeRF: add RX reordering and prime worker before RX enable
- Add RX buffer sequence tracking with reorder queue to deliver in-order buffers
  despite out-of-order USB completions. Pause submissions when the reorder
  queue holds data to avoid overwriting, and reset tracking on stream start.
- Introduce sync_prime_stream() to start the sync worker and wait until it is
  running. This is used to avoid start-up gaps.
- Call sync_prime_stream() on RX enable paths for bladerf1/bladerf2 boards
  before backend enable, reducing early stream discontinuities (e.g., with
  RX_MUX_32BIT_COUNTER).
- This does not at affect TX code paths.

This improves RX robustness and eliminates potential early out-of-order batches
on some platforms under high sample rates and low compute throughput.
2025-09-28 20:28:22 -07:00
Ryan Thompson
7d7d87f686 libbladeRF: improve RFIC BIST loopback error message
Change from log_debug to log_error and provide clearer message when
RFIC BIST loopback is attempted in FPGA tuning mode. The new message
explicitly states the requirement (HOST mode) and current state (FPGA
mode), making it actionable for users.
2025-07-16 17:52:11 -05:00
Ryan Thompson
2935ce5251 test: added oversample test channel select and disabled channel check
If we see over 40% of the samples at zero, it's likely that a channel
is disabled. Reverting 55b5a0d07c will
get this test to fail.
2025-07-07 12:45:18 -05:00
Ryan Thompson
55b5a0d07c libbladeRF: fix OC register from 0x54 to 0xD4 enabling both RX1 and RX2
This occurs because the OC register (0x003) was set to 0x54, which only
enables RX1 in oversample mode. Now both channels are enabled by default
and appropriately gated at the top level adc_assignment_proc
in hosted.vhd.
2025-07-03 21:38:50 -05:00
Ben Morse
3d647f3db9 host: improve txrx_hwloop test
- fix bug where test would erroneously pass due to negative value
- add gain, better threshold control, png output
- requirements.txt now supports Ubuntu 20.04 and newer
2025-07-03 01:29:26 -07:00
ifrasch17
fa2f917179 bladeRF-fsk: bump version to add configurable sample rate, better test_suite 2025-07-01 17:48:53 -06:00
Ben Morse
7706720f99 docker: fix rocky-9 Docker build 2025-07-01 13:22:22 -07:00
Ben Morse
4494aa41ab host: test_regression can build every bitfile 2025-06-13 15:39:22 -07:00
Ben Morse
a81b7ce4c5 hdl: fix foxhunt build error 2025-06-13 15:39:22 -07:00
Ben Morse
e55e12b889 docker: fix all docker images
- delete many dockers, the rest are fully functioning
- build.bash returns with correct exit code
- base moves to alpine
- add rocky in place of centos
- some platforms require a cmake compile to get modern cmake
- add i686 build to existing i386
2025-06-13 15:39:13 -07:00
Ben Morse
ddc83606ff host: fix test_txrx_hwloop
- fix duty cycle error for subsequent iterations in the test
2025-06-13 15:39:07 -07:00
Ryan Thompson
b2f9503fce bladeRF-power: build: look for brew installed ncurses 2025-06-13 15:39:06 -07:00
Ben Morse
86c5063425 host: Fixes for Windows
- Changes around getopt/getopt_long
- CLOCK_MONOTONIC fix
- link fix
2025-06-13 15:39:00 -07:00
Ben Morse
a93191ae39 bladeRF-fsk: bump
- fix compiler error
- update windows threading
2025-06-13 15:38:48 -07:00
Robert Ghilduta
09efbb40b8 hdl: build_bladerf.sh fixups
Add H optarg, and ensure submodules are initialized prior to synthesis
2025-06-08 12:19:04 -07:00
Robert Ghilduta
35ec3c657f hdl: update libad936x build order 2025-06-07 22:08:15 -07:00
Ben Morse
6d61b4f86f bladeRF-fsk: add cmake flag to build FSK project 2025-06-07 22:04:26 -07:00
Ben Morse
918535854c bladeRF-fsk: host: various errors and compiler warning fixes on multiple platforms 2025-06-07 21:58:57 -07:00
Ryan Thompson
d65b160cd9 hdl: parallel build terminates and cleans up if exit or failure occures 2025-05-20 01:49:34 -07:00
Ryan Thompson
5be9df53a8 test: add libbladeRF oversample test 2025-05-20 01:47:40 -07:00
Ryan Thompson
8f490c0a67 libbladeRF: fix max sample throughput warning for oversample feature 2025-05-20 01:47:21 -07:00
Robert Ghilduta
d77b35c7c5 bladeRF-fsk: unitialized value fixup 2025-05-20 01:43:35 -07:00
Robert Ghilduta
2c12352457 docker: add Ubuntu distributions, update debian distro packages 2025-05-20 01:43:22 -07:00
Robert Ghilduta
761f39e1d7 docker: update from yum to DNF 2025-05-20 00:47:40 -07:00
Robert Ghilduta
8f99003e36 libbladeRF_test: update dependency 2025-05-20 00:32:33 -07:00
Robert Ghilduta
6185546fa9 debian: update control
Add support for libedit and curl
2025-05-20 00:30:22 -07:00
Robert Ghilduta
611e9cbfb3 debian: update RBFs and FX3 images 2025-05-20 00:19:40 -07:00
Robert Ghilduta
85d8d4b22b hdl: add AD9361 and bladeRF 2.0 micro support headers to include path 2025-05-19 23:59:16 -07:00
Robert Ghilduta
cd29f93a58 libladeRF: LTO fix
Fixes libbladeRF LTO compilation error
cmake -DCMAKE_C_FLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing" -DCMAKE_BUILD_TYPE=Release ..
2025-05-19 23:58:10 -07:00
Ryan Thompson
8931d475f3 host: add ifdef for array size macro 2025-05-19 23:57:50 -07:00
Ryan Thompson
a59d95fc80 host: fsk submodule init on make 2025-05-19 23:57:43 -07:00
Robert Ghilduta
bbdfbe1760 fsk: bump submodule to include build library fix 2025-05-14 01:22:16 -07:00
Robert Ghilduta
545f73c5f1 fx3_firmware: include major update in CHANGELOG 2025-05-13 04:37:12 -07:00
Robert Ghilduta
09c8208778 libbladeRF: bump version to 2.6.0
v2.6.0 (2025-05-06)
--------------------------------

This version of libbladeRF is intended for use with:

  FX3 Firmware v2.6.0
  FPGA         v0.16.0

New Features:
 * Added SC16_Q11 packed sample format support, improving sample efficiency
 * Increased FX3 GPIF buffer sizes, significantly boosting USB throughput (~356MB/s)
 * Implemented dynamic Nios base address assignment based on RAM size
 * Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
 * Enabled elf-gdb and gdb-server support for improved FPGA debugging capability
 * Added git revision information to FPGA build outputs
 * bladeRF 2.0: Added support for gain calibration loading, enabling, and management
 * bladeRF 2.0: Introduced bladeRF-power CLI tool for managing gain calibration
 * bladeRF 2.0: Added bladerf_get_gain_target function for gain management
 * bladeRF 2.0: Added bladerf_format_to_string API call
 * bladeRF 2.0: Added bladerf_image_print_metadata API to display image metadata
 * bladeRF 2.0: Improved compatibility checking between FPGA and FX3 firmware GPIF buffers

Improvements:
 * libbladeRF now compiles and runs under MinGW and MSVC on Windows platforms
 * Replaced libpthreadswin32 dependency with native libbladeRF threading macros
 * Improved error handling and reporting for out-of-range frequency and sample rate settings
 * Added detailed logging for USB transfer and Nios access timeouts
 * Updated Doxygen to v1.9.8, adding support for light/dark modes and modernized configuration
 * Improved GPIF buffer alignment handling for larger FX3 buffer sizes
 * Added CMake find_package() support for easier integration into external projects
 * Streamlined internal error checking macros, simplifying codebase
 * Enhanced sync_rx_meta example with additional argument parsing and MIMO support
 * Improved FPGA simulations for bladeRF 1.0 and bladeRF 2.0 micro

Bug Fixes:
 * Fixed delayed sample and off-by-one timestamp issues on bladeRF 1.0
 * Corrected TX meta sample gap issue when timestamp set to META_NOW
 * Resolved corrupted UART buffer in command_uart component
 * Fixed TX deadlock scenarios by refactoring RX/TX DMA prioritization
 * Addressed SC16_Q11 packed RX discontinuity issue on overflow condition
 * Fixed false timing paths and resolved multiple timing violations
 * Fixed calibration load check in bladerf_get_gain_calibration
 * Corrected RX meta packet timestamp and flags assignment
 * Fixed sync TX initialization bug

Miscellaneous:
 * Updated API documentation to reflect larger GPIF buffer sizes
 * Improved FX3 SDK setup instructions in README
 * Minor typo and documentation corrections throughout the codebase
2025-05-11 04:22:46 -07:00
Robert Ghilduta
902fc43305 firmware: bump version to 2.6.0
v2.6.0 (2025-05-06)
--------------------------------
 * Fixed missing break in BLADE_USB_CMD_QUERY_FPGA_SOURCE command handling
 * Improved FX3 SDK setup instructions in README
2025-05-11 04:21:32 -07:00
Robert Ghilduta
f746c5bd13 fpga: bump version to 0.16.0
--------------------------------
v0.16.0 (2025-05-06)
--------------------------------

This version brings significant FPGA improvements including sc16q11 packed mode
support and optimized USB throughput, along with important bug fixes for bladeRF
1.0 and 2.0 micro devices.

 Features:
 * hdl: Added sc16q11 packed mode for improved sample efficiency
 * hdl: Increased FX3 GPIF buffer sizes, boosting USB throughput (~356MB/s)
 * hdl: Implemented dynamic Nios base address assignment based on RAM size
 * hdl: Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
 * nios: Enabled elf-gdb and gdb-server support for improved debugging capability
 * hdl: Added git revision information to FPGA build outputs

 Fixes:
 * hdl: Fixed delayed sample and off-by-one timestamp bugs on bladeRF 1.0
 * hdl: Corrected TX meta sample gap issue when timestamp set to META NOW
 * hdl: Fixed corrupted UART buffer in command_uart component
 * hdl: Resolved TX deadlock scenarios by refactoring RX/TX DMA prioritization
 * hdl: Improved FPGA simulation accuracy for bladeRF 1 and 2 micro models
 * hdl: Fixed false timing paths and resolved multiple timing violations
2025-05-11 04:21:30 -07:00
Robert Ghilduta
e1325c0103 bladeRF-cli: bump version to 1.10.0
v1.10.0 (2025-05-06)
--------------------------------
 * Added sc16q11 packed format support
 * Improved sample format tracking and replaced legacy bit_mode handling
 * Migrated threading to unified libbladeRF thread macros
 * Updated CMake minimum requirement to modernized syntax
 * Fixed RX sample count overflow (issue #941)
 * Return error code when no available devices detected (issue #844)
 * Clarified K/M/G prefixes as powers of 1024 in documentation (issue #840)
 * Updated documentation to reflect sample limit changes
2025-05-11 04:17:01 -07:00
Robert Ghilduta
2003fd968f python: bump version to 1.4.0
v1.4.0 (2025-05-06)
--------------------------------
 * add support for SC16_Q11_META format
 * update Python binding definitions
2025-05-11 04:17:01 -07:00
Robert Ghilduta
5627503b27 matlab: bump version to 1.1.0
v1.1.0 (2025-05-06)
--------------------------------
 * Add bladerf_image_type_to_string API binding
 * Add missing RFIC_BIST loopback type
 * Improve enum string handling and conversion functions
 * Fix module default value handling in calibrate method
 * Standardize version information handling
2025-05-11 04:17:01 -07:00
Robert Ghilduta
20b9810eb0 misc: add missing CHANGELOGs
All CHANGELOGs should be up to date now.
2025-05-11 04:17:01 -07:00
Robert Ghilduta
bcf1f4b888 hdl: build A5s as part of build all hosteds 2025-05-11 04:17:01 -07:00
Robert Ghilduta
5e4da73c1c bladeRF-fsk: add git submodule for bladeRF-fsk repo 2025-05-11 04:17:01 -07:00
Robert Ghilduta
ff812e5305 bladeRF-fsk: move into its own repo 2025-04-24 04:36:36 -07:00
Robert Ghilduta
619e058115 matlab: add missing bladerf_image_type_to_string
Add missing bladerf_image_type_to_string API_EXPORT declaration and also
add it to matlab
2025-04-24 04:36:36 -07:00
Robert Ghilduta
6905c37642 host: finish off cross-platform support for Windows
libbladeRF now compiles under MinGW as well as MSVC under Windows
2025-04-24 04:36:36 -07:00
Robert Ghilduta
352b206044 WIP: momentarily disable bladeRF-fsk on Windows 2025-04-24 04:36:36 -07:00
Robert Ghilduta
d673366f4c host: final pthread migration to make linux compile 2025-04-24 04:36:36 -07:00
Robert Ghilduta
a83f21d525 host: clean up windows build script, remove pthreads 2025-04-24 04:36:36 -07:00
Robert Ghilduta
401d7df2c0 host: clean up README, and misc files to indicate remove libpthreadswin32 2025-04-24 04:36:36 -07:00
Robert Ghilduta
11506a4762 host: fixup windows related files 2025-04-24 04:36:36 -07:00
Robert Ghilduta
34fce67f4f host: remove pthreadswin32 cmake 2025-04-24 04:36:36 -07:00
Robert Ghilduta
7985676d0d host: switch over from using pthread.h to libbladeRF's thread.h 2025-04-24 04:36:36 -07:00
Robert Ghilduta
5863f983a2 host: remove remaining libpthreadswin32 and add fixups to cmake 2025-04-24 04:36:36 -07:00
Robert Ghilduta
1062b40d46 host: begin removing libpthreadswin32 from cmakes 2025-04-24 04:36:36 -07:00
Robert Ghilduta
bb93c07af8 host: libbladeRF's thread.h now compiles and runs.
Lowest level functions should now work. Async/sync functions probably still do
not work.
2025-04-24 04:36:36 -07:00
Robert Ghilduta
ee0e0040b6 libbladeRF_test: change over to libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
03b2481db9 bladeRF-cli: move to libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
5cdcd28e16 host: convert async/sync to libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
1e498900e8 libbladeRF: use libbladeRF thread macros 2025-04-24 04:36:36 -07:00
Robert Ghilduta
dc7accaa38 bladeRF-fsk: add additional gain controls 2025-04-24 04:36:36 -07:00
Ryan Thompson
af0045347f host: update CMake minimum required version format
Update cmake_minimum_required calls to use the 'min...max' version range syntax
 to fix CMake deprecation warnings. Also modernized CMP0115 policy to use the
 NEW behavior instead of OLD.
2025-04-24 04:36:36 -07:00
Ryan Thompson
4fd2a40ae1 host: googletest and abseil version bump 2025-04-24 04:36:36 -07:00
ifrasch17
b137fbdf91 hdl: updated readme with latest information
-removed stale information
-current quartus version to use is 20.1.1
-updated to include info about bladeRF 2 micro in addition to bladeRF 1
2025-04-24 04:36:36 -07:00
ifrasch17
b0aa8dd99c libbladeRF: Update API documentation for new GPIF buffer sizes
-fixed the buffer sizes listed in the descriptions of the bladerf META formats
2025-04-24 04:36:36 -07:00
Ben Morse
7b6a08e943 fx3: more explicit instructions for fx3 SDK 2025-04-24 04:36:36 -07:00
Ryan Thompson
2afc653557 hdl: dynamically set Nios data and instruction base address by ram size 2025-04-24 04:36:36 -07:00
Ryan Thompson
309e5e0266 hdl: fixed corrupted uart buffer with two writes before a read
When in the WAIT_FOR_READ state, the first character in reg_request
continuously is overwritten.
2025-04-24 04:36:36 -07:00
ifrasch17
23de23e55f hdl: Added missing signals to bladeRF2 nios_system model 2025-04-24 04:36:35 -07:00
ifrasch17
4bad3ab2ef hdl: fix delayed samples bug in bladeRF1
-adjusted transition from META_DOWNCOUNT to META_LOAD in attempt to fix delayed
 samples bug in bladeRF1
-Sample FIFO was missing the last read of each block
-Saw that meta_current.meta_time.go needed to be held for 1 extra clock cycle
-adjusted things so the transition only happens when dma_downcount==2 AND
 fifo_read=1
2025-04-24 04:36:35 -07:00
ifrasch17
ea07dad7dc hdl: fix bladeRF1 simulation
added missing files to compile.do, and added missing ports to nios_system.vhd,
 so that compile.do would compile and run without errors
2025-04-24 04:36:35 -07:00
Ryan Thompson
92b14af787 nios: added elf-gdb and gdb-server to the make args wrapping nios cmds 2025-04-24 04:36:35 -07:00
Ryan Thompson
fc0be5f7fb nios: rm --go from nios elf load
--go does not let the Nios core continue as one would assume. Now a gdb
client can connect and continue without issues.
2025-04-24 04:36:35 -07:00
Robert Ghilduta
4ef9a72242 bladeRF-update: upgrade utility for firmware and FPGA updates
This commit introduces a new utility, bladeRF-update, which checks for and
optionally installs updates for the bladeRF firmware and FPGA images. The
utility provides functionality to download, verify, and update firmware and FPGA
files based on version information retrieved from the official Nuand server.
2025-04-24 04:36:35 -07:00
Ryan Thompson
ecbfb99b8a libbladeRF: log sample rate ranges on failed sample rate assignment 2025-04-09 23:17:40 -07:00
Ryan Thompson
50eaaa6e0c libbladeRF: added direction to transfer timeout errors 2025-04-09 23:17:40 -07:00
Ryan Thompson
bd5d06879b build_bladerf: added parallel build for hosted 40, 115, A4, A9 FPGAs
usage:
./build_bladerf.sh -H
2025-04-09 23:17:40 -07:00
Ryan Thompson
90bd8bb9cc doc: update sync config buffer size description 2025-04-09 23:17:40 -07:00
Ryan Thompson
234fcfeebf doc: added Doxygen support for light and dark modes 2025-04-09 23:17:40 -07:00
Ryan Thompson
0e2a978554 doc: Doxygen config update v1.8.8 > v1.9.8
└> doxygen -u Doxyfile.in
warning: Tag 'TCL_SUBST' at line 247 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 1059 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'HTML_TIMESTAMP' at line 1194 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'FORMULA_TRANSPARENT' at line 1475 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'LATEX_SOURCE_CODE' at line 1749 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOCBOOK_PROGRAMLISTING' at line 1911 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'PERL_PATH' at line 2090 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'CLASS_DIAGRAMS' at line 2103 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'MSCGEN_PATH' at line 2112 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTNAME' at line 2154 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_FONTSIZE' at line 2161 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Tag 'DOT_TRANSPARENT' at line 2372 of file 'Doxyfile.in' has become obsolete.
         This tag has been removed.
warning: Changing CLASS_GRAPH option to TEXT because obsolete option CLASS_DIAGRAM was found and set to NO.
2025-04-09 23:17:40 -07:00
Ryan Thompson
45e2d8f128 test: bump python requirements.txt versions 2025-04-09 23:17:40 -07:00
Ryan Thompson
79785afcf1 bladeRF-cli: added sc16q11 packed format support 2025-04-09 23:17:40 -07:00
Ryan Thompson
b774f45d38 bladeRF-cli: added sc16q11 packed format support 2025-04-09 23:17:40 -07:00
Ryan Thompson
72db17fa2c libbladeRF: fix packet format async stream to bytes
This fixes the sync interface packet format misalignment when sync
config assumes the sync config buffer is in bytes.
2025-04-09 23:17:40 -07:00
Ryan Thompson
2d2904e880 libbladeRF: added bladerf_format_to_string function 2025-04-09 23:17:40 -07:00
Ryan Thompson
0917d0780b libbladeRF: support for smaller GPIF buffer FPGA and FX3 versions 2025-04-09 23:17:40 -07:00
Ryan Thompson
0b00acac09 libbladeRF: error on GPIF buffer size mismatch between FX3 and HDL
While retaining the original non-fail condition for mismatches, we
throw an error for FPGA and FX3 images that have incompatible buffer
sizes. This prevents operational issues when mixing firmware versions
that support larger USB transfer buffers with FPGA versions that don't,
and vice versa.
2025-04-09 23:17:40 -07:00
Ryan Thompson
d586de33c1 libbladeRF: added legacy GPIF buffer size support for FW < v2.5.0 2025-04-09 23:17:40 -07:00
Ryan Thompson
cc6f329bb8 hdl: refactor RX/TX DMA request prioritization
* fixed TX deadlock when RX requests are not executed
* simplified RX and TX request prioritization
2025-04-09 23:17:40 -07:00
Ryan Thompson
f788085819 hdl: fixed tx sample fifo reset false path assigns for x40 & x115 builds 2025-04-09 23:17:40 -07:00
Ryan Thompson
730094891d hdl: fixed TX meta sample gap every gpif len when timestamp is META NOW 2025-04-09 23:17:40 -07:00
Ryan Thompson
3614c2ccc5 hdl: fixed late exit from TX meta down count state
The expected two cycle passing between meta write and idle states is
independent of the number of streams. Specifically addresses an
off-by-one timestamp error with the bladeRF 1.0.
2025-04-09 23:17:40 -07:00
Ryan Thompson
e8ec849ee7 nios: fix missing break for BLADE_USB_CMD_QUERY_FPGA_SOURCE 2025-04-09 23:17:40 -07:00
Ryan Thompson
3a11ac3b39 hdl: fix fifo reader meta_p_time conditional violation
The conditional that moves the meta state to META_DOWNCOUNT contains a
max value check using the `val+1=0` idiom. We can remove the carry
propagation delay by comparing against a max value constant
assigned (others => '1'). The fixes a setup time violation.
2025-04-09 23:17:40 -07:00
Ryan Thompson
9db41c9faf hdl: optimized sc16q11 packed cycle calculation
Alleviates timing violations from resources allocated by the calibration
signal IP.
2025-04-09 23:17:40 -07:00
Ryan Thompson
b086beee7e libbladeRF: added error print for set frequencies out of range 2025-04-09 23:17:40 -07:00
Ryan Thompson
bfadb91e06 libbladeRF: fixed rx meta packet timestamp and flags assignment 2025-04-09 23:17:40 -07:00
Ryan Thompson
899cd2274f libbladeRF: refactored bladerf_enable_feature
These changes make it much easier to add features to libbladeRF.
The nested ifs have been restructured for a switch and errors leverage
the goto error. The device handle now is also null checked. The mutex
lock has also been removed.

Regression test passed.
2025-04-09 23:17:40 -07:00
Ryan Thompson
0b54c576e3 host: NULL_CHECK made variadic 2025-04-09 23:17:40 -07:00
Ryan Thompson
950189d29d hdl: fix fifo_reader packet mode dma_downcount off-by-one error 2025-04-09 23:17:40 -07:00
Ryan Thompson
16c184b6dc test: added fx3_gpif_iq_packed_tb to regression test 2025-04-09 23:17:40 -07:00
Ryan Thompson
b2d9f969a5 bladeRF-cli: added sc16q11 packed mimo tx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
709d45d853 bladeRF-cli: added sc16q11 packed siso tx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
c407de2c9f bladeRF-cli: added sc16q11 packed mimo rx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
3ae66b49a1 bladeRF-cli: added sc16q11 packed siso rx example 2025-04-09 23:17:40 -07:00
Ryan Thompson
6eab5f6a5e bladeRF-cli: added sc16q11 packed format support 2025-04-09 23:17:40 -07:00
Ryan Thompson
b655422a71 bladeRF-cli: replace cli state member bit_mode_8bit with sample_format
Instead of relying on a bit_mode boolean assignment, we can directly
rely on a bladerf_format state member.
2025-04-09 23:17:40 -07:00
Ryan Thompson
59b68f7bf2 bladeRF-cli: sample format tracked by cli state
This will allow us to track the sample format across the cli and can
replace the bit_mode cli state member.
2025-04-09 23:17:40 -07:00
Ryan Thompson
5ff41748aa libbladeRF: added sc16q11 packed error when initializing async stream
BLADERF_FORMAT_SC16_Q11_PACKED is only supported with the synchronous
interface.
2025-04-09 23:17:40 -07:00
Ryan Thompson
ff1b3d4e97 libbladeRF: added sc16q11 packed tx support 2025-04-09 23:17:40 -07:00
Ryan Thompson
d48f0d568f hdl: added sc16q11 packed tx support 2025-04-09 23:17:40 -07:00
Ryan Thompson
36dddacd27 hdl: added sc16q11 packed format to fx3 model
Every 3 gpif cycles will contain 4 sc12q11 samples when the
packed format is enabled.
2025-04-09 23:17:40 -07:00
Ryan Thompson
057964225f hdl: added sc16q11 packed tx sample drop check 2025-04-09 23:17:40 -07:00
Ryan Thompson
999f632f8c hdl: fixed sc16q11 packed discontinuity on RX overflow
The 12b write cycle and buffer are held constant when in the HOLDOFF
state.
2025-04-09 23:17:40 -07:00
Ryan Thompson
79cae1e87f libbladeRF: added sc16q11 packed sample format
libbladeRF ingests SC12 Q11 samples and expands them to SC16 Q11 before
filling the end buffer. The trade-off is CPU cycles for the 12b to 16b
conversion.
2025-04-09 23:17:40 -07:00
Ryan Thompson
9a22cd26d5 hdl: added sc16q11 packed enable signal from Nios GPIO 2025-04-09 23:17:40 -07:00
Ryan Thompson
6196c71911 hdl: added sc16q11 packed tb 2025-04-09 23:17:40 -07:00
Ryan Thompson
b52f50c1fe hdl: added highly packed mode to fifo writer
Iteratively packs 12b'samples across 3 fifo writes. The meta downcount
operation still needs to be confirmed.
2025-04-09 23:17:40 -07:00
Ryan Thompson
966900a8c1 hdl: added enable signal for highly packed mode 2025-04-09 23:17:40 -07:00
Ryan Thompson
04c1215e02 libbladeRF: test: added packet test 2025-04-09 23:17:40 -07:00
Ryan Thompson
bc6ac13970 doc: updated fx3 firmware folder name 2025-04-09 23:17:40 -07:00
Ryan Thompson
bdd4f39a3d fx3_firmware: rev libbladeRF, hdl, and fx3 for 2048 sample gpif buffers
FX3 GPIF buffers set to 2048 samples and number of buffers reduced to
11 per dma channel. This substantially increases the theoretical USB
SuperSpeed throughput from roughly 228MB/s to 356MB/s.

$ make test_libbladeRF
[       OK ] libbladeRF.scheduled_retune (19755 ms)
[----------] 29 tests from libbladeRF (308802 ms total)

[----------] Global test environment tear-down
[==========] 29 tests from 1 test suite ran. (308802 ms total)
[  PASSED  ] 29 tests.
2025-04-09 23:17:40 -07:00
Ryan Thompson
87e06388d4 hdl: revert jtag timing fixes
SignalTap may throw a "jtag instance not found" error which is sourced
from not meeting timing requirements for the jtag interface. Reverting
previous fixes may resurface some timing issues, but the "instance not
found" error at least goes away and I can use signal tap again.

Sources:
SignalTap-II -> "instance not found" error
https://community.intel.com/t5/Programmable-Devices/SignalTap-II-gt-quot-instance-not-found-quot-error/m-p/238886

How to set timing constraint for JTAG
https://community.intel.com/t5/Programmable-Devices/How-to-set-timing-constraint-for-JTAG/m-p/1379278
2025-04-09 23:17:40 -07:00
Ryan Thompson
d0d6d97eb4 doc: bladeRF-cli: updated sample limit to match buffer limit 2025-04-09 23:17:40 -07:00
Ryan Thompson
a0937cc50c doc: updated buf size limit in examples and tests 2025-04-09 23:17:40 -07:00
Ryan Thompson
a62c1d4903 libbladeRF: support and clamp byte alignment to larger GPIF buffer size
This change also includes a refactor of the redundant format to sample
size conversions found within the synchronous and asynchronous
interfaces.
2025-04-09 23:17:40 -07:00
Ryan Thompson
05ede8f541 fx3_firmware: increase DMA buffer sizes for USB throughput bottleneck
$ make test_hdl
[----------] Global test environment tear-down
[==========] 63 tests from 2 test suites ran. (381209 ms total)
[  PASSED  ] 63 tests.
[100%] Built target test_hdl
2025-04-09 23:17:40 -07:00
Ryan Thompson
2aaa5e2961 hdl: test: added variable gpif buffer length support for 8b testbenches 2025-04-09 23:17:40 -07:00
Ryan Thompson
5d7ff6a0ea hdl: test: added variable gpif buffer length support for gpif meta tb 2025-04-09 23:17:40 -07:00
Ryan Thompson
37d3e0b2e5 hdl: test: added variable gpif buffer length support for fx3_gpif_iq_tb 2025-04-09 23:17:40 -07:00
Ryan Thompson
6a0de33642 hdl: test: variable gpif buf length support added to testbenches 2025-04-09 23:17:40 -07:00
Ryan Thompson
89caa01c12 hdl: test: added variable length gpif support to fx3_model 2025-04-09 23:17:40 -07:00
Ryan Thompson
27fe2f48ea hdl: moved gpif buf size constants to fx3 gpif package
As we add changes to the FX3, it will be much easier to have a single
source of truth for the GPIF DMA sizes. This commit should not introduce
any changes to simulation or synthesis results.
2025-04-09 23:17:40 -07:00
Ryan Thompson
77d234c3bb hdl: leverage full sample depth of sample fifos
We were limiting ourselves to half of the fifo depth and subtracting
4 gpif buffers from that, which is 1/4 of the current fifo depth. No
sign of a full fifo during siso, mimo, meta, and non-meta streaming
tests at low sample rates. The fifo writes are appropriately held off.
2025-04-09 23:17:40 -07:00
Ryan Thompson
367df45e75 hdl: fixed fifo ingestion arithmetic on tx enable toggle
The channel shift would be left at 1 after the state moved to
COMPUTE_ENABLED_CHANNELS. Samples left would be reassigned to 1 in
COMPUTE_OFFSETS. Then channel offset would be assigned 2, an invalid
value.

This change only assigns samples left and channel shift if at the 0th
sample index, which allows for sample continuity.
2025-04-09 23:17:40 -07:00
Ryan Thompson
f230c9dc8d hdl: test: added gpif fifo stress test testbench
This copies the gpif 8b testbench, but with 7 blocks per TX iteration
and 2 subsequent iteration repeats. Run for 4ms to find channel shift
reset failure.
2025-04-09 23:17:40 -07:00
Ryan Thompson
465ea0a49e libbladeRF: test: added streaming test
The streaming test allows for cross testing between MIMO, SISO, TX, RX, meta,
and non-meta configurations.

Example: TX a CW at 50MSPS and at a frequency of (915MHz+50MHz/16) with meta enabled
./output/libbladeRF_test_streaming -te -s 50M

Example: TX and RX at 25MSPS and at a frequency of (915MHz+25MHz/16) without meta enabled
./output/libbladeRF_test_streaming -tr -s 25M
2025-04-09 23:17:40 -07:00
Ryan Thompson
ffd7f52a40 hdl: added git information to build output 2025-04-09 23:17:40 -07:00
Ryan Thompson
a8481c2af7 doc: added packet length warning for BLADERF_FORMAT_PACKET_META
A packet length of (n*256-4) DWORDs will cause the synchronous
buffer it's filled into to indefinitely persist.
2025-04-09 23:17:40 -07:00
Ryan Thompson
73e78639aa doc: fix API sections menu item with Doxygen 1.9.8
The API sections aren't stored as modules anymore. They're topics.
Error likely introduced at doxygen commit: 6d80fc7e5
2025-04-09 23:17:40 -07:00
Ryan Thompson
3cc8e3c54e hdl: fixed late exit from meta down count state
The expected two cycle passing between meta write and idle states is
independent of the number of streams. Specifically addresses an
off-by-one timestamp error with the bladeRF 1.0.
2025-04-09 23:17:40 -07:00
Ryan Thompson
65cdf88994 bladeRF-power: fixed ncurses dep
On macOS, sometimes the ${CURSES_LIBRARIES} variable provided by
 find_package(Curses) doesn't correctly include all the necessary linkage
 information, especially when using wide character support. By explicitly adding
 ncurses to the link libraries for Apple platforms, we ensure that the linker
 can find all the required symbols.
2025-04-09 23:17:33 -07:00
222 changed files with 5091 additions and 10688 deletions

3
.gitignore vendored
View file

@ -57,5 +57,8 @@ host/misc/windows/scripts/work
env/
venv/
ENV/
__pycache__/
*.py[cod]
*$py.class
.vscode/

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "thirdparty/analogdevicesinc/no-OS"]
path = thirdparty/analogdevicesinc/no-OS
url = https://github.com/analogdevicesinc/no-OS/
[submodule "host/utilities/bladeRF-fsk"]
path = host/utilities/bladeRF-fsk
url = https://github.com/Nuand/bladeRF-fsk

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(bladeRF CXX C)
# Indicate that this is a top-level build
set(BLADERF_TOP_LEVEL_BUILD ON)

View file

@ -1,7 +1,7 @@
#!/bin/sh -e
UPSTREAM='https://www.nuand.com/fx3/bladeRF_fw_v2.4.0.img'
CHECKSUM='337f570f2e3fdb26abde0f0765196d92'
UPSTREAM='https://www.nuand.com/fx3/bladeRF_fw_v2.6.0.img'
CHECKSUM='7cc51b4eedebf54dd01be83745d1c59f'
DATAFILE='/usr/share/Nuand/bladeRF/bladeRF_fw.img'
DESCRIPT='firmware'
MYNAMEIS='bladerf-firmware-fx3'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedx115.rbf'
CHECKSUM='94ee5c7f68abe5c3392202246789fedd'
UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedx115.rbf'
CHECKSUM='a7f25be8abdab3835e734599eb846ea4'
DATAFILE='/usr/share/Nuand/bladeRF/hostedx115.rbf'
DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedx115'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedx40.rbf'
CHECKSUM='25f402b3734c9aa0d37db9531f93335c'
UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedx40.rbf'
CHECKSUM='f3d0e55aa4cae485df6d3c20004b7742'
DATAFILE='/usr/share/Nuand/bladeRF/hostedx40.rbf'
DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedx40'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedxA4.rbf'
CHECKSUM='c24af70cf56b13123295125a22d5e921'
UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA4.rbf'
CHECKSUM='276a74b748d699a9fc348babd34af19c'
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA4.rbf'
DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedxa4'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedxA5.rbf'
CHECKSUM='ae6391cc3fd467bbb07868450612ce17'
UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA5.rbf'
CHECKSUM='be0909dc27b48a08c54db33675130f27'
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA5.rbf'
DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedxa5'

View file

@ -1,7 +1,7 @@
#!/bin/sh -e
UPSTREAM='https://www.nuand.com/fpga/v0.14.0/hostedxA9.rbf'
CHECKSUM='7dfe8c32f260d43a14b9583375a1a6eb'
UPSTREAM='https://www.nuand.com/fpga/v0.16.0/hostedxA9.rbf'
CHECKSUM='1ab3bc8bdcf16a5f0ddf3fcdbaa6556b'
DATAFILE='/usr/share/Nuand/bladeRF/hostedxA9.rbf'
DESCRIPT='FPGA bitstream'
MYNAMEIS='bladerf-fpga-hostedxa9'

4
debian/control vendored
View file

@ -2,8 +2,8 @@ Source: bladerf
Priority: optional
Maintainer: Nuand LLC <bladeRF@nuand.com>
Build-Depends: debhelper (>=9), cmake (>= 2.8.5), pkg-config, doxygen,
libusb-1.0-0-dev (>= 1.0.12), libtecla-dev | libtecla1-dev, libncurses5-dev,
git, help2man, pandoc
libusb-1.0-0-dev (>= 1.0.12), libedit-dev, libncurses5-dev,
git, help2man, pandoc, libcurl4-openssl-dev
Standards-Version: 4.1.4
Section: comm
Homepage: https://www.nuand.com/bladeRF

11
debian/copyright vendored
View file

@ -60,17 +60,6 @@ License: OpenCores-I2C
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Files: host/cmake/modules/FindLibPThreadsWin32.cmake
Copyright: 2008-2009 Hendrik Sattler
2013-2018 Nuand LLC
License: GPL-2+
Comment: This is file is based off of the FindLibUSB.cmake file written by
Hendrik Sattler, from the OpenOBEX project (licensed GPLv2/LGPL). (If
this is not correct, please contact us so we can attribute the author
appropriately.)
https://github.com/zuckschwerdt/openobex/blob/master/CMakeModules/FindLibUSB.cmake
http://dev.zuckschwerdt.org/openobex/
Files: host/cmake/modules/FindLibUSB.cmake
Copyright: 2008-2009 Hendrik Sattler
2013-2018 Nuand LLC

View file

@ -29,6 +29,8 @@
#include <inttypes.h>
#include <stdbool.h>
#include <ad9361_api.h>
/**
* The purpose of this header file is to allow the use of libad9361 without
* including all of the unnecessary defines, etc, used during compilation.
@ -46,15 +48,6 @@
* From common.h
******************************************************************************/
struct clk_onecell_data {
struct clk **clks;
uint32_t clk_num;
};
/******************************************************************************
* From ad9361.h
******************************************************************************/
#define AD936X_REG_TX1_OUT_1_PHASE_CORR 0x08E
#define AD936X_REG_TX1_OUT_1_GAIN_CORR 0x08F
#define AD936X_REG_TX2_OUT_1_PHASE_CORR 0x090
@ -98,681 +91,6 @@ struct clk_onecell_data {
#define AD936X_CNT(x) ((((x)-1) & 0x7) << 12)
#define AD936X_ADDR(x) ((x)&0x3FF)
enum dev_id { ID_AD9361, ID_AD9364, ID_AD9363A };
enum ad9361_clocks {
BB_REFCLK,
RX_REFCLK,
TX_REFCLK,
BBPLL_CLK,
ADC_CLK,
R2_CLK,
R1_CLK,
CLKRF_CLK,
RX_SAMPL_CLK,
DAC_CLK,
T2_CLK,
T1_CLK,
CLKTF_CLK,
TX_SAMPL_CLK,
RX_RFPLL_INT,
TX_RFPLL_INT,
RX_RFPLL_DUMMY,
TX_RFPLL_DUMMY,
RX_RFPLL,
TX_RFPLL,
NUM_AD9361_CLKS,
EXT_REF_CLK,
};
enum rx_gain_table_name {
TBL_200_1300_MHZ,
TBL_1300_4000_MHZ,
TBL_4000_6000_MHZ,
RXGAIN_TBLS_END,
};
enum rx_gain_table_type {
RXGAIN_FULL_TBL,
RXGAIN_SPLIT_TBL,
};
struct rx_gain_info {
enum rx_gain_table_type tbl_type;
int32_t starting_gain_db;
int32_t max_gain_db;
int32_t gain_step_db;
int32_t max_idx;
int32_t idx_step_offset;
};
enum ad9361_pdata_rx_freq {
BBPLL_FREQ,
ADC_FREQ,
R2_FREQ,
R1_FREQ,
CLKRF_FREQ,
RX_SAMPL_FREQ,
NUM_RX_CLOCKS,
};
enum ad9361_pdata_tx_freq {
IGNORE_FREQ,
DAC_FREQ,
T2_FREQ,
T1_FREQ,
CLKTF_FREQ,
TX_SAMPL_FREQ,
NUM_TX_CLOCKS,
};
struct ad9361_fastlock_entry {
//#define FASTLOOK_INIT 1
uint8_t flags;
uint8_t alc_orig;
uint8_t alc_written;
};
struct ad9361_fastlock {
uint8_t save_profile;
uint8_t current_profile[2];
struct ad9361_fastlock_entry entry[2][8];
};
enum ad9361_bist_mode {
BIST_DISABLE,
BIST_INJ_TX,
BIST_INJ_RX,
};
enum ad9361_clkout {
CLKOUT_DISABLE,
BUFFERED_XTALN_DCXO,
ADC_CLK_DIV_2,
ADC_CLK_DIV_3,
ADC_CLK_DIV_4,
ADC_CLK_DIV_8,
ADC_CLK_DIV_16,
};
enum rf_gain_ctrl_mode {
RF_GAIN_MGC,
RF_GAIN_FASTATTACK_AGC,
RF_GAIN_SLOWATTACK_AGC,
RF_GAIN_HYBRID_AGC
};
enum f_agc_target_gain_index_type {
MAX_GAIN,
SET_GAIN,
OPTIMIZED_GAIN,
NO_GAIN_CHANGE,
};
enum rssi_restart_mode {
AGC_IN_FAST_ATTACK_MODE_LOCKS_THE_GAIN,
EN_AGC_PIN_IS_PULLED_HIGH,
ENTERS_RX_MODE,
GAIN_CHANGE_OCCURS,
SPI_WRITE_TO_REGISTER,
GAIN_CHANGE_OCCURS_OR_EN_AGC_PIN_PULLED_HIGH,
};
struct rssi_control {
enum rssi_restart_mode restart_mode;
bool rssi_unit_is_rx_samples;
uint32_t rssi_delay;
uint32_t rssi_wait;
uint32_t rssi_duration;
};
struct port_control {
uint8_t pp_conf[3];
uint8_t rx_clk_data_delay;
uint8_t tx_clk_data_delay;
uint8_t digital_io_ctrl;
uint8_t lvds_bias_ctrl;
uint8_t lvds_invert[2];
uint8_t clk_out_drive;
uint8_t dataclk_drive;
uint8_t data_port_drive;
uint8_t clk_out_slew;
uint8_t dataclk_slew;
uint8_t data_port_slew;
};
struct ctrl_outs_control {
uint8_t index;
uint8_t en_mask;
};
struct elna_control {
uint16_t gain_mdB;
uint16_t bypass_loss_mdB;
uint32_t settling_delay_ns;
bool elna_1_control_en;
bool elna_2_control_en;
bool elna_in_gaintable_all_index_en;
};
struct auxadc_control {
int8_t offset;
uint32_t temp_time_inteval_ms;
uint32_t temp_sensor_decimation;
bool periodic_temp_measuremnt;
uint32_t auxadc_clock_rate;
uint32_t auxadc_decimation;
};
struct auxdac_control {
uint16_t dac1_default_value;
uint16_t dac2_default_value;
bool auxdac_manual_mode_en;
bool dac1_in_rx_en;
bool dac1_in_tx_en;
bool dac1_in_alert_en;
bool dac2_in_rx_en;
bool dac2_in_tx_en;
bool dac2_in_alert_en;
uint8_t dac1_rx_delay_us;
uint8_t dac1_tx_delay_us;
uint8_t dac2_rx_delay_us;
uint8_t dac2_tx_delay_us;
};
struct gpo_control {
bool gpo0_inactive_state_high_en;
bool gpo1_inactive_state_high_en;
bool gpo2_inactive_state_high_en;
bool gpo3_inactive_state_high_en;
bool gpo0_slave_rx_en;
bool gpo0_slave_tx_en;
bool gpo1_slave_rx_en;
bool gpo1_slave_tx_en;
bool gpo2_slave_rx_en;
bool gpo2_slave_tx_en;
bool gpo3_slave_rx_en;
bool gpo3_slave_tx_en;
uint8_t gpo0_rx_delay_us;
uint8_t gpo0_tx_delay_us;
uint8_t gpo1_rx_delay_us;
uint8_t gpo1_tx_delay_us;
uint8_t gpo2_rx_delay_us;
uint8_t gpo2_tx_delay_us;
uint8_t gpo3_rx_delay_us;
uint8_t gpo3_tx_delay_us;
};
struct tx_monitor_control {
bool tx_mon_track_en;
bool one_shot_mode_en;
uint32_t low_high_gain_threshold_mdB;
uint8_t low_gain_dB;
uint8_t high_gain_dB;
uint16_t tx_mon_delay;
uint16_t tx_mon_duration;
uint8_t tx1_mon_front_end_gain;
uint8_t tx2_mon_front_end_gain;
uint8_t tx1_mon_lo_cm;
uint8_t tx2_mon_lo_cm;
};
struct gain_control {
enum rf_gain_ctrl_mode rx1_mode;
enum rf_gain_ctrl_mode rx2_mode;
uint8_t adc_ovr_sample_size;
uint8_t adc_small_overload_thresh;
uint8_t adc_large_overload_thresh;
uint16_t lmt_overload_high_thresh;
uint16_t lmt_overload_low_thresh;
uint16_t dec_pow_measuremnt_duration;
uint8_t low_power_thresh;
bool dig_gain_en;
uint8_t max_dig_gain;
bool mgc_rx1_ctrl_inp_en;
bool mgc_rx2_ctrl_inp_en;
uint8_t mgc_inc_gain_step;
uint8_t mgc_dec_gain_step;
uint8_t mgc_split_table_ctrl_inp_gain_mode;
uint8_t agc_attack_delay_extra_margin_us;
uint8_t agc_outer_thresh_high;
uint8_t agc_outer_thresh_high_dec_steps;
uint8_t agc_inner_thresh_high;
uint8_t agc_inner_thresh_high_dec_steps;
uint8_t agc_inner_thresh_low;
uint8_t agc_inner_thresh_low_inc_steps;
uint8_t agc_outer_thresh_low;
uint8_t agc_outer_thresh_low_inc_steps;
uint8_t adc_small_overload_exceed_counter;
uint8_t adc_large_overload_exceed_counter;
uint8_t adc_large_overload_inc_steps;
bool adc_lmt_small_overload_prevent_gain_inc;
uint8_t lmt_overload_large_exceed_counter;
uint8_t lmt_overload_small_exceed_counter;
uint8_t lmt_overload_large_inc_steps;
uint8_t dig_saturation_exceed_counter;
uint8_t dig_gain_step_size;
bool sync_for_gain_counter_en;
uint32_t gain_update_interval_us;
bool immed_gain_change_if_large_adc_overload;
bool immed_gain_change_if_large_lmt_overload;
uint32_t f_agc_dec_pow_measuremnt_duration;
uint32_t f_agc_state_wait_time_ns;
bool f_agc_allow_agc_gain_increase;
uint8_t f_agc_lp_thresh_increment_time;
uint8_t f_agc_lp_thresh_increment_steps;
uint8_t f_agc_lock_level;
bool f_agc_lock_level_lmt_gain_increase_en;
uint8_t f_agc_lock_level_gain_increase_upper_limit;
uint8_t f_agc_lpf_final_settling_steps;
uint8_t f_agc_lmt_final_settling_steps;
uint8_t f_agc_final_overrange_count;
bool f_agc_gain_increase_after_gain_lock_en;
enum f_agc_target_gain_index_type f_agc_gain_index_type_after_exit_rx_mode;
bool f_agc_use_last_lock_level_for_set_gain_en;
uint8_t f_agc_optimized_gain_offset;
bool f_agc_rst_gla_stronger_sig_thresh_exceeded_en;
uint8_t f_agc_rst_gla_stronger_sig_thresh_above_ll;
bool f_agc_rst_gla_engergy_lost_sig_thresh_exceeded_en;
bool f_agc_rst_gla_engergy_lost_goto_optim_gain_en;
uint8_t f_agc_rst_gla_engergy_lost_sig_thresh_below_ll;
uint8_t f_agc_energy_lost_stronger_sig_gain_lock_exit_cnt;
bool f_agc_rst_gla_large_adc_overload_en;
bool f_agc_rst_gla_large_lmt_overload_en;
bool f_agc_rst_gla_en_agc_pulled_high_en;
enum f_agc_target_gain_index_type f_agc_rst_gla_if_en_agc_pulled_high_mode;
uint8_t f_agc_power_measurement_duration_in_state5;
};
struct ad9361_phy_platform_data {
bool rx2tx2;
bool fdd;
bool fdd_independent_mode;
bool split_gt;
bool use_extclk;
bool ensm_pin_pulse_mode;
bool ensm_pin_ctrl;
bool debug_mode;
bool tdd_use_dual_synth;
bool tdd_skip_vco_cal;
bool use_ext_rx_lo;
bool use_ext_tx_lo;
bool rx1rx2_phase_inversion_en;
bool qec_tracking_slow_mode_en;
uint8_t dc_offset_update_events;
uint8_t dc_offset_attenuation_high;
uint8_t dc_offset_attenuation_low;
uint8_t rf_dc_offset_count_high;
uint8_t rf_dc_offset_count_low;
uint8_t dig_interface_tune_skipmode;
uint8_t dig_interface_tune_fir_disable;
uint32_t dcxo_coarse;
uint32_t dcxo_fine;
uint32_t rf_rx_input_sel;
uint32_t rf_tx_output_sel;
uint32_t rx1tx1_mode_use_rx_num;
uint32_t rx1tx1_mode_use_tx_num;
uint32_t rx_path_clks[NUM_RX_CLOCKS];
uint32_t tx_path_clks[NUM_TX_CLOCKS];
uint32_t trx_synth_max_fref;
uint64_t rx_synth_freq;
uint64_t tx_synth_freq;
uint32_t rf_rx_bandwidth_Hz;
uint32_t rf_tx_bandwidth_Hz;
int32_t tx_atten;
bool update_tx_gain_via_alert;
uint32_t rx_fastlock_delay_ns;
uint32_t tx_fastlock_delay_ns;
bool trx_fastlock_pinctrl_en[2];
enum ad9361_clkout ad9361_clkout_mode;
struct gain_control gain_ctrl;
struct rssi_control rssi_ctrl;
struct port_control port_ctrl;
struct ctrl_outs_control ctrl_outs_ctrl;
struct elna_control elna_ctrl;
struct auxadc_control auxadc_ctrl;
struct auxdac_control auxdac_ctrl;
struct gpo_control gpo_ctrl;
struct tx_monitor_control txmon_ctrl;
int32_t gpio_resetb;
int32_t gpio_sync;
int32_t gpio_cal_sw1;
int32_t gpio_cal_sw2;
};
struct ad9361_rf_phy {
enum dev_id dev_sel;
uint8_t id_no;
struct spi_device *spi;
struct gpio_device *gpio;
struct clk *clk_refin;
struct clk *clks[NUM_AD9361_CLKS];
struct refclk_scale *ref_clk_scale[NUM_AD9361_CLKS];
struct clk_onecell_data clk_data;
uint32_t (*ad9361_rfpll_ext_recalc_rate)(struct refclk_scale *clk_priv);
int32_t (*ad9361_rfpll_ext_round_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
int32_t (*ad9361_rfpll_ext_set_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
struct ad9361_phy_platform_data *pdata;
uint8_t prev_ensm_state;
uint8_t curr_ensm_state;
uint8_t cached_rx_rfpll_div;
uint8_t cached_tx_rfpll_div;
struct rx_gain_info rx_gain[RXGAIN_TBLS_END];
enum rx_gain_table_name current_table;
bool ensm_pin_ctl_en;
bool auto_cal_en;
uint64_t last_tx_quad_cal_freq;
uint32_t last_tx_quad_cal_phase;
uint64_t current_tx_lo_freq;
uint64_t current_rx_lo_freq;
bool current_tx_use_tdd_table;
bool current_rx_use_tdd_table;
uint32_t flags;
uint32_t cal_threshold_freq;
uint32_t current_rx_bw_Hz;
uint32_t current_tx_bw_Hz;
uint32_t rxbbf_div;
uint32_t rate_governor;
bool bypass_rx_fir;
bool bypass_tx_fir;
bool rx_eq_2tx;
bool filt_valid;
uint32_t filt_rx_path_clks[NUM_RX_CLOCKS];
uint32_t filt_tx_path_clks[NUM_TX_CLOCKS];
uint32_t filt_rx_bw_Hz;
uint32_t filt_tx_bw_Hz;
uint8_t tx_fir_int;
uint8_t tx_fir_ntaps;
uint8_t rx_fir_dec;
uint8_t rx_fir_ntaps;
uint8_t agc_mode[2];
bool rfdc_track_en;
bool bbdc_track_en;
bool quad_track_en;
bool txmon_tdd_en;
uint16_t auxdac1_value;
uint16_t auxdac2_value;
uint32_t tx1_atten_cached;
uint32_t tx2_atten_cached;
struct ad9361_fastlock fastlock;
struct axiadc_converter *adc_conv;
struct axiadc_state *adc_state;
int32_t bist_loopback_mode;
enum ad9361_bist_mode bist_prbs_mode;
enum ad9361_bist_mode bist_tone_mode;
uint32_t bist_tone_freq_Hz;
uint32_t bist_tone_level_dB;
uint32_t bist_tone_mask;
bool bbpll_initialized;
};
struct rf_rx_gain {
uint32_t ant;
int32_t gain_db;
uint32_t fgt_lmt_index;
uint32_t lmt_gain;
uint32_t lpf_gain;
uint32_t digital_gain;
uint32_t lna_index;
uint32_t tia_index;
uint32_t mixer_index;
};
struct rf_rssi {
uint32_t ant;
uint32_t symbol;
uint32_t preamble;
int32_t multiplier;
uint8_t duration;
};
int32_t ad9361_get_rx_gain(struct ad9361_rf_phy *phy,
uint32_t rx_id,
struct rf_rx_gain *rx_gain);
int32_t ad9361_spi_read(struct spi_device *spi, uint32_t reg);
int32_t ad9361_spi_write(struct spi_device *spi, uint32_t reg, uint32_t val);
void ad9361_get_bist_loopback(struct ad9361_rf_phy *phy, int32_t *mode);
int32_t ad9361_bist_loopback(struct ad9361_rf_phy *phy, int32_t mode);
/******************************************************************************
* From ad9361_api.h
******************************************************************************/
typedef struct {
enum dev_id dev_sel;
uint8_t id_no;
uint32_t reference_clk_rate;
uint8_t two_rx_two_tx_mode_enable;
uint8_t one_rx_one_tx_mode_use_rx_num;
uint8_t one_rx_one_tx_mode_use_tx_num;
uint8_t frequency_division_duplex_mode_enable;
uint8_t frequency_division_duplex_independent_mode_enable;
uint8_t tdd_use_dual_synth_mode_enable;
uint8_t tdd_skip_vco_cal_enable;
uint32_t tx_fastlock_delay_ns;
uint32_t rx_fastlock_delay_ns;
uint8_t rx_fastlock_pincontrol_enable;
uint8_t tx_fastlock_pincontrol_enable;
uint8_t external_rx_lo_enable;
uint8_t external_tx_lo_enable;
uint8_t dc_offset_tracking_update_event_mask;
uint8_t dc_offset_attenuation_high_range;
uint8_t dc_offset_attenuation_low_range;
uint8_t dc_offset_count_high_range;
uint8_t dc_offset_count_low_range;
uint8_t split_gain_table_mode_enable;
uint32_t trx_synthesizer_target_fref_overwrite_hz;
uint8_t qec_tracking_slow_mode_enable;
uint8_t ensm_enable_pin_pulse_mode_enable;
uint8_t ensm_enable_txnrx_control_enable;
uint64_t rx_synthesizer_frequency_hz;
uint64_t tx_synthesizer_frequency_hz;
uint32_t rx_path_clock_frequencies[6];
uint32_t tx_path_clock_frequencies[6];
uint32_t rf_rx_bandwidth_hz;
uint32_t rf_tx_bandwidth_hz;
uint32_t rx_rf_port_input_select;
uint32_t tx_rf_port_input_select;
int32_t tx_attenuation_mdB;
uint8_t update_tx_gain_in_alert_enable;
uint8_t xo_disable_use_ext_refclk_enable;
uint32_t dcxo_coarse_and_fine_tune[2];
uint32_t clk_output_mode_select;
uint8_t gc_rx1_mode;
uint8_t gc_rx2_mode;
uint8_t gc_adc_large_overload_thresh;
uint8_t gc_adc_ovr_sample_size;
uint8_t gc_adc_small_overload_thresh;
uint16_t gc_dec_pow_measurement_duration;
uint8_t gc_dig_gain_enable;
uint16_t gc_lmt_overload_high_thresh;
uint16_t gc_lmt_overload_low_thresh;
uint8_t gc_low_power_thresh;
uint8_t gc_max_dig_gain;
uint8_t mgc_dec_gain_step;
uint8_t mgc_inc_gain_step;
uint8_t mgc_rx1_ctrl_inp_enable;
uint8_t mgc_rx2_ctrl_inp_enable;
uint8_t mgc_split_table_ctrl_inp_gain_mode;
uint8_t agc_adc_large_overload_exceed_counter;
uint8_t agc_adc_large_overload_inc_steps;
uint8_t agc_adc_lmt_small_overload_prevent_gain_inc_enable;
uint8_t agc_adc_small_overload_exceed_counter;
uint8_t agc_dig_gain_step_size;
uint8_t agc_dig_saturation_exceed_counter;
uint32_t agc_gain_update_interval_us;
uint8_t agc_immed_gain_change_if_large_adc_overload_enable;
uint8_t agc_immed_gain_change_if_large_lmt_overload_enable;
uint8_t agc_inner_thresh_high;
uint8_t agc_inner_thresh_high_dec_steps;
uint8_t agc_inner_thresh_low;
uint8_t agc_inner_thresh_low_inc_steps;
uint8_t agc_lmt_overload_large_exceed_counter;
uint8_t agc_lmt_overload_large_inc_steps;
uint8_t agc_lmt_overload_small_exceed_counter;
uint8_t agc_outer_thresh_high;
uint8_t agc_outer_thresh_high_dec_steps;
uint8_t agc_outer_thresh_low;
uint8_t agc_outer_thresh_low_inc_steps;
uint32_t agc_attack_delay_extra_margin_us;
uint8_t agc_sync_for_gain_counter_enable;
uint32_t fagc_dec_pow_measuremnt_duration;
uint32_t fagc_state_wait_time_ns;
uint8_t fagc_allow_agc_gain_increase;
uint32_t fagc_lp_thresh_increment_time;
uint32_t fagc_lp_thresh_increment_steps;
uint8_t fagc_lock_level_lmt_gain_increase_en;
uint32_t fagc_lock_level_gain_increase_upper_limit;
uint32_t fagc_lpf_final_settling_steps;
uint32_t fagc_lmt_final_settling_steps;
uint32_t fagc_final_overrange_count;
uint8_t fagc_gain_increase_after_gain_lock_en;
uint32_t fagc_gain_index_type_after_exit_rx_mode;
uint8_t fagc_use_last_lock_level_for_set_gain_en;
uint8_t fagc_rst_gla_stronger_sig_thresh_exceeded_en;
uint32_t fagc_optimized_gain_offset;
uint32_t fagc_rst_gla_stronger_sig_thresh_above_ll;
uint8_t fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en;
uint8_t fagc_rst_gla_engergy_lost_goto_optim_gain_en;
uint32_t fagc_rst_gla_engergy_lost_sig_thresh_below_ll;
uint32_t fagc_energy_lost_stronger_sig_gain_lock_exit_cnt;
uint8_t fagc_rst_gla_large_adc_overload_en;
uint8_t fagc_rst_gla_large_lmt_overload_en;
uint8_t fagc_rst_gla_en_agc_pulled_high_en;
uint32_t fagc_rst_gla_if_en_agc_pulled_high_mode;
uint32_t fagc_power_measurement_duration_in_state5;
uint32_t rssi_delay;
uint32_t rssi_duration;
uint8_t rssi_restart_mode;
uint8_t rssi_unit_is_rx_samples_enable;
uint32_t rssi_wait;
uint32_t aux_adc_decimation;
uint32_t aux_adc_rate;
uint8_t aux_dac_manual_mode_enable;
uint32_t aux_dac1_default_value_mV;
uint8_t aux_dac1_active_in_rx_enable;
uint8_t aux_dac1_active_in_tx_enable;
uint8_t aux_dac1_active_in_alert_enable;
uint32_t aux_dac1_rx_delay_us;
uint32_t aux_dac1_tx_delay_us;
uint32_t aux_dac2_default_value_mV;
uint8_t aux_dac2_active_in_rx_enable;
uint8_t aux_dac2_active_in_tx_enable;
uint8_t aux_dac2_active_in_alert_enable;
uint32_t aux_dac2_rx_delay_us;
uint32_t aux_dac2_tx_delay_us;
uint32_t temp_sense_decimation;
uint16_t temp_sense_measurement_interval_ms;
int8_t temp_sense_offset_signed;
uint8_t temp_sense_periodic_measurement_enable;
uint8_t ctrl_outs_enable_mask;
uint8_t ctrl_outs_index;
uint32_t elna_settling_delay_ns;
uint32_t elna_gain_mdB;
uint32_t elna_bypass_loss_mdB;
uint8_t elna_rx1_gpo0_control_enable;
uint8_t elna_rx2_gpo1_control_enable;
uint8_t elna_gaintable_all_index_enable;
uint8_t digital_interface_tune_skip_mode;
uint8_t digital_interface_tune_fir_disable;
uint8_t pp_tx_swap_enable;
uint8_t pp_rx_swap_enable;
uint8_t tx_channel_swap_enable;
uint8_t rx_channel_swap_enable;
uint8_t rx_frame_pulse_mode_enable;
uint8_t two_t_two_r_timing_enable;
uint8_t invert_data_bus_enable;
uint8_t invert_data_clk_enable;
uint8_t fdd_alt_word_order_enable;
uint8_t invert_rx_frame_enable;
uint8_t fdd_rx_rate_2tx_enable;
uint8_t swap_ports_enable;
uint8_t single_data_rate_enable;
uint8_t lvds_mode_enable;
uint8_t half_duplex_mode_enable;
uint8_t single_port_mode_enable;
uint8_t full_port_enable;
uint8_t full_duplex_swap_bits_enable;
uint32_t delay_rx_data;
uint32_t rx_data_clock_delay;
uint32_t rx_data_delay;
uint32_t tx_fb_clock_delay;
uint32_t tx_data_delay;
uint32_t lvds_bias_mV;
uint8_t lvds_rx_onchip_termination_enable;
uint8_t rx1rx2_phase_inversion_en;
uint8_t lvds_invert1_control;
uint8_t lvds_invert2_control;
uint8_t clk_out_drive;
uint8_t dataclk_drive;
uint8_t data_port_drive;
uint8_t clk_out_slew;
uint8_t dataclk_slew;
uint8_t data_port_slew;
uint8_t gpo0_inactive_state_high_enable;
uint8_t gpo1_inactive_state_high_enable;
uint8_t gpo2_inactive_state_high_enable;
uint8_t gpo3_inactive_state_high_enable;
uint8_t gpo0_slave_rx_enable;
uint8_t gpo0_slave_tx_enable;
uint8_t gpo1_slave_rx_enable;
uint8_t gpo1_slave_tx_enable;
uint8_t gpo2_slave_rx_enable;
uint8_t gpo2_slave_tx_enable;
uint8_t gpo3_slave_rx_enable;
uint8_t gpo3_slave_tx_enable;
uint8_t gpo0_rx_delay_us;
uint8_t gpo0_tx_delay_us;
uint8_t gpo1_rx_delay_us;
uint8_t gpo1_tx_delay_us;
uint8_t gpo2_rx_delay_us;
uint8_t gpo2_tx_delay_us;
uint8_t gpo3_rx_delay_us;
uint8_t gpo3_tx_delay_us;
uint32_t low_high_gain_threshold_mdB;
uint32_t low_gain_dB;
uint32_t high_gain_dB;
uint8_t tx_mon_track_en;
uint8_t one_shot_mode_en;
uint32_t tx_mon_delay;
uint32_t tx_mon_duration;
uint32_t tx1_mon_front_end_gain;
uint32_t tx2_mon_front_end_gain;
uint32_t tx1_mon_lo_cm;
uint32_t tx2_mon_lo_cm;
int32_t gpio_resetb;
int32_t gpio_sync;
int32_t gpio_cal_sw1;
int32_t gpio_cal_sw2;
uint32_t (*ad9361_rfpll_ext_recalc_rate)(struct refclk_scale *clk_priv);
int32_t (*ad9361_rfpll_ext_round_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
int32_t (*ad9361_rfpll_ext_set_rate)(struct refclk_scale *clk_priv,
uint32_t rate);
} AD9361_InitParam;
typedef struct {
uint32_t rx; /* 1, 2, 3(both) */
int32_t rx_gain; /* -12, -6, 0, 6 */
uint32_t rx_dec; /* 1, 2, 4 */
int16_t rx_coef[128];
uint8_t rx_coef_size;
uint32_t rx_path_clks[6];
uint32_t rx_bandwidth;
} AD9361_RXFIRConfig;
typedef struct {
uint32_t tx; /* 1, 2, 3(both) */
int32_t tx_gain; /* -6, 0 */
uint32_t tx_int; /* 1, 2, 4 */
int16_t tx_coef[128];
uint8_t tx_coef_size;
uint32_t tx_path_clks[6];
uint32_t tx_bandwidth;
} AD9361_TXFIRConfig;
#define AD936X_A_BALANCED 0
#define AD936X_B_BALANCED 1
#define AD936X_C_BALANCED 2
@ -789,70 +107,5 @@ typedef struct {
#define AD936X_TXA 0
#define AD936X_TXB 1
int32_t ad9361_init(struct ad9361_rf_phy **ad9361_phy,
AD9361_InitParam *init_param,
void *userdata);
int32_t ad9361_deinit(struct ad9361_rf_phy *phy);
int32_t ad9361_set_rx_rf_gain(struct ad9361_rf_phy *phy,
uint8_t ch,
int32_t gain_db);
int32_t ad9361_set_rx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t bandwidth_hz);
int32_t ad9361_get_rx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t *bandwidth_hz);
int32_t ad9361_set_rx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t sampling_freq_hz);
int32_t ad9361_get_rx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t *sampling_freq_hz);
int32_t ad9361_set_rx_lo_freq(struct ad9361_rf_phy *phy, uint64_t lo_freq_hz);
int32_t ad9361_get_rx_lo_freq(struct ad9361_rf_phy *phy, uint64_t *lo_freq_hz);
int32_t ad9361_get_rx_rssi(struct ad9361_rf_phy *phy,
uint8_t ch,
struct rf_rssi *rssi);
int32_t ad9361_set_rx_gain_control_mode(struct ad9361_rf_phy *phy,
uint8_t ch,
uint8_t gc_mode);
int32_t ad9361_get_rx_gain_control_mode(struct ad9361_rf_phy *phy,
uint8_t ch,
uint8_t *gc_mode);
int32_t ad9361_set_rx_fir_config(struct ad9361_rf_phy *phy,
AD9361_RXFIRConfig fir_cfg);
int32_t ad9361_set_rx_fir_en_dis(struct ad9361_rf_phy *phy, uint8_t en_dis);
int32_t ad9361_set_rx_rf_port_input(struct ad9361_rf_phy *phy, uint32_t mode);
int32_t ad9361_get_rx_rf_port_input(struct ad9361_rf_phy *phy, uint32_t *mode);
int32_t ad9361_set_tx_attenuation(struct ad9361_rf_phy *phy,
uint8_t ch,
uint32_t attenuation_mdb);
int32_t ad9361_get_tx_attenuation(struct ad9361_rf_phy *phy,
uint8_t ch,
uint32_t *attenuation_mdb);
int32_t ad9361_set_tx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t bandwidth_hz);
int32_t ad9361_get_tx_rf_bandwidth(struct ad9361_rf_phy *phy,
uint32_t *bandwidth_hz);
int32_t ad9361_set_tx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t sampling_freq_hz);
int32_t ad9361_get_tx_sampling_freq(struct ad9361_rf_phy *phy,
uint32_t *sampling_freq_hz);
int32_t ad9361_set_tx_lo_freq(struct ad9361_rf_phy *phy, uint64_t lo_freq_hz);
int32_t ad9361_get_tx_lo_freq(struct ad9361_rf_phy *phy, uint64_t *lo_freq_hz);
int32_t ad9361_set_tx_fir_config(struct ad9361_rf_phy *phy,
AD9361_TXFIRConfig fir_cfg);
int32_t ad9361_set_tx_fir_en_dis(struct ad9361_rf_phy *phy, uint8_t en_dis);
int32_t ad9361_get_tx_rssi(struct ad9361_rf_phy *phy,
uint8_t ch,
uint32_t *rssi_db_x_1000);
int32_t ad9361_set_tx_rf_port_output(struct ad9361_rf_phy *phy, uint32_t mode);
int32_t ad9361_get_tx_rf_port_output(struct ad9361_rf_phy *phy, uint32_t *mode);
int32_t ad9361_get_temp(struct ad9361_rf_phy *phy);
int32_t ad9361_rx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile);
int32_t ad9361_rx_fastlock_save(struct ad9361_rf_phy *phy,
uint32_t profile,
uint8_t *values);
int32_t ad9361_tx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile);
int32_t ad9361_tx_fastlock_save(struct ad9361_rf_phy *phy,
uint32_t profile,
uint8_t *values);
int32_t ad9361_set_no_ch_mode(struct ad9361_rf_phy *phy, uint8_t no_ch_mode);
#endif // AD936X_H_

View file

@ -5,6 +5,11 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/nuand/bladeRF
================================================================================
v2.6.0 (2025-05-06)
--------------------------------
* Increase GPIF buffer size for increase performance
* Fixed missing break in BLADE_USB_CMD_QUERY_FPGA_SOURCE command handling
* Improved FX3 SDK setup instructions in README
v2.5.0 (2024-07-30)
--------------------------------

View file

@ -33,7 +33,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../host/cmake/modules)
# Update these definitions when updating the firmware version
set(VERSION_INFO_MAJOR 2)
set(VERSION_INFO_MINOR 5)
set(VERSION_INFO_MINOR 6)
set(VERSION_INFO_PATCH 0)
if(NOT DEFINED VERSION_INFO_EXTRA)

View file

@ -18,7 +18,7 @@ Building the FX3 firmware first requires the download of the [Cypress FX3 SDK][c
**This firmware build requires FX3 SDK version 1.3.3 or later**
[cypress_sdk]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK)
[cypress_sdk]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK) (downloaded file is `ezusbfx3sdk_1.3.5_Linux_x32-x64.tar.gz`)
[CMake](https://cmake.org) is used to configure the build. There are two locations that we must provide to CMake when configuring the build:
@ -27,6 +27,24 @@ Building the FX3 firmware first requires the download of the [Cypress FX3 SDK][c
### Command Line-Based Build (Recommended for Linux Users) ###
#### Setting up the FX3 SDK on Linux ####
1. Extract the contents of `ezusbfx3sdk_1.3.5_Linux_x32-x64.tar.gz` (the contents are 5 .tar.gz files)
2. Extract and arrange two of them such that these folders exist:
- `/opt/cypress/ARM_GCC/arm-2013.11/`
- `/opt/cypress/fx3_firmware_linux/cyfx3sdk/`
##### Ubuntu 20.04 Dependencies #####
On Ubuntu 20.04, you'll need to install 32-bit libraries:
```
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libc6:i386 libstdc++6:i386 libncurses5:i386
```
#### Building the Firmware ####
Below are instructions for building the FX3 firmware from the command-line. This assumes that `cmake` and `make`
are in your `PATH`, and is best suited for Linux developers.

View file

@ -468,6 +468,7 @@ CyBool_t NuandHandleVendorRequest(
case BLADE_USB_CMD_QUERY_FPGA_SOURCE:
ret = (unsigned int)NuandGetFpgaConfigSource();
CyU3PUsbSendRetCode(ret);
break;
case BLADE_USB_CMD_SET_LOOPBACK:
NuandRFLinkLoopBack(wValue);

View file

@ -5,6 +5,30 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/nuand/bladeRF
================================================================================
--------------------------------
v0.16.0 (2025-05-06)
--------------------------------
This version brings significant FPGA improvements including sc16q11 packed mode
support and optimized USB throughput, along with important bug fixes for bladeRF
1.0 and 2.0 micro devices.
Features:
* hdl: Added sc16q11 packed mode for improved sample efficiency
* hdl: Increased FX3 GPIF buffer sizes, boosting USB throughput (~356MB/s)
* hdl: Implemented dynamic Nios base address assignment based on RAM size
* hdl: Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
* nios: Enabled elf-gdb and gdb-server support for improved debugging capability
* hdl: Added git revision information to FPGA build outputs
Fixes:
* hdl: Fixed delayed sample and off-by-one timestamp bugs on bladeRF 1.0
* hdl: Corrected TX meta sample gap issue when timestamp set to META NOW
* hdl: Fixed corrupted UART buffer in command_uart component
* hdl: Resolved TX deadlock scenarios by refactoring RX/TX DMA prioritization
* hdl: Improved FPGA simulation accuracy for bladeRF 1 and 2 micro models
* hdl: Fixed false timing paths and resolved multiple timing violations
--------------------------------
v0.15.3 (2023-08-09)
--------------------------------

View file

@ -1,5 +1,5 @@
# bladeRF HDL Source #
The Cyclone IV FPGA is at the heart of the bladeRF. It interfaces to the Cypress FX3, Lime Micro LMS6002D RF transceiver, Si5338 clock generator chip, and VCTCXO trim DAC. It has an input to read NMEA from a GPS as well as a 1pps input for time synchronization of signals and has a reference input for a reference clock to tame the VCTCXO. Lastly, it connects directly to the expansion header for controlling GPIO or any other interfaces that may reside on the expansion board.
The Cyclone FPGA is at the heart of the bladeRF. It interfaces to the Cypress FX3, Analog Devices AD9361 (bladeRF 2.0 micro) or Lime Micro LMS6002D (bladeRF 1) RF transceiver, Silicon Labs clock generator chip, and VCTCXO trim DAC. It has an input to read NMEA from a GPS as well as a 1pps input for time synchronization of signals and has a reference input for a reference clock to tame the VCTCXO. Lastly, it connects directly to the expansion header for controlling GPIO or any other interfaces that may reside on the expansion board.
The HDL is separated out into two different sections:
@ -18,13 +18,14 @@ Some FPGA binaries are available for [download][download]. Please note the md5
[download]: https://www.nuand.com/fpga/ (nuand/FPGA Images)
## Required Software ##
We use an [Intel (Altera)][intel] [Cyclone IV E FPGA][cive]. The size of the FPGA is the only difference between the x40 and x115 models. Intel provides their [Quartus Prime][quartus] software for synthesizing designs for their FPGAs. The Lite Edition is free of charge, but not open source, and may require registering on their site to download the software.
We use an [Intel (Altera)][intel] [Cyclone V E FPGA][cve] for bladeRF 2.0 micro and a [Cyclone IV E FPGA][cive] for bladeRF 1 (classic). The size of the FPGA is the only difference between different bladeRF models of the same generation (x40 vs x115, xA4 vs xA9). Intel provides their [Quartus Prime][quartus] software for synthesizing designs for their FPGAs. The Lite Edition is free of charge, but not open source, and may require registering on their site to download the software.
**Important Note:** Be sure to download and install [Quartus Prime version 17.1][quartus], which the bladeRF project files are based upon. Updates to Quartus Prime are not guaranteed to be reverse-compatible with earlier Quartus versions, nor will future versions necessarily be reverse-compatible.
**Important Note:** Be sure to download and install [Quartus Prime version 20.1.1][quartus], which the bladeRF project files are based upon. Updates to Quartus Prime are not guaranteed to be reverse-compatible with earlier Quartus versions, nor will future versions necessarily be reverse-compatible. Particularly, newer versions of Quartus may not support older generation bladeRF 1 devices or the Nios II processor used on all bladeRF devices.
[intel]: https://www.altera.com/ (Altera, part of the Intel Programmable Solutions Group)
[quartus]: https://dl.altera.com/17.1/?edition=lite (Quartus Prime Lite Edition v17.1)
[cive]: https://www.altera.com/products/fpga/cyclone-series/cyclone-iv/overview.html
[quartus]: https://www.intel.com/content/www/us/en/software-kit/660904/intel-quartus-prime-lite-edition-design-software-version-20-1-1-for-linux.html (Quartus Prime Lite Edition v20.1.1)
[cve]: https://www.intel.com/content/www/us/en/products/details/fpga/cyclone/v.html
[cive]: https://www.intel.com/content/www/us/en/products/details/fpga/cyclone/iv.html
## HDL Structure ##
Since the FPGA is connected and soldered down to the board, it makes sense to have a single top level which defines where the pins go, their IO levels and their general directionality. We use a single `bladerf.vhd` top level to define a VHDL entity called `bladerf` that defines these pins.
@ -41,21 +42,25 @@ This technique can be seen with the currently supported architectures:
## Building the Project ##
The Quartus Prime build tools supports TCL as a scripting language which we utilize to not only create the project file, but build the system without requiring the need of the GUI. Currently, the `build_bladerf.sh` performs some environment checks, builds the NIOS BSP and software, and then kicks off TCL scripts to build the FPGA image.
To support multiple versions of Quartus Prime on the same machine and to ensure the environment is appropriately setup, please use the `nios2_command_shell.sh` script to get into an appropriate Quartus Prime environment. Note that this shell script is usually located in the `nios2eds` directory of your Quartus Prime install directory. Also note that this is the preferred method regardless of using Windows or Linux to build. If you're using pybombs, make sure you haven't run `setup_env.sh`, as it prevents `nios2_command_shell.sh` from working properly.
To support multiple versions of Quartus Prime on the same machine and to ensure the environment is appropriately setup, please run the `nios2_command_shell.sh` script to get into an appropriate Quartus Prime environment. Note that this shell script is usually located in the `nios2eds` directory of your Quartus Prime install directory (e.g. `~/intelFPGA_lite/20.1/nios2eds/nios2_command_shell.sh`). Also note that this is the preferred method regardless of using Windows or Linux to build. If you're using pybombs, make sure you haven't run `setup_env.sh`, as it prevents `nios2_command_shell.sh` from working properly.
1. Take note of which Cyclone device you have. (The EP4CE40 is 40 kLE, and the EP4CE115 is 115 kLE.) You'll need this size below.
1. Take note of your bladeRF model (bladeRF micro, bladeRF classic) and its corresponding FPGA size (x40, xA9, etc). You'll need this info below.
2. Enter the `quartus` directory
3. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -h` to view the usage for the build script. Note the size and revision options. Also note any items you'll need to add to your PATH before continuing.
4. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -s <size> -r <revision>`, with the relevant size for your bladeRF, and the desired revision. This will create the NIOS system and software associated with the FPGA build needed by the internal RAM for execution.
3. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -h` to view the usage for the build script. Note the board, size, and revision options. Also note any items you'll need to add to your PATH before continuing.
4. Execute, from inside an appropriate NIOS II command shell, `./build_bladerf.sh -b <board> -s <size> -r <revision>`, with your bladeRF board model, the relevant size for your bladeRF, and the desired revision. This will create the NIOS system and software associated with the FPGA build needed by the internal RAM for execution.
5. The output of the build will be stored in a directory named in the form, `<revision>x<size>-<build time>`. This directory will contain the bitstream, summaries, and reports.
Note that there will be a _lot_ of information displayed from notes to critical warnings. Some of these are benign and others are, in fact, critical.
## Adding Signal Tap ##
For advanced users who want to use Signal Tap internal logic analyzer in their design, the `build.tcl` file can be passed a `-stp` flag which will add the Signal Tap file to the project before building it:
Ex: Build the bladeRF 2.0 micro xA4 with the default `hosted` architecture
```
quartus_sh -t ../build.tcl -rev hosted -size 115 -stp ../signaltap/debug_rx.stp
./build_bladerf.sh -b bladeRF-micro -s A4 -r hosted
```
## Adding Signal Tap ##
For advanced users who want to use Signal Tap internal logic analyzer in their design, use the `-a` flag to add the Signal Tap file to the project before building it:
```
./build_bladerf.sh -b bladeRF-micro -s A4 -r hosted -a ../signaltap/debug_rx.stp
```
Note that to use Signal Tap with the Quartus Prime Lite Edition software, the TalkBack feature must be enabled. The build script tries to 'fake' this out by setting the TalkBack feature to be on, compiling the project, then turning it off immediately afterward. If this behavior is not desired, don't try to add a Signal Tap file to the project.

View file

@ -184,7 +184,7 @@ begin
count := 0 ;
irq <= '0' ;
elsif( rising_edge(clock) ) then
if( sin_we = '1' ) then
if( sin_we = '1' and state /= WAIT_FOR_READ ) then
reg_request(count*8+7 downto count*8) <= sin_data ;
end if ;
case state is

View file

@ -75,6 +75,7 @@ architecture simple of fifo_reader is
constant DMA_BUF_SIZE_SS : natural := GPIF_BUF_SIZE_SS;
constant DMA_BUF_SIZE_HS : natural := GPIF_BUF_SIZE_HS;
constant MAX_TIMESTAMP : unsigned(timestamp'high downto timestamp'low) := (others => '1');
signal dma_buf_size : natural range DMA_BUF_SIZE_HS to DMA_BUF_SIZE_SS := DMA_BUF_SIZE_SS;
signal underflow_detected : std_logic := '0';
@ -146,7 +147,7 @@ architecture simple of fifo_reader is
-- Highly packed mode signals
packed_buffer : std_logic_vector(47 downto 0);
packed_cycle : integer range 0 to 3;
packed_cycle : integer range 0 to 4;
end record;
constant FIFO_FSM_RESET_VALUE : fifo_fsm_t := (
@ -211,7 +212,9 @@ begin
-- Meta FIFO combinatorial process
meta_fsm_comb : process( all )
variable meta_time : unsigned(63 downto 0);
constant META_NOW : unsigned(63 downto 0) := (others => '1');
variable meta_time : unsigned(63 downto 0);
variable packet_len : integer;
begin
meta_future <= meta_current;
@ -241,7 +244,7 @@ begin
(packet_en = '1' and packet_ready = '1') ) ) then
meta_future.meta_read <= '1';
meta_future.state <= META_WAIT;
if( packet_en = '1' or meta_current.meta_p_time_r /= timestamp ) then
if( packet_en = '1' or (meta_current.meta_p_time_r > timestamp and meta_current.meta_p_time_r /= META_NOW) ) then
meta_future.meta_time_go <= '0';
else
meta_future.meta_time_go <= '1';
@ -254,12 +257,13 @@ begin
when META_WAIT =>
if( packet_en = '1' ) then
meta_future.dma_downcount <= to_integer(unsigned(meta_current.meta_cache(15 downto 0)));
packet_len := to_integer(unsigned(meta_current.meta_cache(15 downto 0)));
meta_future.dma_downcount <= packet_len - 1;
else
meta_future.dma_downcount <= dma_buf_size - 4;
end if;
if( (timestamp >= meta_current.meta_p_time or meta_current.meta_p_time + 1 = 0)
if( (timestamp >= meta_current.meta_p_time or meta_current.meta_p_time = MAX_TIMESTAMP)
and ( packet_en = '0' or ( packet_en = '1' and packet_ready = '1' ) ) ) then
meta_future.meta_time_go <= '1';
meta_future.state <= META_DOWNCOUNT;
@ -274,11 +278,11 @@ begin
if( packet_en = '0' ) then
if( fifo_current.fifo_read = '1') then
meta_future.dma_downcount <= meta_current.dma_downcount - NUM_STREAMS;
end if;
if( meta_current.dma_downcount <= NUM_STREAMS ) then
-- Look for 2 because of the 2 cycles passing
-- through META_LOAD and META_WAIT after this.
meta_future.state <= META_LOAD;
if( meta_current.dma_downcount <= 2 ) then
-- Look for 2 because of the 2 cycles passing
-- through META_LOAD and META_WAIT after this.
meta_future.state <= META_LOAD;
end if;
end if;
else
if( fifo_current.packet_control.data_valid = '1') then
@ -646,9 +650,10 @@ begin
fifo_future.fifo_read <= read_req and fifo_current.eight_bit_sample_sel;
fifo_future.eight_bit_sample_sel <= not fifo_current.eight_bit_sample_sel;
elsif (highly_packed_mode_en = '1' and NUM_STREAMS = 2) then
fifo_future.packed_cycle <= (fifo_current.packed_cycle + 1) mod 4;
fifo_future.packed_cycle <= (fifo_current.packed_cycle + 1);
fifo_future.packed_buffer <= fifo_data(fifo_data'high downto fifo_data'high-47);
if read_req = '1' and fifo_current.packed_cycle = 3 then
if fifo_current.packed_cycle = 3 then
fifo_future.packed_cycle <= 0;
fifo_future.fifo_read <= '0';
end if;
end if;

View file

@ -33,6 +33,10 @@ if { [info exists platform_revision] == 0 } {
puts "platform revision: ${platform_revision}"
}
# RAM base address is equal to the RAM size
set ram_base_addr "0x[format %08x $ram_size]"
puts "RAM size: ${ram_size}, base address: ${ram_base_addr}"
# Instances and instance parameters
# (disabled instances are intentionally culled)
add_instance axi_ad9361_0 axi_ad9361 1.0
@ -496,7 +500,7 @@ set_connection_parameter_value nios2.data_master/peripheral_spi.spi_control_port
add_connection nios2.data_master ram.s1
set_connection_parameter_value nios2.data_master/ram.s1 arbitrationPriority {1}
set_connection_parameter_value nios2.data_master/ram.s1 baseAddress {0x00020000}
set_connection_parameter_value nios2.data_master/ram.s1 baseAddress ${ram_base_addr}
set_connection_parameter_value nios2.data_master/ram.s1 defaultConnection {0}
add_connection nios2.data_master rffe_spi.spi_control_port
@ -556,7 +560,7 @@ set_connection_parameter_value nios2.instruction_master/nios2.debug_mem_slave de
add_connection nios2.instruction_master ram.s1
set_connection_parameter_value nios2.instruction_master/ram.s1 arbitrationPriority {1}
set_connection_parameter_value nios2.instruction_master/ram.s1 baseAddress {0x00020000}
set_connection_parameter_value nios2.instruction_master/ram.s1 baseAddress ${ram_base_addr}
set_connection_parameter_value nios2.instruction_master/ram.s1 defaultConnection {0}
add_connection nios2.irq command_uart.interrupt

View file

@ -36,7 +36,9 @@ LIBAD936X_DIR := ../../../../fpga/ip/analogdevicesinc/no_OS
INC_DIRS += $(LIBAD936X_BUILDDIR) \
../$(LIBAD936X_DIR)/include \
../../../../../../host/common/include
../../../../../../host/common/include \
../../../../../../host/build/common/thirdparty/ad936x/ \
../../../../../../thirdparty/analogdevicesinc/no-OS_local/platform_bladerf2/
LIB_DIRS += $(LIBAD936X_BUILDDIR)
LDDEPS += $(LIBAD936X_BUILDDIR)/libad936x.a
@ -80,3 +82,6 @@ $(LIBAD936X_BUILDDIR)/Makefile: $(LIBAD936X_MAKE_DEP)
$(LIBAD936X_BUILDDIR)/libad936x.a: $(LIBAD936X_BUILD_DEP)
@$(ECHO) Info: Building libad936x
@$(MAKE) --no-print-directory -C $(LIBAD936X_BUILDDIR) ad936x
# Ensure libad936x is built before the application objects that depend on its headers
$(APP_OBJS): $(LIBAD936X_BUILDDIR)/libad936x.a

View file

@ -38,7 +38,8 @@ LIBAD936X_DIR := ../../../../fpga/ip/analogdevicesinc/no_OS
INC_DIRS += $(LIBAD936X_BUILDDIR) \
../$(LIBAD936X_DIR)/include \
../../../../../../host/common/include
../../../../../../host/common/include \
../../../../../../thirdparty/analogdevicesinc/no-OS_local/platform_bladerf2/
LIB_DIRS += $(LIBAD936X_BUILDDIR)
LDDEPS += $(LIBAD936X_BUILDDIR)/libad936x.a

View file

@ -700,7 +700,7 @@ begin
-- Change the iq values based on blocks received
-- See tx_sample_stream's encoding scheme in fx3_model.vhd
if( iq_value(7 downto 0) = tx_packet_len ) then
if( iq_value(7 downto 0) = tx_packet_len - 1 ) then
iq_value := x"0000";
if( current_block_count <= BLOCKS_PER_ITERATION ) then
current_block_count := current_block_count + 1;

View file

@ -108,7 +108,20 @@ entity nios_system is
tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0); -- out_port
xb_gpio_in_port : in std_logic_vector(31 downto 0) := (others => 'X'); -- in_port
xb_gpio_out_port : out std_logic_vector(31 downto 0); -- out_port
xb_gpio_dir_export : out std_logic_vector(31 downto 0) -- export
xb_gpio_dir_export : out std_logic_vector(31 downto 0); -- export
arbiter_request : in std_logic_vector(1 downto 0) := (others => 'X'); -- request
arbiter_granted : out std_logic_vector(1 downto 0); -- granted
arbiter_ack : in std_logic_vector(1 downto 0) := (others => 'X'); -- ack
wbm_wb_clk_i : in std_logic := 'X'; -- clk_i
wbm_wb_rst_i : in std_logic := 'X'; -- rst_i
wbm_wb_adr_o : out std_logic_vector(31 downto 0); -- adr_o
wbm_wb_dat_o : out std_logic_vector(31 downto 0); -- dat_o
wbm_wb_dat_i : in std_logic_vector(31 downto 0) := (others => 'X'); -- dat_i
wbm_wb_we_o : out std_logic; -- we_o
wbm_wb_sel_o : out std_logic; -- sel_o
wbm_wb_stb_o : out std_logic; -- stb_o
wbm_wb_ack_i : in std_logic := 'X'; -- ack_i
wbm_wb_cyc_o : out std_logic -- cyc_o
);
end entity ;
@ -142,5 +155,14 @@ begin
xb_gpio_out_port <= (others =>'0') ;
xb_gpio_dir_export <= (others =>'0') ;
arbiter_granted <= (others => '0');
wbm_wb_adr_o <= (others => '0');
wbm_wb_dat_o <= (others => '0');
wbm_wb_we_o <= '0';
wbm_wb_sel_o <= '0';
wbm_wb_stb_o <= '0';
wbm_wb_cyc_o <= '0';
end architecture ;

View file

@ -105,8 +105,8 @@ set_output_delay -clock [get_clocks altera_reserved_tck] 20 [get_ports altera_re
# Exceptions
# The dcfifo which goes from the C4 TX domain to the PCLK domain seems to have an issue with the clear signal. It isn't generally a issue so ignore it?
set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe12a[0]}
set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe13a[0]}
set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe*a[0]}
set_false_path -from {reset_synchronizer:U_tx_reset|sync} -to {tx_*fifo:U_tx_*_fifo|common_dcfifo:U_common_dcfifo|dcfifo*:auto_generated|dffpipe_3dc:wraclr|dffe*a[0]}
# False path between hold_time and compare_time due to the way the FSM is setup
set_false_path -from {*x_tamer|hold_time[*]} -to {*x_tamer|compare_time[*]}

View file

@ -1,17 +1,17 @@
source ../../../ip/nuand/nuand.do
compile_nuand ../../../ip/nuand
compile_nuand ../../../ip/nuand bladerf
vcom -work nuand -2008 ../../../ip/altera/pll/pll.vhd
vcom -work nuand -2008 ../../../ip/altera/fx3_pll/fx3_pll.vhd
vcom -work nuand -2008 ../../../ip/altera/rx_fifo/rx_fifo.vhd
vcom -work nuand -2008 ../../../ip/altera/tx_fifo/tx_fifo.vhd
vcom -work nuand -2008 ../../../ip/altera/tx_meta_fifo/tx_meta_fifo.vhd
vcom -work nuand -2008 ../../../ip/altera/rx_meta_fifo/rx_meta_fifo.vhd
vcom -work nuand -2008 ../vhdl/tb/nios_system.vhd
vcom -work nuand -2008 ../vhdl/fx3_gpif_p.vhd
vcom -work nuand -2008 ../vhdl/fx3_gpif.vhd
vcom -work nuand -2008 ../../common/bladerf/vhdl/fx3_gpif_p.vhd
vcom -work nuand -2008 ../../common/bladerf/vhdl/fx3_gpif.vhd
vcom -work nuand -2008 ../../../ip/nuand/lms6_spi_controller/vhdl/lms6_spi_controller.vhd
vcom -work nuand -2008 ../../../ip/nuand/synthesis/lms6002d/vhdl/bladerf_agc_lms_drv.vhd
vcom -work nuand -2008 ../../../ip/nuand/synthesis/lms6002d/vhdl/bladerf_agc.vhd
vcom -work nuand -2008 ../vhdl/bladerf.vhd
vcom -work nuand -2008 ../vhdl/bladerf_p.vhd

View file

@ -7,8 +7,8 @@
#define FPGA_VERSION_ID 0x7777
#define FPGA_VERSION_MAJOR 0
#define FPGA_VERSION_MINOR 15
#define FPGA_VERSION_PATCH 3
#define FPGA_VERSION_MINOR 16
#define FPGA_VERSION_PATCH 0
#define FPGA_VERSION ((uint32_t)( FPGA_VERSION_MAJOR | \
(FPGA_VERSION_MINOR << 8) | \
(FPGA_VERSION_PATCH << 16) ) )

View file

@ -46,7 +46,16 @@ entity nios_system is
tx_trigger_ctl_in_port : in std_logic_vector(7 downto 0);
tx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
rx_trigger_ctl_in_port : in std_logic_vector(7 downto 0);
rx_trigger_ctl_out_port : out std_logic_vector(7 downto 0)
rx_trigger_ctl_out_port : out std_logic_vector(7 downto 0);
arbiter_request : in std_logic_vector(1 downto 0);
arbiter_granted : out std_logic_vector(1 downto 0);
arbiter_ack : in std_logic_vector(1 downto 0);
agc_dc_i_max_export : out std_logic_vector(15 downto 0);
agc_dc_q_max_export : out std_logic_vector(15 downto 0);
agc_dc_i_mid_export : out std_logic_vector(15 downto 0);
agc_dc_q_mid_export : out std_logic_vector(15 downto 0);
agc_dc_i_min_export : out std_logic_vector(15 downto 0);
agc_dc_q_min_export : out std_logic_vector(15 downto 0)
);
end entity ;
@ -83,5 +92,17 @@ begin
xb_gpio_out_port <= (others =>'0') ;
xb_gpio_dir_export <= (others =>'0') ;
tx_trigger_ctl_out_port <= (others => '0');
rx_trigger_ctl_out_port <= (others => '0');
arbiter_granted <= (others => '0');
agc_dc_i_max_export <= (others => '0');
agc_dc_q_max_export <= (others => '0');
agc_dc_i_mid_export <= (others => '0');
agc_dc_q_mid_export <= (others => '0');
agc_dc_i_min_export <= (others => '0');
agc_dc_q_min_export <= (others => '0');
end architecture ;

View file

@ -146,7 +146,7 @@ Command-Line Debugging with GDB
- `$QUARTUS_INSTALL_DIR/nios2eds/nios2_command_shell.sh`
- cd into `$BLADERF_DIR/hdl/quartus/work/<platform>-<size>-<rev>/bladeRF_nios`
- Start the Nios gdb client:
- `nios2-elf-gdb -ex "target remote localhost:8888" bladeRF_nios.elf`
- `make WORKDIR=work/<platform>-<size>-<rev> elf-gdb`
- The Nios processor will now be in a paused state. This lets us setup breakpoints and whatnot as needed for debug. When ready to begin the debug process, issue the `continue` command. This will unpause the Nios.
- If a breakpoint is hit, gdb will pause the Nios again until you issue another `continue` command. This may cause a timeout and break the user application. Breakpoints can have [commands associated with them](https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_34.html), so when one is hit, gdb can immediately print a value and continue. The print operation is slow enough that if more than a few characters are printed, it will trigger a timeout in libbladeRF. Refer to the *Debugging Tips* section for how to increase the timeout.

View file

@ -897,6 +897,8 @@ endif # QSYS == 1
@$(ECHO) " Run targets:"
@$(ECHO) " download-elf - Download and run your elf executable"
@$(ECHO) " program-flash - Program flash contents to the board"
@$(ECHO) " gdb-server - Start GDB server on port 8888"
@$(ECHO) " elf-gdb - Connect GDB to running server and load symbols"
# Handy rule to skip making libraries and just make application.
.PHONY : app
@ -1004,7 +1006,7 @@ download-elf : $(ELF)
$(ECHO) Downloading $(ELF) not supported; \
else \
$(ECHO) Info: Downloading $(ELF); \
$(DOWNLOAD) --go --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \
$(DOWNLOAD) --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \
fi
# Delete the target of a rule if it has changed and its commands exit
@ -1111,3 +1113,13 @@ $(OBJDUMP_NAME) : $(ELF)
.PHONY: print-elf-name
print-elf-name:
@$(ECHO) $(ELF)
.PHONY : elf-gdb
elf-gdb : $(ELF)
@$(ECHO) Info: Starting GDB for $(ELF)
nios2-elf-gdb -ex "target remote localhost:8888" $(ELF)
.PHONY : gdb-server
gdb-server:
@$(ECHO) Info: Starting GDB server on port 8888
nios2-gdb-server --tcpport 8888 --tcppersist

View file

@ -179,8 +179,8 @@ architecture sample_shuffler of fx3_gpif is
signal current, future : fsm_t := FSM_RESET_VALUE;
signal can_rx, should_rx : boolean;
signal can_tx, should_tx : boolean;
signal can_rx : boolean;
signal can_tx : boolean;
signal rx_fifo_enough : boolean;
signal tx_fifo_enough : boolean;
signal rx_fifo_critical : boolean;
@ -192,14 +192,10 @@ architecture sample_shuffler of fx3_gpif is
attribute preserve : boolean;
attribute preserve of can_rx : signal is true;
attribute preserve of can_tx : signal is true;
attribute preserve of should_rx : signal is true;
attribute preserve of should_tx : signal is true;
attribute keep : boolean;
attribute keep of can_rx : signal is true;
attribute keep of can_tx : signal is true;
attribute keep of should_rx : signal is true;
attribute keep of should_tx : signal is true;
-- acknowledge(dma_channel) returns a dma_handshake_t with all bits 0
-- except the bit corresponding to dma_channel
@ -337,22 +333,28 @@ begin
end if;
end process gpif_mux;
-- Arbitrate RX and TX requests
-- In the event the FX3 simultaneously requests RX and TX, we generally
-- prioritize the TX first; this helps avoid discontinuities on the TX
-- signal. However, if RX is about to overflow, we'll choose that.
can_and_should : process(pclk, reset)
variable rx_dma_req : boolean;
variable tx_dma_req : boolean;
variable rx_meta_ok : boolean;
begin
if (reset = '1') then
can_rx <= false;
can_tx <= false;
should_rx <= false;
should_tx <= false;
elsif (rising_edge(pclk)) then
can_rx <= dma_rx_enable = '1' and rx_fifo_enough and (dma_req.rx0 = '1' or dma_req.rx1 = '1');
can_tx <= dma_tx_enable = '1' and tx_fifo_enough and (dma_req.tx2 = '1' or dma_req.tx3 = '1');
should_rx <= can_rx and (not can_tx or rx_fifo_critical);
should_tx <= can_tx and not rx_fifo_critical;
rx_dma_req := dma_req.rx0 = '1' or dma_req.rx1 = '1';
rx_meta_ok := meta_enable = '1' nand rx_meta_fifo_empty = '1';
can_rx <= dma_rx_enable = '1' and
rx_fifo_enough and
rx_dma_req and
rx_meta_ok;
tx_dma_req := dma_req.tx2 = '1' or dma_req.tx3 = '1';
can_tx <= dma_tx_enable = '1' and
tx_fifo_enough and
tx_dma_req;
end if;
end process;
@ -408,21 +410,24 @@ begin
future.fini_downcount <= FINI_DOWNCOUNT_RESET;
future.finishing_rx <= '0';
-- Arbitrate RX and TX requests
-- In the event the FX3 simultaneously requests RX and TX, we generally
-- prioritize the TX first; this helps avoid discontinuities on the TX
-- signal. However, if RX is about to overflow, we'll choose that.
if (current.dma_idle = '1') then
if (should_rx and ( (rx_meta_fifo_empty = '0' and current.rx_meta_en = '1')
or (current.rx_meta_en = '0') ) ) then
-- There is an RX to perform (sending data to FX3).
future.dma_downcount <= gpif_buf_size-1;
if (can_rx and rx_fifo_critical) then
future.ack_downcount <= ACK_DOWNCOUNT_READ;
future.dma_downcount <= gpif_buf_size-1;
future.rx_current_dma <= RX0;
future.state <= SETUP_RD;
elsif (should_tx) then
-- There is a TX to perform (getting data from FX3).
elsif (can_tx) then
future.ack_downcount <= ACK_DOWNCOUNT_WRITE;
future.dma_downcount <= gpif_buf_size-1;
future.tx_current_dma <= TX3;
future.state <= SETUP_WR;
elsif (can_rx) then
future.ack_downcount <= ACK_DOWNCOUNT_READ;
future.rx_current_dma <= RX0;
future.state <= SETUP_RD;
end if;
end if;

View file

@ -3,6 +3,41 @@
# Build a bladeRF fpga image
################################################################################
# Ensure we're in the right directory and submodules are initialized
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# Initialize and update submodules if needed
echo "Checking and initializing submodules..."
cd "$PROJECT_ROOT"
if [ -f .gitmodules ]; then
# Initialize submodules if not already initialized
git submodule init
# Update submodules to ensure they're checked out
git submodule update
echo "Submodules initialized and updated."
fi
cd "$SCRIPT_DIR"
cleanup() {
# Prevent recursive cleanup calls
trap '' INT TERM HUP
echo "Cleaning up and terminating builds..."
if [ -n "${build_pids[*]}" ]; then
for pid in "${build_pids[@]}"; do
pkill -P $pid 2>/dev/null || true
done
fi
exit 1
}
# Set up trap to catch Ctrl+C and other termination signals
trap cleanup INT TERM HUP
function print_boards() {
echo "Supported boards:"
for i in ../fpga/platforms/*/build/platform.conf ; do
@ -33,6 +68,7 @@ function usage()
echo " -r <rev> Quartus project revision"
echo " -s <size> FPGA size"
echo " -a <stp> SignalTap STP file"
echo " -H Build all hosted configurations"
echo " -f Force SignalTap STP insertion by temporarily enabling"
echo " the TalkBack feature of Quartus (required for Web Edition)."
echo " The previous setting will be restored afterward."
@ -44,6 +80,7 @@ function usage()
echo " synth Synthesize the design"
echo " full (default) Fit the design and create programming files"
echo " -S <seed> Fitter seed setting (default: 1)"
echo " -D Output directory name won't contain the date"
echo " -h Show this text"
echo ""
@ -125,8 +162,9 @@ fi
nios_rev="Tiny"
flow="full"
seed="1"
omit_date=false
while getopts ":cb:r:s:a:fn:l:S:h" opt; do
while getopts ":cb:r:s:a:fn:l:S:DhH" opt; do
case $opt in
c)
clear_work_dir=1
@ -149,6 +187,10 @@ while getopts ":cb:r:s:a:fn:l:S:h" opt; do
stp=$(readlink -f $OPTARG)
;;
H)
build_hosted=1
;;
f)
echo "Forcing STP insertion"
force="-force"
@ -166,6 +208,10 @@ while getopts ":cb:r:s:a:fn:l:S:h" opt; do
seed=$OPTARG
;;
D)
omit_date=true
;;
h)
usage
exit 0
@ -183,6 +229,39 @@ while getopts ":cb:r:s:a:fn:l:S:h" opt; do
esac
done
if [ "$build_hosted" == "1" ]; then
mkdir -p build_logs
build_pids=()
echo "Starting parallel builds for all hosted configurations..."
for config in "bladeRF 40" "bladeRF 115" "bladeRF-micro A4" "bladeRF-micro A5" "bladeRF-micro A9"; do
read -r board size <<< "$config"
log_file="build_logs/$board-hosted-$size.log"
$0 -b "$board" -r hosted -s "$size" > "$log_file" 2>&1 &
build_pids+=($!)
echo " → $board $size (PID: ${build_pids[-1]})"
done
echo "Waiting for ${#build_pids[@]} builds to complete..."
# Monitor build processes
failed=0
for pid in "${build_pids[@]}"; do
if ! wait "$pid"; then
failed=1
fi
done
if [ "$failed" -ne 0 ]; then
echo "One or more builds failed. Check build_logs directory for details."
cleanup
exit 1
fi
echo "All hosted builds completed successfully!"
exit 0
fi
if [ "$board" == "" ]; then
echo -e "\nError: board (-b) is required\n" >&2
print_boards
@ -446,7 +525,11 @@ if [[ ${flow} == "full" ]]; then
BUILD_TIME_DONE=$(date -d"$BUILD_TIME_DONE" '+%F_%H.%M.%S')
BUILD_NAME="$rev"x"$size"
BUILD_OUTPUT_DIR="$BUILD_NAME"-"$BUILD_TIME_DONE"
if [ "$omit_date" = false ]; then
BUILD_OUTPUT_DIR="$BUILD_NAME"-"$BUILD_TIME_DONE"
else
BUILD_OUTPUT_DIR="$BUILD_NAME"
fi
RBF=$BUILD_NAME.rbf
mkdir -p "$BUILD_OUTPUT_DIR"

View file

@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(bladeRF C)
################################################################################
# Project configuration
################################################################################
add_compile_definitions(NUAND_MODIFICATIONS=1)
# All build output lands in this directory:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output)
@ -230,29 +231,6 @@ add_custom_target(uninstall
# Windows-only, Post build: Copy libraries to our build output directory
################################################################################
if(WIN32 AND NOT CMAKE_CROSSCOMPILING)
find_package(LibPThreadsWin32)
if(LIBPTHREADSWIN32_FOUND)
set(WIN_RUNTIME_ITEMS ${WIN_RUNTIME_ITEMS}
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/pthreads-win32/COPYING.LIB.txt"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/pthreadVC2.dll")
add_custom_command(
OUTPUT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/pthreads-win32/COPYING.LIB.txt"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${LIBPTHREADSWIN32_LIB_COPYING}"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/pthreads-win32/COPYING.LIB.txt"
COMMENT "Copying pthreads-win32 license to output directory..."
)
add_custom_command(
OUTPUT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/pthreadVC2.dll"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${LIBPTHREADSWIN32_DLL}"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/"
COMMENT "Copying pthreadVC2.dll to output directory..."
)
endif(LIBPTHREADSWIN32_FOUND)
if(LIBUSB_FOUND)
set(WIN_RUNTIME_ITEMS ${WIN_RUNTIME_ITEMS}
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/licenses/libusb/COPYING"

View file

@ -23,9 +23,6 @@ Windows users that wish to use a Cypress driver/library based libbladeRF backend
### CMake ###
[CMake][CMake.org] is used to build the items in this directory. \>= v2.8.5 is required, but the latest available version is recommended.
### pthreads-win32 - Windows-only ###
Windows users will need to get [pthreads-win32], and may (with newer Windows versions) need to build it from scratch.
## Build ##
### Linux and OSX ###
@ -63,7 +60,6 @@ This process was most recently validated on Windows 10 Enterprise with CMake 3.9
- If you run into any failures, check these items, then re-run Configure:
- LIBUSB_PATH (and ENABLE_BACKEND_LIBUSB) - for using libusb
- FX3_SDK_PATH (and ENABLE_BACKEND_CYAPI) - for using the Cypress driver
- LIBPTHREADSWIN32_PATH
- Adjust options as desired and re-run the "Configure" command as needed. Values in red are new, and should be reviewed before running "Configure" again to get the red out.
- Click the CMake GUI's "Generate" button.
- In the ```build``` directory, a Visual Studio solution will now exist. You can click "Open Project" to get there.
@ -71,21 +67,6 @@ This process was most recently validated on Windows 10 Enterprise with CMake 3.9
- Upon building the solution, build artifacts will be present in: ```build\output\<build type>```
- ```<build_type>``` may refer to Debug or Release, for example
#### pthreads-win32 ####
If you are using a newer version of Windows / Visual Studio and are getting ```error C0211: 'timespec': 'struct' type redefinition``` when trying to build bladeRF, you will need to rebuild pthreads-win32. The below process seems to work with pthreads-w32 2.9.1.
- Get full source tree from [pthreads-win32] website, and unpack someplace convenient
- In Visual Studio, open `pthreads-w32-2-9-1-release\pthreads.2\pthread.dsw` (one-way upgrade is OK)
- Right-click the solution, select "Retarget solution", hit OK.
- Change "Solution Configurations" dropdown to "Release" ("Debug" doesn't work, but that's OK)
- Edit pthread.h to add `#define HAVE_STRUCT_TIMESPEC` and `#define PTW32_ARCHx64` near the top, just below the include guard
- Build the solution
- Back over in the bladeRF CMake:
- File -> Delete Cache
- Redo the "Configure" dance as before
- Point `LIBPTHREADSWIN32_PATH` to the `pthreads-w32-2-9-1-release\pthreads.2` directory you were just working in
## CMake Options and Flags ##
Below is a list of useful and project-specific CMake options. Please see the [CMake documentation] for
@ -120,4 +101,3 @@ more information.
[CMake documentation]: http://www.cmake.org/cmake/help/documentation.html (Cmake documentation)
[Cypress FX3 SDK]: http://www.cypress.com/?rID=57990 (Cypress FX3 SDK)
[redhat144967]: https://bugzilla.redhat.com/show_bug.cgi?id=144967 (Red Hat Bugzilla - Bug 144967)
[pthreads-win32]: https://sourceware.org/pthreads-win32/ (POSIX Threads for Win32)

View file

@ -1,113 +0,0 @@
# This is file is based off of the FindLibUSB.cmake file written by Hendrik Sattler,
# from the OpenOBEX project (licensed GPLv2/LGPL). (If this is not correct,
# please contact us so we can attribute the author appropriately.)
#
# https://github.com/zuckschwerdt/openobex/blob/master/CMakeModules/FindLibUSB.cmake
# http://dev.zuckschwerdt.org/openobex/
#
# Find pthreads-win32
#
# This requires the LIBPTHREADSWIN32_PATH variable to be set to the path to the
# a pthreads-win32 release, such as the Pre-built.2 directory from the 2.9.1 release:
# ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
#
# The following standard variables get defined:
# LIBPTHREADSWIN32_FOUND: true if LibUSB was found
# LIBPTHREADSWIN32_HEADER_FILE: the location of the C header file
# LIBPTHREADSWIN32_INCLUDE_DIRS: the directories that contain headers
# LIBPTHREADSWIN32_LIBRARIES: the library files
# LIBPTHREADSWIN32_LIB_COPYING: the license associated with the library
# LIBPTHREADSWIN32_DLL: the pthreadVC2.dll file
if(DEFINED __INCLUDED_BLADERF_FINDLIBPTHREADSWIN32_CMAKE)
return()
endif()
set(__INCLUDED_BLADERF_FINDLIBPTHREADSWIN32_CMAKE TRUE)
include ( CheckLibraryExists )
include ( CheckIncludeFile )
set(LIBPTHREADSWIN32_PATH
"C:/Program Files (x86)/pthreads-win32"
CACHE
PATH
"Path to win-pthreads files. (This is generally only needed for Windows users who downloaded binary distributions.)"
)
find_file ( LIBPTHREADSWIN32_HEADER_FILE
NAMES
pthread.h
PATHS
${LIBPTHREADSWIN32_PATH}
PATH_SUFFIXES
include include
)
mark_as_advanced ( LIBPTHREADSWIN32_HEADER_FILE )
get_filename_component ( LIBPTHREADSWIN32_INCLUDE_DIRS "${LIBPTHREADSWIN32_HEADER_FILE}" PATH )
if ( WIN32 )
if ( MSVC )
if ( CMAKE_CL_64 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x64 )
else ( CMAKE_CL_64 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x86 )
endif ( CMAKE_CL_64 )
elseif ( CMAKE_COMPILER_IS_GNUCC )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x64 )
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX x86 )
endif ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
endif ( MSVC )
find_library ( PTHREAD_LIBRARY
NAMES
pthreadVC2
PATHS
${LIBPTHREADSWIN32_PATH}
PATH_SUFFIXES
lib/${LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX}
)
mark_as_advanced ( PTHREAD_LIBRARY )
if ( PTHREAD_LIBRARY )
set ( LIBPTHREADSWIN32_LIBRARIES ${PTHREAD_LIBRARY} )
endif ( PTHREAD_LIBRARY )
find_file ( PTHREAD_DLL
NAMES
pthreadVC2.dll
PATHS
${LIBPTHREADSWIN32_PATH}
PATH_SUFFIXES
dll/${LIBPTHREADSWIN32_LIBRARY_PATH_SUFFIX}
.
)
mark_as_advanced ( PTHREAD_DLL )
if ( PTHREAD_DLL )
set ( LIBPTHREADSWIN32_DLL ${PTHREAD_DLL} )
endif ( PTHREAD_DLL )
else ( WIN32 )
message(FATAL_ERROR "This file only supports Windows")
endif ( WIN32 )
set ( LIBPTHREADSWIN32_LIB_COPYING
"${LIBPTHREADSWIN32_PATH}/COPYING.LIB" )
if ( NOT EXISTS ${LIBPTHREADSWIN32_LIB_COPYING} )
message(FATAL_ERROR "Unable to find pthread-win32 COPYING.LIB file")
endif ()
if ( LIBPTHREADSWIN32_INCLUDE_DIRS AND LIBPTHREADSWIN32_LIBRARIES AND LIBPTHREADSWIN32_DLL )
set ( LIBPTHREADSWIN32_FOUND true )
endif ( LIBPTHREADSWIN32_INCLUDE_DIRS AND LIBPTHREADSWIN32_LIBRARIES AND LIBPTHREADSWIN32_DLL )
if ( LIBPTHREADSWIN32_FOUND )
set ( CMAKE_REQUIRED_INCLUDES "${LIBPTHREADSWIN32_INCLUDE_DIRS}" )
check_include_file ( "{LIBPTHREADSWIN32_HEADER_FILE}" LIBPTHREADSWIN32_FOUND )
endif ( LIBPTHREADSWIN32_FOUND )
if ( NOT LIBPTHREADSWIN32_FOUND )
message ( FATAL_ERROR "pthreads-win32 not found. If you're using a binary distribution, try setting -DLIBPTHREADSWIN32_PATH=<path_to_win_pthread_files>." )
endif ( NOT LIBPTHREADSWIN32_FOUND )

View file

@ -80,6 +80,11 @@ if(PKGCONFIG_LIBUSB_FOUND AND NOT LIBUSB_FOUND)
mark_as_advanced(${ibase}_LIBRARY)
endforeach(i)
# assume we're using vcpkg
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(LIBUSB_LIBRARY_PATH_SUFFIX bin)
endif()
else(PKGCONFIG_LIBUSB_FOUND)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
# The libusbx binary distribution contains several libs.

View file

@ -316,7 +316,9 @@
/*******************************************************************************
* Miscellaneous utility macros
******************************************************************************/
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(n) (sizeof(n) / sizeof(n[0]))
#endif
/**
* GCC 7+ warns on implicit fallthroughs in switch statements

View file

@ -39,7 +39,9 @@ extern "C" {
#endif // __MACH__
typedef int clockid_t;
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
int clock_gettime(clockid_t clk_id, struct timespec *tp);

View file

@ -32,11 +32,32 @@
/* Currently, only pthreads is supported. In the future, native windows threads
* may be used; one of the objectives of this file is to ease that transistion.
*/
#include <pthread.h>
#include "rel_assert.h"
#define MUTEX pthread_mutex_t
#if (defined(_WIN32) || defined(USE_NATIVE_THREADS)) && \
!defined(DO_NOT_USE_PTHREADS)
// Do not use pthreads on Windows
#undef USE_PTHREADS
#else
// Use pthreads on non-Windows platforms
#undef USE_PTHREADS
#define USE_PTHREADS
#endif
#ifdef USE_PTHREADS
/* Use pthreads */
#include <pthread.h>
#include <errno.h>
#include <time.h>
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
#define THREAD pthread_t
#define MUTEX pthread_mutex_t
#define COND pthread_cond_t
#ifdef ENABLE_LOCK_CHECKS
# define MUTEX_INIT(m) do { \
int status; \
@ -64,11 +85,103 @@
int status = pthread_mutex_destroy(m); \
assert(status == 0 && "Mutex destroy failure");\
} while (0)
#else
# define MUTEX_INIT(m) pthread_mutex_init(m, NULL)
# define MUTEX_LOCK(m) pthread_mutex_lock(m)
# define MUTEX_UNLOCK(m) pthread_mutex_unlock(m)
# define MUTEX_DESTROY(m) pthread_mutex_destroy(m)
#endif
#else /* ENABLE_LOCK_CHECKS */
#define MUTEX_INIT(m) pthread_mutex_init(m, NULL)
#define MUTEX_LOCK(m) pthread_mutex_lock(m)
#define MUTEX_UNLOCK(m) pthread_mutex_unlock(m)
#define MUTEX_DESTROY(m) pthread_mutex_destroy(m)
#endif /* ENABLE_LOCK_CHECKS */
# define THREAD_CREATE(x,y,z) pthread_create(x, NULL, y, z)
# define THREAD_SUCCESS 0
# define THREAD_TIMEOUT ETIMEDOUT
# define THREAD_CANCEL(m) pthread_cancel(m)
# define THREAD_JOIN(t, s) pthread_join(t, s)
# define THREAD_EXIT(s) pthread_exit(s)
# define COND_INIT(m) pthread_cond_init(m, NULL)
# define COND_SIGNAL(m) pthread_cond_signal(m)
// POSIX implementation as a function
static inline int posix_cond_timedwait(pthread_cond_t *c,
pthread_mutex_t *m,
unsigned int t)
{
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
ts.tv_sec += t / 1000;
ts.tv_nsec += (t % 1000) * 1000000;
if (ts.tv_nsec >= 1000000000) {
ts.tv_sec++;
ts.tv_nsec -= 1000000000;
}
return pthread_cond_timedwait(c, m, &ts) == ETIMEDOUT ? -1 : 0;
}
#define COND_TIMED_WAIT(c, m, t) posix_cond_timedwait(c, m, t)
#define COND_WAIT(c, m) pthread_cond_wait(c, m)
#else /* USE_PTHREADS */
#include <windows.h>
#include <time.h>
/* Use C11 threads */
//#include <threads.h>
#define THREAD HANDLE // For thread handles
#define MUTEX CRITICAL_SECTION // For mutexes
#define COND CONDITION_VARIABLE // For condition variables
#ifdef ENABLE_LOCK_CHECKS
# define MUTEX_INIT(m) do { \
int status; \
status = mtx_init(m, mtx_plain | mtx_recursive); \
assert(status == thrd_success && "Mutex init failure"); \
} while (0)
# define MUTEX_LOCK(m) do { \
int status = mtx_lock(m); \
assert(status == thrd_success && "Mutex lock failure");\
} while (0)
# define MUTEX_UNLOCK(m) do { \
int status = mtx_unlock(m); \
assert(status == thrd_success && "Mutex unlock failure");\
} while (0)
# define MUTEX_DESTROY(m) do { \
mtx_destroy(m); \
} while (0)
#else /* ENABLE_LOCK_CHECKS */
#define MUTEX_INIT(m) InitializeCriticalSection(m)
#define MUTEX_LOCK(m) EnterCriticalSection(m)
#define MUTEX_UNLOCK(m) LeaveCriticalSection(m)
#define MUTEX_DESTROY(m) DeleteCriticalSection(m)
#endif /* ENABLE_LOCK_CHECKS */
# define THREAD_CREATE(handle, func, arg) \
((*(handle) = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)(func), \
(LPVOID)(arg), 0, NULL)) == NULL ? GetLastError() : 0)
# define THREAD_SUCCESS 0
# define THREAD_TIMEOUT WAIT_TIMEOUT
# define THREAD_CANCEL(m) TerminateThread(m, 0)
# define THREAD_JOIN(t, s) WaitForSingleObject(t, INFINITE)
# define THREAD_EXIT(s) ExitThread(s)
# define COND_INIT(m) (InitializeConditionVariable(m), 0)
# define COND_SIGNAL(m) WakeConditionVariable(m)
# define COND_TIMED_WAIT(c, m, t) \
(SleepConditionVariableCS(c, m, t) ? 0 : GetLastError())
# define COND_WAIT(c, m) (!SleepConditionVariableCS(c, m, INFINITE))
#endif /* USE_PTHREADS */
#endif

View file

@ -25,7 +25,7 @@
#ifndef WIN_CLOCK_GETTIME_H_
#define WIN_CLOCK_GETTIME_H_
#include <pthread.h>
#include "thread.h"
#ifdef __cplusplus
extern "C" {
@ -36,7 +36,9 @@ extern "C" {
#endif
typedef int clockid_t;
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
int clock_gettime(clockid_t clk_id, struct timespec *tp);

View file

@ -25,7 +25,7 @@
#ifndef WIN_GETTIMEOFDAY_H_
#define WIN_GETTIMEOFDAY_H_
#include <pthread.h>
#include "thread.h"
#ifdef __cplusplus
extern "C" {

View file

@ -25,7 +25,7 @@
#ifndef WIN_NANOSLEEP_H_
#define WIN_NANOSLEEP_H_
#include <pthread.h>
#include "thread.h"
#ifdef __cplusplus
extern "C" {

View file

@ -48,9 +48,10 @@
#endif
#include <Windows.h>
#include <time.h>
#include <stdint.h>
#include "host_config.h"
#include "pthread.h"
#include "thread.h"
#ifdef __cplusplus
extern "C" {

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(test_dc_calibration C)
set(INCLUDES

View file

@ -94,16 +94,7 @@ target_include_directories(ad936x PUBLIC
if(MSVC)
add_definitions(-DHAVE_STRUCT_TIMESPEC)
target_include_directories(ad936x PUBLIC ${MSVC_C99_INCLUDES})
find_package(LibPThreadsWin32 REQUIRED)
if(LIBPTHREADSWIN32_FOUND)
set(HAVE_THREADS true)
target_include_directories(ad936x PUBLIC ${LIBPTHREADSWIN32_INCLUDE_DIRS})
set(LIBAD936X_LIBS
${LIBAD936X_LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
else()
set(HAVE_THREADS false)
endif()
set(HAVE_THREADS true)
else(MSVC)
find_package(Threads REQUIRED)
if(Threads_FOUND)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
add_subdirectory(libbladeRF)
# Conditionally add the test directory

View file

@ -5,6 +5,128 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/Nuand/bladeRF
================================================================================
v2.6.0 (2025-05-06)
--------------------------------
This version of libbladeRF is intended for use with:
FX3 Firmware v2.6.0
FPGA v0.16.0
New Features:
* Added SC16_Q11 packed sample format support, improving sample efficiency
* Increased FX3 GPIF buffer sizes, significantly boosting USB throughput (~356MB/s)
* Implemented dynamic Nios base address assignment based on RAM size
* Added parallel build support for hosted FPGA variants (40, 115, A4, A5, A9)
* Enabled elf-gdb and gdb-server support for improved FPGA debugging capability
* Added git revision information to FPGA build outputs
* bladeRF 2.0: Added support for gain calibration loading, enabling, and management
* bladeRF 2.0: Introduced bladeRF-power CLI tool for managing gain calibration
* bladeRF 2.0: Added bladerf_get_gain_target function for gain management
* bladeRF 2.0: Added bladerf_format_to_string API call
* bladeRF 2.0: Added bladerf_image_print_metadata API to display image metadata
* bladeRF 2.0: Improved compatibility checking between FPGA and FX3 firmware GPIF buffers
Improvements:
* libbladeRF now compiles and runs under MinGW and MSVC on Windows platforms
* Replaced libpthreadswin32 dependency with native libbladeRF threading macros
* Improved error handling and reporting for out-of-range frequency and sample rate settings
* Added detailed logging for USB transfer and Nios access timeouts
* Updated Doxygen to v1.9.8, adding support for light/dark modes and modernized configuration
* Improved GPIF buffer alignment handling for larger FX3 buffer sizes
* Added CMake find_package() support for easier integration into external projects
* Streamlined internal error checking macros, simplifying codebase
* Enhanced sync_rx_meta example with additional argument parsing and MIMO support
* Improved FPGA simulations for bladeRF 1.0 and bladeRF 2.0 micro
Bug Fixes:
* Fixed delayed sample and off-by-one timestamp issues on bladeRF 1.0
* Corrected TX meta sample gap issue when timestamp set to META_NOW
* Resolved corrupted UART buffer in command_uart component
* Fixed TX deadlock scenarios by refactoring RX/TX DMA prioritization
* Addressed SC16_Q11 packed RX discontinuity issue on overflow condition
* Fixed false timing paths and resolved multiple timing violations
* Fixed calibration load check in bladerf_get_gain_calibration
* Corrected RX meta packet timestamp and flags assignment
* Fixed sync TX initialization bug
Miscellaneous:
* Updated API documentation to reflect larger GPIF buffer sizes
* Improved FX3 SDK setup instructions in README
* Minor typo and documentation corrections throughout the codebase
v2.5.0 (2023-02-13)
--------------------------------
This version of libbladeRF is intended for use with:
FX3 Firmware v2.4.0
FPGA v0.15.0
Changes:
* Added 8-bit SC8_Q11 sample mode support for bladeRF 2.0 micro
* Added oversampling (OC) mode configuration to libbladeRF
* Extended TX bandwidth limit with oversampling enabled
* Improved compatibility checks and guards for sample rate and gain settings
* Fixed mutex locking bug during stream configuration
* Renamed bladerf_set_feature() to bladerf_enable_feature()
* Expanded help menus and command abbreviation support in bladeRF-cli
* Various minor fixes and cleanups
v2.4.1 (2021-10-04)
--------------------------------
This version of libbladeRF is intended for use with:
FX3 Firmware v2.4.0
FPGA v0.14.0
Changes:
* Added support for bladeRF 2.0 micro xA5
* Fixed packet mode enable issue on bladeRF 1.0
* Added Wishbone master control functions
* ConfigFile: Added keywords clock_out, clock_sel, refin_freq, clock_ref
* ConfigFile: Fixed parsing of vctcxo_tamer key
* Minor documentation updates and code cleanups
v2.4.0 (2020-12-23)
--------------------------------
This version of libbladeRF is intended for use with:
FX3 Firmware v2.4.0
FPGA v0.12.0
Changes:
* Added BLADERF_FORMAT_PACKET_META streaming format
* Added FPGA and firmware version checks for packet meta support
* Added metadata helper functions for packet streaming
* Introduced BLADERF_GPIO_PACKET_CORE_PRESENT definition
* Improved RFIC initialization parameter selection
* Added RFIC fast AGC settings
* Improved internal capability checking functions
* Updated version compatibility tables
* Minor fixes and code cleanups
v2.2.1 (2019-07-30)
--------------------------------
This version of libbladeRF is intended for use with:
FX3 Firmware v2.3.2
FPGA v0.11.0
Changes:
* bladerf2: Set tuning mode default to host-based
* bladerf2: Include FPGA v0.11.0 compatibility
* streaming: Fix timestamp advancement calculation
* bladerf1: Allow quicktune to control XB GPIO register
* bladerf2: Improve error handling on FIR filter failures
* flash: Add OTP read/write and locking functionality
* host: Update FPGA flash type definitions
* host: Fix formatting error in internal error message
* host: Fix type warnings in flash.c (Windows build)
v2.2.0 (2018-12-21)
--------------------------------

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF C)
@ -199,16 +199,7 @@ set(LIBBLADERF_INCLUDES
if(MSVC)
set(LIBBLADERF_INCLUDES ${LIBBLADERF_INCLUDES} ${MSVC_C99_INCLUDES})
find_package(LibPThreadsWin32 REQUIRED)
if(LIBPTHREADSWIN32_FOUND)
set(HAVE_THREADS true)
set(LIBBLADERF_INCLUDES
${LIBBLADERF_INCLUDES} ${LIBPTHREADSWIN32_INCLUDE_DIRS})
set(LIBBLADERF_LIBS
${LIBBLADERF_LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
else()
set(HAVE_THREADS false)
endif()
set(HAVE_THREADS true)
else(MSVC)
find_package(Threads REQUIRED)
if(Threads_FOUND)
@ -283,11 +274,6 @@ if(ENABLE_BACKEND_CYAPI)
set(LIBBLADERF_INCLUDES ${LIBBLADERF_INCLUDES} ${CYAPI_INCLUDE_DIRS})
endif(ENABLE_BACKEND_CYAPI)
if(MSVC)
set(LIBBLADERF_INCLUDES ${LIBBLADERF_INCLUDES}
${LIBPTHREADSWIN32_INCLUDE_DIRS})
endif()
if(ENABLE_LIBBLADERF_SYNC_LOG_VERBOSE AND ENABLE_LIBBLADERF_LOGGING)
add_definitions(-DENABLE_LIBBLADERF_SYNC_LOG_VERBOSE)
endif()
@ -432,7 +418,7 @@ if(MSVC)
endif()
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
cmake_policy(SET CMP0115 OLD)
cmake_policy(SET CMP0115 NEW)
endif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
add_library(libbladerf_shared SHARED ${LIBBLADERF_SOURCE})
@ -441,11 +427,9 @@ add_library(libbladerf_shared SHARED ${LIBBLADERF_SOURCE})
# Build configuration
################################################################################
if(MSVC)
set(LIBBLADERF_LIBS ${LIBBLADERF_LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
else()
if(NOT MSVC)
set(LIBBLADERF_LIBS ${LIBBLADERF_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif(MSVC)
endif(NOT MSVC)
if(ENABLE_BACKEND_LIBUSB)
set(LIBBLADERF_LIBS ${LIBBLADERF_LIBS} ${LIBUSB_LIBRARIES})

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_doc_examples C)
set(INCLUDES

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#define FREQ_HOP_SPACING (bladerf_frequency)40e6
#define ITERATIONS 10000
@ -78,16 +79,16 @@ int main(int argc, char *argv[])
for (i = 0; i < num_frequencies; i++) {
status = bladerf_set_frequency(dev, ch, frequencies[i]);
if (status != 0) {
fprintf(stderr, "Failed to set frequency to %lu Hz: %s\n",
fprintf(stderr, "Failed to set frequency to %" PRIu64 " Hz: %s\n",
frequencies[i], bladerf_strerror(status));
return status;
}
bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_VERBOSE);
printf("Frequency: %lu Hz\n", frequencies[i]);
printf("Frequency: %" PRIu64 " Hz\n", frequencies[i]);
status = bladerf_get_quick_tune(dev, ch, &quick_tunes[i]);
if (status != 0) {
fprintf(stderr, "Failed to get quick tune for %lu Hz: %s\n",
fprintf(stderr, "Failed to get quick tune for %" PRIu64 " Hz: %s\n",
frequencies[i], bladerf_strerror(status));
return status;
}

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
################################################################################
# Install libbladeRF header files

View file

@ -2179,8 +2179,8 @@ typedef enum {
*
* <i>*</i>The number of samples in a <i>block</i> is dependent upon
* the USB speed being used:
* - USB 2.0 Hi-Speed: 256 samples
* - USB 3.0 SuperSpeed: 512 samples
* - USB 2.0 Hi-Speed: 1024 samples
* - USB 3.0 SuperSpeed: 2048 samples
*
* When using the bladerf_sync_rx() and bladerf_sync_tx() functions, the
* above details are entirely transparent; the caller need not be concerned
@ -2324,8 +2324,8 @@ typedef enum {
*
* <i>*</i>The number of samples in a <i>block</i> is dependent upon
* the USB speed being used:
* - USB 2.0 Hi-Speed: 256 samples
* - USB 3.0 SuperSpeed: 512 samples
* - USB 2.0 Hi-Speed: 1024 samples
* - USB 3.0 SuperSpeed: 2048 samples
*
* When using the bladerf_sync_rx() and bladerf_sync_tx() functions, the
* above details are entirely transparent; the caller need not be concerned
@ -2343,6 +2343,16 @@ typedef enum {
BLADERF_FORMAT_SC8_Q7_META,
} bladerf_format;
/**
* Convert a sample format to a string suitable for printing
*
* @param format Format to convert to string
*
* @return The string representation of the format
*/
API_EXPORT
const char * CALL_CONV bladerf_format_to_string(bladerf_format format);
/**
* @defgroup STREAMING_FORMAT_METADATA Metadata structure and flags
*
@ -2747,9 +2757,10 @@ int CALL_CONV bladerf_get_timestamp(struct bladerf *dev,
* data stream. This must be greater than the
* `num_xfers` parameter.
* @param[in] buffer_size The size of the underlying stream buffers, in
* samples. This value must be a multiple of 2048.
* Note that samples are only transferred when a
* buffer of this size is filled.
* samples. Must be a multiple of:
* - 8192 bytes (2048 for FW < v2.5.0)
* - For SC16_Q11_PACKED format, multiply by 3
* Invalid sizes are automatically rounded up.
* @param[in] num_transfers The number of active USB transfers that may be
* in-flight at any given time. If unsure of what
* to use here, try values of 4, 8, or 16.
@ -3488,6 +3499,7 @@ int CALL_CONV bladerf_image_print_metadata(const struct bladerf_image *image);
* @return A pointer to a string representing the image type. Returns "Unknown Type"
* for any unrecognized or out-of-range values.
*/
API_EXPORT
const char* bladerf_image_type_to_string(bladerf_image_type type);
/**

View file

@ -26,7 +26,7 @@
extern "C" {
#include <stdlib.h>
#include <pthread.h>
#include "thread.h"
#include <errno.h>
#include "bladeRF.h" /* Firmware interface */
@ -655,7 +655,7 @@ static int cyapi_stream(void *driver, struct bladerf_stream *stream,
if ((stream->layout & BLADERF_DIRECTION_MASK) == BLADERF_TX
&& stream->format == BLADERF_FORMAT_PACKET_META) {
status = submit_transfer(stream, next_buffer, meta.actual_count);
status = submit_transfer(stream, next_buffer, meta.actual_count * sizeof(uint32_t));
} else {
status = submit_transfer(stream, next_buffer, async_stream_buf_bytes(stream));
}
@ -707,14 +707,14 @@ static int cyapi_stream(void *driver, struct bladerf_stream *stream,
data->transfers[i].buffer = NULL;
data->transfers[i].handle = NULL;
data->num_avail++;
pthread_cond_signal(&stream->can_submit_buffer);
COND_SIGNAL(&stream->can_submit_buffer);
if (next_buffer == BLADERF_STREAM_SHUTDOWN) {
done = true;
} else if (next_buffer != BLADERF_STREAM_NO_DATA) {
if ((layout & BLADERF_DIRECTION_MASK) == BLADERF_TX
&& stream->format == BLADERF_FORMAT_PACKET_META) {
status = submit_transfer(stream, next_buffer, meta.actual_count);
status = submit_transfer(stream, next_buffer, meta.actual_count * sizeof(uint32_t));
} else {
status = submit_transfer(stream, next_buffer, async_stream_buf_bytes(stream));
}
@ -792,20 +792,20 @@ int cyapi_submit_stream_buffer(void *driver, struct bladerf_stream *stream,
return BLADERF_ERR_UNEXPECTED;
}
while (data->num_avail == 0 && status == 0) {
status = pthread_cond_timedwait(&stream->can_submit_buffer,
while (data->num_avail == 0 && status == THREAD_SUCCESS) {
status = COND_TIMED_WAIT(&stream->can_submit_buffer,
&stream->lock,
&timeout_abs);
}
} else {
while (data->num_avail == 0 && status == 0) {
status = pthread_cond_wait(&stream->can_submit_buffer,
while (data->num_avail == 0 && status == THREAD_SUCCESS) {
status = COND_WAIT(&stream->can_submit_buffer,
&stream->lock);
}
}
}
if (status == ETIMEDOUT) {
if (status == THREAD_TIMEOUT) {
return BLADERF_ERR_TIMEOUT;
} else if (status != 0) {
return BLADERF_ERR_UNEXPECTED;

View file

@ -22,7 +22,7 @@
#include "host_config.h"
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "thread.h"
#include <errno.h>
#include <libusb.h>
#if 1 == BLADERF_OS_FREEBSD
@ -1054,7 +1054,7 @@ static void LIBUSB_CALL lusb_stream_cb(struct libusb_transfer *transfer)
} else {
stream_data->transfer_status[transfer_i] = TRANSFER_AVAIL;
stream_data->num_avail++;
pthread_cond_signal(&stream->can_submit_buffer);
COND_SIGNAL(&stream->can_submit_buffer);
}
/* Check to see if the transfer has been cancelled or errored */
@ -1086,7 +1086,8 @@ static void LIBUSB_CALL lusb_stream_cb(struct libusb_transfer *transfer)
break;
case LIBUSB_TRANSFER_TIMED_OUT:
log_error("Transfer timed out for buffer %p\n\r",
log_error("Transfer timed out for %s buffer %p\n\r",
(stream->layout & BLADERF_DIRECTION_MASK) == BLADERF_TX ? "TX" : "RX",
transfer->buffer);
stream->error_code = BLADERF_ERR_TIMEOUT;
break;
@ -1125,7 +1126,7 @@ static void LIBUSB_CALL lusb_stream_cb(struct libusb_transfer *transfer)
int status;
if((stream->layout & BLADERF_DIRECTION_MASK) == BLADERF_TX
&& stream->format == BLADERF_FORMAT_PACKET_META) {
status = submit_transfer(stream, next_buffer, metadata.actual_count);
status = submit_transfer(stream, next_buffer, metadata.actual_count * sizeof(uint32_t));
} else {
status = submit_transfer(stream, next_buffer, async_stream_buf_bytes(stream));
}
@ -1372,7 +1373,7 @@ static int lusb_stream(void *driver, struct bladerf_stream *stream,
if (buffer != BLADERF_STREAM_NO_DATA) {
if((layout & BLADERF_DIRECTION_MASK) == BLADERF_TX
&& stream->format == BLADERF_FORMAT_PACKET_META) {
status = submit_transfer(stream, buffer, metadata.actual_count);
status = submit_transfer(stream, buffer, metadata.actual_count * sizeof(uint32_t));
} else {
status = submit_transfer(stream, buffer, async_stream_buf_bytes(stream));
}
@ -1409,7 +1410,6 @@ int lusb_submit_stream_buffer(void *driver, struct bladerf_stream *stream,
{
int status = 0;
struct lusb_stream_data *stream_data = stream->backend_data;
struct timespec timeout_abs;
if (buffer == BLADERF_STREAM_SHUTDOWN) {
if (stream_data->num_avail == stream_data->num_transfers) {
@ -1430,25 +1430,20 @@ int lusb_submit_stream_buffer(void *driver, struct bladerf_stream *stream,
}
if (timeout_ms != 0) {
status = populate_abs_timeout(&timeout_abs, timeout_ms);
if (status != 0) {
return BLADERF_ERR_UNEXPECTED;
}
while (stream_data->num_avail == 0 && status == 0) {
status = pthread_cond_timedwait(&stream->can_submit_buffer,
while (stream_data->num_avail == 0 && status == THREAD_SUCCESS) {
status = COND_TIMED_WAIT(&stream->can_submit_buffer,
&stream->lock,
&timeout_abs);
timeout_ms);
}
} else {
while (stream_data->num_avail == 0 && status == 0) {
status = pthread_cond_wait(&stream->can_submit_buffer,
while (stream_data->num_avail == 0 && status == THREAD_SUCCESS) {
status = COND_WAIT(&stream->can_submit_buffer,
&stream->lock);
}
}
}
if (status == ETIMEDOUT) {
if (status == THREAD_TIMEOUT) {
log_debug("%s: Timed out waiting for a transfer to become available.\n",
__FUNCTION__);
return BLADERF_ERR_TIMEOUT;

View file

@ -63,6 +63,23 @@ extern bool bladerf_usb_reset_device_on_open;
/* Size of a host<->FPGA message in BYTES */
#define USB_MSG_SIZE_SS 8192
#define USB_MSG_SIZE_HS 4096
#define USB_MSG_SIZE_SS_LEGACY 2048
#define USB_MSG_SIZE_HS_LEGACY 1024
static const struct bladerf_version FW_LARGER_BUFFER_VERSION = {
.major = 2,
.minor = 5,
.patch = 0,
.describe = NULL
};
static const struct bladerf_version FPGA_LARGER_BUFFER_VERSION = {
.major = 0,
.minor = 16,
.patch = 0,
.describe = NULL
};
typedef enum {
USB_TARGET_DEVICE,

View file

@ -24,6 +24,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif
#endif
#include <libbladeRF.h>
@ -1787,6 +1793,28 @@ int bladerf_lock_otp(struct bladerf *dev)
/* Helpers & Miscellaneous */
/******************************************************************************/
const char * bladerf_format_to_string(bladerf_format format)
{
switch (format) {
case BLADERF_FORMAT_SC8_Q7:
return "BLADERF_FORMAT_SC8_Q7";
case BLADERF_FORMAT_SC8_Q7_META:
return "BLADERF_FORMAT_SC8_Q7_META";
case BLADERF_FORMAT_SC16_Q11_PACKED:
return "BLADERF_FORMAT_SC16_Q11_PACKED";
case BLADERF_FORMAT_SC16_Q11:
return "BLADERF_FORMAT_SC16_Q11";
case BLADERF_FORMAT_SC16_Q11_META:
return "BLADERF_FORMAT_SC16_Q11_META";
case BLADERF_FORMAT_PACKET_META:
return "BLADERF_FORMAT_PACKET_META";
default:
assert(!"Invalid format");
return "UNKNOWN";
}
}
const char *bladerf_strerror(int error)
{
switch (error) {
@ -2079,36 +2107,41 @@ int bladerf_xb300_get_output_power(struct bladerf *dev, float *val)
/* Features */
/******************************************************************************/
static const char *feature2str(bladerf_feature feature)
{
switch (feature) {
case BLADERF_FEATURE_DEFAULT: return "DEFAULT";
case BLADERF_FEATURE_OVERSAMPLE: return "OVERSAMPLE";
default: return "UNKNOWN FEATURE";
}
}
static int validate_board_compatibility(const char *board_name, bladerf_feature feature)
{
if (strcmp(board_name, "bladerf2") != 0 && feature == BLADERF_FEATURE_OVERSAMPLE) {
log_error("BladeRF2 required for %s feature\n", feature2str(feature));
return BLADERF_ERR_UNSUPPORTED;
}
return 0;
}
int bladerf_enable_feature(struct bladerf *dev, bladerf_feature feature, bool enable)
{
int status;
MUTEX_LOCK(&dev->lock);
log_verbose("%s feature %s\n", enable ? "Enabling" : "Disabling", feature2str(feature));
int status = 0;
CHECK_NULL(dev);
status = 0;
const char *board_name = bladerf_get_board_name(dev);
if(feature == BLADERF_FEATURE_DEFAULT) {
dev->feature = 0;
} else {
if(feature == BLADERF_FEATURE_OVERSAMPLE) {
if (strcmp(bladerf_get_board_name(dev), "bladerf2") != 0) {
log_error("BladeRF2 required for OVERSAMPLE feature\n");
status = BLADERF_ERR_UNSUPPORTED;
}
} else {
/* Unknown / Unsupported feature */
status = BLADERF_ERR_UNSUPPORTED;
}
if (status == 0) {
if (enable) {
dev->feature |= feature;
} else {
dev->feature &= ~feature;
}
}
if (enable == false) {
dev->feature = BLADERF_FEATURE_DEFAULT;
return 0;
}
MUTEX_UNLOCK(&dev->lock);
CHECK_STATUS(validate_board_compatibility(board_name, feature));
dev->feature = feature;
error:
return status;
}
@ -2132,7 +2165,7 @@ int bladerf_set_oversample_register_config(struct bladerf *dev) {
return BLADERF_ERR_UNSUPPORTED;
}
bladerf_set_rfic_register(dev,0x003,0x54); // OC Register
bladerf_set_rfic_register(dev,0x003,0xD4); // OC Register
/* TX Register Assignments */
bladerf_set_rfic_register(dev,0x02,0xc0); // TX Enable and Filter Control

View file

@ -576,7 +576,7 @@ static int bladerf1_initialize(struct bladerf *dev)
if (status < 0) {
#if LOGGING_ENABLED
if (status == BLADERF_ERR_UPDATE_FPGA) {
log_warning("FPGA v%u.%u.%u was detected. Firmware v%u.%u.%u "
log_error("FPGA v%u.%u.%u was detected. Firmware v%u.%u.%u "
"requires FPGA v%u.%u.%u or later. Please load a "
"different FPGA version before continuing.\n\n",
board_data->fpga_version.major,
@ -589,7 +589,7 @@ static int bladerf1_initialize(struct bladerf *dev)
required_fpga_version.minor,
required_fpga_version.patch);
} else if (status == BLADERF_ERR_UPDATE_FW) {
log_warning("FPGA v%u.%u.%u was detected, which requires firmware "
log_error("FPGA v%u.%u.%u was detected, which requires firmware "
"v%u.%u.%u or later. The device firmware is currently "
"v%u.%u.%u. Please upgrade the device firmware before "
"continuing.\n\n",
@ -604,6 +604,16 @@ static int bladerf1_initialize(struct bladerf *dev)
board_data->fw_version.patch);
}
#endif
if (version_greater_or_equal(&board_data->fw_version, &FW_LARGER_BUFFER_VERSION) &&
version_less_than(&board_data->fpga_version, &FPGA_LARGER_BUFFER_VERSION)) {
return BLADERF_ERR_UPDATE_FPGA;
}
if (version_greater_or_equal(&board_data->fpga_version, &FPGA_LARGER_BUFFER_VERSION) &&
version_less_than(&board_data->fw_version, &FW_LARGER_BUFFER_VERSION)) {
return BLADERF_ERR_UPDATE_FW;
}
}
/* Detect AGC FPGA bug and report warning */
@ -814,6 +824,7 @@ static int bladerf1_open(struct bladerf *dev, struct bladerf_devinfo *devinfo)
struct bladerf1_board_data *board_data;
struct bladerf_version required_fw_version;
bladerf_dev_speed usb_speed;
bool use_legacy_msg_size = false;
char filename[FILENAME_MAX];
char *full_path;
int status;
@ -899,13 +910,19 @@ static int bladerf1_open(struct bladerf *dev, struct bladerf_devinfo *devinfo)
log_debug("Failed to get device speed: %s\n", bladerf_strerror(status));
return status;
}
use_legacy_msg_size = version_less_than(&board_data->fw_version, &FW_LARGER_BUFFER_VERSION);
switch (usb_speed) {
case BLADERF_DEVICE_SPEED_SUPER:
board_data->msg_size = USB_MSG_SIZE_SS;
if (use_legacy_msg_size)
board_data->msg_size = USB_MSG_SIZE_SS_LEGACY;
break;
case BLADERF_DEVICE_SPEED_HIGH:
board_data->msg_size = USB_MSG_SIZE_HS;
if (use_legacy_msg_size)
board_data->msg_size = USB_MSG_SIZE_HS_LEGACY;
break;
default:
@ -913,6 +930,13 @@ static int bladerf1_open(struct bladerf *dev, struct bladerf_devinfo *devinfo)
return BLADERF_ERR_UNEXPECTED;
}
log_debug("Size of a host<->FPGA message: %zu bytes\n", board_data->msg_size);
if (use_legacy_msg_size) {
log_warning("Using legacy message size. Consider upgrading firmware >= v%u.%u.%u and fpga >= v%u.%u.%u\n",
FW_LARGER_BUFFER_VERSION.major, FW_LARGER_BUFFER_VERSION.minor, FW_LARGER_BUFFER_VERSION.patch,
FPGA_LARGER_BUFFER_VERSION.major, FPGA_LARGER_BUFFER_VERSION.minor, FPGA_LARGER_BUFFER_VERSION.patch);
}
/* Verify that we have a sufficent firmware version before continuing. */
status = version_check_fw(&bladerf1_fw_compat_table,
&board_data->fw_version, &required_fw_version);
@ -1345,6 +1369,18 @@ static int bladerf1_enable_module(struct bladerf *dev,
}
lms_enable_rffe(dev, ch, enable);
if (enable && !BLADERF_CHANNEL_IS_TX(ch)) {
struct bladerf_sync *sync = &board_data->sync[ch];
if (sync->initialized) {
status = sync_prime_stream(sync, 0);
if (status != 0) {
return status;
}
}
}
status = dev->backend->enable_module(
dev, BLADERF_CHANNEL_IS_TX(ch) ? BLADERF_TX : BLADERF_RX, enable);

View file

@ -13,6 +13,8 @@
static const struct compat fw_compat[] = {
/* Firmware requires >= FPGA */
{ VERSION(2, 6, 0), VERSION(0, 16, 0) },
{ VERSION(2, 5, 0), VERSION(0, 16, 0) },
{ VERSION(2, 4, 0), VERSION(0, 6, 0) },
{ VERSION(2, 3, 2), VERSION(0, 0, 2) },
{ VERSION(2, 3, 1), VERSION(0, 0, 2) },
@ -35,6 +37,8 @@ const struct version_compat_table bladerf1_fw_compat_table = {fw_compat, ARRAY_S
static const struct compat fpga_compat[] = {
/* FPGA requires >= Firmware */
{ VERSION(0, 16, 0), VERSION(2, 6, 0) },
{ VERSION(0, 16, 0), VERSION(2, 5, 0) },
{ VERSION(0, 15, 3), VERSION(2, 4, 0) },
{ VERSION(0, 15, 1), VERSION(2, 4, 0) },
{ VERSION(0, 15, 0), VERSION(2, 4, 0) },

View file

@ -143,7 +143,7 @@ static int _bladerf2_initialize(struct bladerf *dev)
if (status < 0) {
#if LOGGING_ENABLED
if (BLADERF_ERR_UPDATE_FPGA == status) {
log_warning(
log_error(
"FPGA v%u.%u.%u was detected. Firmware v%u.%u.%u "
"requires FPGA v%u.%u.%u or later. Please load a "
"different FPGA version before continuing.\n\n",
@ -153,7 +153,7 @@ static int _bladerf2_initialize(struct bladerf *dev)
required_fpga_version.major, required_fpga_version.minor,
required_fpga_version.patch);
} else if (BLADERF_ERR_UPDATE_FW == status) {
log_warning(
log_error(
"FPGA v%u.%u.%u was detected, which requires firmware "
"v%u.%u.%u or later. The device firmware is currently "
"v%u.%u.%u. Please upgrade the device firmware before "
@ -165,6 +165,16 @@ static int _bladerf2_initialize(struct bladerf *dev)
board_data->fw_version.patch);
}
#endif
if (version_greater_or_equal(&board_data->fw_version, &FW_LARGER_BUFFER_VERSION) &&
version_less_than(&board_data->fpga_version, &FPGA_LARGER_BUFFER_VERSION)) {
return BLADERF_ERR_UPDATE_FPGA;
}
if (version_greater_or_equal(&board_data->fpga_version, &FPGA_LARGER_BUFFER_VERSION) &&
version_less_than(&board_data->fw_version, &FW_LARGER_BUFFER_VERSION)) {
return BLADERF_ERR_UPDATE_FW;
}
}
/* Set FPGA packet protocol */
@ -254,6 +264,7 @@ static int bladerf2_open(struct bladerf *dev, struct bladerf_devinfo *devinfo)
struct bladerf_version required_fw_version;
char *full_path;
bladerf_dev_speed usb_speed;
bool use_legacy_msg_size = false;
size_t i;
int ready, status;
@ -324,19 +335,33 @@ static int bladerf2_open(struct bladerf *dev, struct bladerf_devinfo *devinfo)
/* Determine data message size */
CHECK_STATUS(dev->backend->get_device_speed(dev, &usb_speed));
use_legacy_msg_size = version_less_than(&board_data->fw_version, &FW_LARGER_BUFFER_VERSION);
switch (usb_speed) {
case BLADERF_DEVICE_SPEED_SUPER:
board_data->msg_size = USB_MSG_SIZE_SS;
if (use_legacy_msg_size)
board_data->msg_size = USB_MSG_SIZE_SS_LEGACY;
break;
case BLADERF_DEVICE_SPEED_HIGH:
board_data->msg_size = USB_MSG_SIZE_HS;
if (use_legacy_msg_size)
board_data->msg_size = USB_MSG_SIZE_HS_LEGACY;
break;
default:
log_error("%s: unsupported device speed (%d)\n", __FUNCTION__,
usb_speed);
return BLADERF_ERR_UNSUPPORTED;
}
log_debug("Size of a host<->FPGA message: %zu bytes\n", board_data->msg_size);
if (use_legacy_msg_size) {
log_warning("Using legacy message size. Consider upgrading firmware >= v%u.%u.%u and fpga >= v%u.%u.%u\n",
FW_LARGER_BUFFER_VERSION.major, FW_LARGER_BUFFER_VERSION.minor, FW_LARGER_BUFFER_VERSION.patch,
FPGA_LARGER_BUFFER_VERSION.major, FPGA_LARGER_BUFFER_VERSION.minor, FPGA_LARGER_BUFFER_VERSION.patch);
}
/* Verify that we have a sufficent firmware version before continuing. */
status = version_check_fw(&bladerf2_fw_compat_table,
&board_data->fw_version, &required_fw_version);
@ -1047,17 +1072,17 @@ static int bladerf2_set_sample_rate(struct bladerf *dev,
CHECK_STATUS(dev->board->get_sample_rate_range(dev, ch, &range));
if (!is_within_range(range, rate)) {
return BLADERF_ERR_RANGE;
}
/* Feature range check */
if (dev->feature == BLADERF_FEATURE_OVERSAMPLE &&
!is_within_range(&bladerf2_sample_rate_range_oversample, rate)) {
log_error("Sample rate outside of OVERSAMPLE feature range\n");
return BLADERF_ERR_RANGE;
} else if (dev->feature == BLADERF_FEATURE_DEFAULT &&
!is_within_range(&bladerf2_sample_rate_range_base, rate)) {
log_error("Sample rate outside of DEFAULT feature range\n");
log_error("Sample rate %.3f MHz is out of range\n"
"Available ranges:\n"
" Normal operating range: %.3f MHz to %.3f MHz%s\n"
" Oversample feature range: %.3f MHz to %.3f MHz%s\n",
rate/1e6,
bladerf2_sample_rate_range_base.min/1e6,
bladerf2_sample_rate_range_base.max/1e6,
(dev->feature == BLADERF_FEATURE_DEFAULT) ? " (current)" : "",
bladerf2_sample_rate_range_oversample.min/1e6,
bladerf2_sample_rate_range_oversample.max/1e6,
(dev->feature == BLADERF_FEATURE_OVERSAMPLE) ? " (current)" : "");
return BLADERF_ERR_RANGE;
}
@ -2446,8 +2471,9 @@ static int bladerf2_set_loopback(struct bladerf *dev, bladerf_loopback mode)
IF_COMMAND_MODE(dev, RFIC_COMMAND_FPGA, {
if (BLADERF_LB_RFIC_BIST == mode) {
log_debug(
"%s: BLADERF_LB_RFIC_BIST not supported in FPGA command mode\n",
log_error(
"%s: RFIC BIST requires HOST tuning mode (currently FPGA). "
"Check BLADERF_DEFAULT_TUNING_MODE env var.\n",
__FUNCTION__);
return BLADERF_ERR_UNSUPPORTED;
}

View file

@ -312,7 +312,8 @@ bool check_total_sample_rate(struct bladerf *dev)
bladerf_sample_rate rate_accum = 0;
size_t active_channels = 0;
const bladerf_sample_rate MAX_SAMPLE_THROUGHPUT = 80000000;
const bladerf_sample_rate MAX_SAMPLE_THROUGHPUT =
(dev->feature == BLADERF_FEATURE_OVERSAMPLE) ? 160000000 : 80000000;
/* Read RFFE control register */
status = dev->backend->rffe_control_read(dev, &reg);

View file

@ -253,17 +253,21 @@ extern char const *bladerf2_state_to_string[4];
} while (0)
/**
* @brief Null test
* @brief Null test for multiple variables
*
* @param _var The variable to check
* @param ... The variables to check
*
* @return RETURN_INVAL if _var is null, continues otherwise
* @return RETURN_INVAL if any var is null, continues otherwise
*/
#define NULL_CHECK(_var) \
do { \
if (NULL == _var) { \
RETURN_INVAL(#_var, "is null"); \
} \
#define NULL_CHECK(...) \
do { \
void *_ptrs[] = { (void*)__VA_ARGS__ }; \
const char *_names[] = { #__VA_ARGS__ }; \
for (size_t _i = 0; _i < sizeof(_ptrs)/sizeof(_ptrs[0]); _i++) { \
if (NULL == _ptrs[_i]) { \
RETURN_INVAL(_names[_i], "is null"); \
} \
} \
} while (0)
/**

View file

@ -13,6 +13,7 @@
static const struct compat fw_compat[] = {
/* Firmware requires >= FPGA */
{ VERSION(2, 6, 0), VERSION(0, 16, 0) },
{ VERSION(2, 5, 0), VERSION(0, 16, 0) },
{ VERSION(2, 4, 0), VERSION(0, 6, 0) },
{ VERSION(2, 3, 2), VERSION(0, 6, 0) },
@ -28,6 +29,7 @@ const struct version_compat_table bladerf2_fw_compat_table = {fw_compat, ARRAY_S
static const struct compat fpga_compat[] = {
/* FPGA requires >= Firmware */
{ VERSION(0, 16, 0), VERSION(2, 6, 0) },
{ VERSION(0, 16, 0), VERSION(2, 5, 0) },
{ VERSION(0, 15, 3), VERSION(2, 4, 0) },
{ VERSION(0, 15, 2), VERSION(2, 4, 0) },

View file

@ -319,6 +319,14 @@ static int _rfic_fpga_enable_module(struct bladerf *dev,
/* Perform backend setup */
if (be_setup) {
if (dir == BLADERF_RX) {
struct bladerf_sync *sync = &board_data->sync[BLADERF_RX];
if (sync->initialized) {
CHECK_STATUS(sync_prime_stream(sync, 0));
}
}
CHECK_STATUS(dev->backend->enable_module(dev, dir, true));
}

View file

@ -337,6 +337,14 @@ static int _rfic_host_enable_module(struct bladerf *dev,
}
if (dir_enable || backend_clear) {
if (dir == BLADERF_RX) {
struct bladerf_sync *sync = &board_data->sync[BLADERF_RX];
if (sync->initialized) {
CHECK_STATUS(sync_prime_stream(sync, 0));
}
}
CHECK_STATUS(dev->backend->enable_module(dev, dir, true));
}
}
@ -443,6 +451,8 @@ static int _rfic_host_set_frequency(struct bladerf *dev,
CHECK_STATUS(dev->board->get_frequency_range(dev, ch, &range));
if (!is_within_range(range, frequency)) {
log_error("Frequency out of range [%0.2f MHz, %0.2f MHz]: %f MHz\n",
range->min/1e6, range->max/1e6, frequency/1e6);
return BLADERF_ERR_RANGE;
}

View file

@ -22,14 +22,24 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <limits.h>
#include "common.h"
#include "libbladeRF.h"
#include "board/board.h"
#include "helpers/version.h"
#include "device_calibration.h"
#include "log.h"
#include "common.h"
#ifdef _WIN32
#include <windows.h>
#include <limits.h>
// Define PATH_MAX for Windows if not already defined
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif
#else
#include <unistd.h>
#include <limits.h>
#endif
#define GAIN_CAL_HEADER_RX "RX Chain,RX Gain,VSG Power into bladeRF RX (dBm),Frequency of signal (Hz),Frequency of bladeRF+PXI (Hz),AD9361 RSSI register value,Power of Signal from Full Scale (dBFS)\0"
#define GAIN_CAL_HEADER_TX "TX Chain,TX Gain,Frequency of Signal (Hz),Frequency of bladeRF+PXI (Hz),VSA Measured Power (dBm)\0"
@ -226,7 +236,7 @@ static int gain_cal_tbl_init(struct bladerf_gain_cal_tbl *tbl, uint32_t num_entr
tbl->n_entries = num_entries;
tbl->start_freq = 0;
tbl->stop_freq = 0;
tbl->file_path_len = PATH_MAX;
tbl->file_path_len = 4;
tbl->entries = malloc(num_entries * sizeof(struct bladerf_gain_cal_entry));
if (tbl->entries == NULL) {
@ -269,8 +279,13 @@ void gain_cal_tbl_free(struct bladerf_gain_cal_tbl *tbl) {
}
int load_gain_calibration(struct bladerf *dev, bladerf_channel ch, const char *binary_path) {
int num_channels = 4;
struct bladerf_gain_cal_tbl gain_tbls[num_channels];
const int num_channels = 4; // Make this const to fix the array allocation issue
struct bladerf_gain_cal_tbl *gain_tbls = malloc(num_channels * sizeof(struct bladerf_gain_cal_tbl));
if (!gain_tbls) {
log_error("Failed to allocate memory for gain tables\n");
return BLADERF_ERR_MEM;
}
bladerf_gain current_gain;
uint64_t frequency;
float power;
@ -413,6 +428,9 @@ error:
fclose(binaryFile);
if (image)
bladerf_free_image(image);
if (gain_tbls)
free(gain_tbls);
return status;
}

View file

@ -44,6 +44,8 @@ int async_init_stream(struct bladerf_stream **stream,
{
struct bladerf_stream *lstream;
size_t buffer_size_bytes;
size_t gpif_buffer_size = USB_MSG_SIZE_SS;
struct bladerf_version fx3_version = FW_LARGER_BUFFER_VERSION;
size_t i;
int status = 0;
@ -52,10 +54,26 @@ int async_init_stream(struct bladerf_stream **stream,
return BLADERF_ERR_INVAL;
}
status = dev->board->get_fw_version(dev, &fx3_version);
if (status != 0) {
log_error("Failed to get FX3 firmware version: %s\n",
bladerf_strerror(status));
return status;
}
if (fx3_version.major <= FW_LARGER_BUFFER_VERSION.major &&
fx3_version.minor < FW_LARGER_BUFFER_VERSION.minor) {
gpif_buffer_size = USB_MSG_SIZE_SS_LEGACY;
}
log_debug("FX3 firmware %u.%u.%u GPIF buffer size: %zu%s\n",
fx3_version.major, fx3_version.minor, fx3_version.patch,
gpif_buffer_size, gpif_buffer_size == USB_MSG_SIZE_SS_LEGACY ? " (legacy)" : "");
buffer_size_bytes = samples_to_bytes(format, samples_per_buffer);
if (buffer_size_bytes < USB_MSG_SIZE_SS || buffer_size_bytes % USB_MSG_SIZE_SS != 0) {
if (buffer_size_bytes < gpif_buffer_size || buffer_size_bytes % gpif_buffer_size != 0) {
log_error("Samples_per_buffer must be multiples of %u\n",
bytes_to_samples(format, USB_MSG_SIZE_SS));
bytes_to_samples(format, gpif_buffer_size));
return BLADERF_ERR_INVAL;
}
@ -68,12 +86,12 @@ int async_init_stream(struct bladerf_stream **stream,
MUTEX_INIT(&lstream->lock);
if (pthread_cond_init(&lstream->can_submit_buffer, NULL) != 0) {
if (COND_INIT(&lstream->can_submit_buffer) != THREAD_SUCCESS) {
free(lstream);
return BLADERF_ERR_UNEXPECTED;
}
if (pthread_cond_init(&lstream->stream_started, NULL) != 0) {
if (COND_INIT(&lstream->stream_started) != THREAD_SUCCESS) {
free(lstream);
return BLADERF_ERR_UNEXPECTED;
}
@ -185,7 +203,7 @@ int async_run_stream(struct bladerf_stream *stream, bladerf_channel_layout layou
MUTEX_LOCK(&stream->lock);
stream->layout = layout;
stream->state = STREAM_RUNNING;
pthread_cond_signal(&stream->stream_started);
COND_SIGNAL(&stream->stream_started);
MUTEX_UNLOCK(&stream->lock);
status = dev->backend->stream(stream, layout);
@ -200,32 +218,23 @@ int async_submit_stream_buffer(struct bladerf_stream *stream,
bool nonblock)
{
int status = 0;
struct timespec timeout_abs;
MUTEX_LOCK(&stream->lock);
if (buffer != BLADERF_STREAM_SHUTDOWN) {
if (stream->state != STREAM_RUNNING && timeout_ms != 0) {
status = populate_abs_timeout(&timeout_abs, timeout_ms);
if (status != 0) {
log_debug("Failed to populate timeout value\n");
goto error;
}
}
while (stream->state != STREAM_RUNNING) {
log_debug("Buffer submitted while stream's not running. "
"Waiting for stream to start.\n");
if (timeout_ms == 0) {
status = pthread_cond_wait(&stream->stream_started,
status = COND_WAIT(&stream->stream_started,
&stream->lock);
} else {
status = pthread_cond_timedwait(&stream->stream_started,
&stream->lock, &timeout_abs);
status = COND_TIMED_WAIT(&stream->stream_started,
&stream->lock, timeout_ms);
}
if (status == ETIMEDOUT) {
if (status == THREAD_TIMEOUT) {
status = BLADERF_ERR_TIMEOUT;
log_debug("%s: %u ms timeout expired",
__FUNCTION__, timeout_ms);

View file

@ -22,8 +22,6 @@
#ifndef STREAMING_ASYNC_H_
#define STREAMING_ASYNC_H_
#include <pthread.h>
#include <libbladeRF.h>
#include "thread.h"
@ -58,16 +56,14 @@ struct bladerf_stream {
/* The following items must be accessed atomically */
int error_code;
bladerf_stream_state state;
pthread_cond_t can_submit_buffer;
pthread_cond_t stream_started;
COND can_submit_buffer;
COND stream_started;
void *backend_data;
};
/* Get the number of bytes per stream buffer */
static inline size_t async_stream_buf_bytes(struct bladerf_stream *s)
{
if (s->format == BLADERF_FORMAT_PACKET_META)
return s->samples_per_buffer;
return samples_to_bytes(s->format, s->samples_per_buffer);
}

View file

@ -39,6 +39,7 @@
#include "board/board.h"
#include "helpers/timeout.h"
#include "helpers/have_cap.h"
#include "backend/usb/usb.h"
#ifdef ENABLE_LIBBLADERF_SYNC_LOG_VERBOSE
static inline void dump_buf_states(struct bladerf_sync *s)
@ -142,7 +143,9 @@ int sync_init(struct bladerf_sync *sync,
int status = 0;
size_t i, bytes_per_sample;
size_t bytes_per_buffer;
const size_t GPIF_BUF_SIZE = 8192;
size_t gpif_buffer_size = USB_MSG_SIZE_SS;
size_t valid_buffer_size = gpif_buffer_size;
struct bladerf_version fx3_version = FW_LARGER_BUFFER_VERSION;
if (num_transfers >= num_buffers) {
return BLADERF_ERR_INVAL;
@ -170,15 +173,35 @@ int sync_init(struct bladerf_sync *sync,
}
}
status = dev->board->get_fw_version(dev, &fx3_version);
if (status != 0) {
log_error("Failed to get FX3 firmware version: %s\n",
bladerf_strerror(status));
return status;
}
if (fx3_version.major <= FW_LARGER_BUFFER_VERSION.major &&
fx3_version.minor < FW_LARGER_BUFFER_VERSION.minor) {
gpif_buffer_size = USB_MSG_SIZE_SS_LEGACY;
}
log_debug("FX3 firmware %u.%u.%u GPIF buffer size: %zu%s\n",
fx3_version.major, fx3_version.minor, fx3_version.patch,
gpif_buffer_size, gpif_buffer_size == USB_MSG_SIZE_SS_LEGACY ? " (legacy)" : "");
if (format == BLADERF_FORMAT_SC16_Q11_PACKED) {
valid_buffer_size = 3*gpif_buffer_size;
}
bytes_per_sample = samples_to_bytes(format, 1);
bytes_per_buffer = samples_to_bytes(format, buffer_size);
if (bytes_per_buffer < GPIF_BUF_SIZE || bytes_per_buffer % GPIF_BUF_SIZE != 0) {
if (bytes_per_buffer < valid_buffer_size || bytes_per_buffer % valid_buffer_size != 0) {
size_t original_size = buffer_size;
/* Round up to the next multiple of GPIF_BUF_SIZE, ensuring at least one GPIF buffer */
buffer_size = bytes_per_buffer == 0 ? GPIF_BUF_SIZE / bytes_per_sample :
((bytes_per_buffer + GPIF_BUF_SIZE - 1) / GPIF_BUF_SIZE)
* (GPIF_BUF_SIZE / bytes_per_sample);
/* Round up to the next multiple of valid_buffer_size, ensuring at least one GPIF buffer */
buffer_size = bytes_per_buffer == 0 ? valid_buffer_size / bytes_per_sample :
((bytes_per_buffer + valid_buffer_size - 1) / valid_buffer_size)
* (valid_buffer_size / bytes_per_sample);
log_warning("Requested buffer size %zu samples (%zu bytes) is invalid. "
"Adjusting to %zu samples (%zu bytes).\n",
@ -234,7 +257,7 @@ int sync_init(struct bladerf_sync *sync,
__FUNCTION__, sync->meta.samples_per_msg);
MUTEX_INIT(&sync->buf_mgmt.lock);
pthread_cond_init(&sync->buf_mgmt.buf_ready, NULL);
COND_INIT(&sync->buf_mgmt.buf_ready);
sync->buf_mgmt.status = (sync_buffer_status*) malloc(num_buffers * sizeof(sync_buffer_status));
if (sync->buf_mgmt.status == NULL) {
@ -248,6 +271,22 @@ int sync_init(struct bladerf_sync *sync,
goto error;
}
if ((layout & BLADERF_DIRECTION_MASK) == BLADERF_RX) {
sync->buf_mgmt.buffer_seq =
(uint32_t *)malloc(num_buffers * sizeof(uint32_t));
if (sync->buf_mgmt.buffer_seq == NULL) {
status = BLADERF_ERR_MEM;
goto error;
}
} else {
sync->buf_mgmt.buffer_seq = NULL;
}
sync->buf_mgmt.expected_seq = 0;
sync->buf_mgmt.next_seq = 0;
sync->buf_mgmt.reorder_len = 0;
sync->buf_mgmt.reorder_limit = 0;
switch (layout & BLADERF_DIRECTION_MASK) {
case BLADERF_RX:
/* When starting up an RX stream, the first 'num_transfers'
@ -267,6 +306,8 @@ int sync_init(struct bladerf_sync *sync,
sync->meta.msg_timestamp = 0;
sync->meta.msg_flags = 0;
sync_reset_sequence_tracking(&sync->buf_mgmt, num_transfers);
break;
case BLADERF_TX:
@ -309,13 +350,21 @@ void sync_deinit(struct bladerf_sync *sync)
sync_worker_deinit(sync->worker, &sync->buf_mgmt.lock,
&sync->buf_mgmt.buf_ready);
if (sync->buf_mgmt.actual_lengths) {
free(sync->buf_mgmt.actual_lengths);
}
/* De-allocate our buffer management resources */
if (sync->buf_mgmt.status) {
MUTEX_DESTROY(&sync->buf_mgmt.lock);
free(sync->buf_mgmt.status);
sync->buf_mgmt.status = NULL;
}
if (sync->buf_mgmt.actual_lengths) {
free(sync->buf_mgmt.actual_lengths);
sync->buf_mgmt.actual_lengths = NULL;
}
if (sync->buf_mgmt.buffer_seq) {
free(sync->buf_mgmt.buffer_seq);
sync->buf_mgmt.buffer_seq = NULL;
}
MUTEX_DESTROY(&sync->lock);
@ -330,22 +379,18 @@ static int wait_for_buffer(struct buffer_mgmt *b,
unsigned int dbg_idx)
{
int status;
struct timespec timeout;
if (timeout_ms == 0) {
log_verbose("%s: Infinite wait for buffer[%d] (status: %d).\n",
dbg_name, dbg_idx, b->status[dbg_idx]);
status = pthread_cond_wait(&b->buf_ready, &b->lock);
status = COND_WAIT(&b->buf_ready, &b->lock);
} else {
log_verbose("%s: Timed wait for buffer[%d] (status: %d).\n", dbg_name,
dbg_idx, b->status[dbg_idx]);
status = populate_abs_timeout(&timeout, timeout_ms);
if (status == 0) {
status = pthread_cond_timedwait(&b->buf_ready, &b->lock, &timeout);
}
status = COND_TIMED_WAIT(&b->buf_ready, &b->lock, timeout_ms);
}
if (status == ETIMEDOUT) {
if (status == THREAD_TIMEOUT) {
log_error("%s: Timed out waiting for buf_ready after %d ms\n",
__FUNCTION__, timeout_ms);
status = BLADERF_ERR_TIMEOUT;
@ -360,6 +405,43 @@ static int wait_for_buffer(struct buffer_mgmt *b,
# define SYNC_WORKER_START_TIMEOUT_MS 250
#endif
int sync_prime_stream(struct bladerf_sync *sync, unsigned int timeout_ms)
{
int status;
unsigned int wait_ms = timeout_ms ? timeout_ms : SYNC_WORKER_START_TIMEOUT_MS;
if (sync == NULL || !sync->initialized) {
return 0;
}
if ((sync->stream_config.layout & BLADERF_DIRECTION_MASK) != BLADERF_RX) {
return 0;
}
if (sync->worker == NULL) {
return BLADERF_ERR_INVAL;
}
switch (sync_worker_get_state(sync->worker, NULL)) {
case SYNC_WORKER_STATE_RUNNING:
return 0;
case SYNC_WORKER_STATE_IDLE:
break;
default:
return BLADERF_ERR_UNEXPECTED;
}
sync_worker_submit_request(sync->worker, SYNC_WORKER_START);
status = sync_worker_wait_for_state(sync->worker,
SYNC_WORKER_STATE_RUNNING,
wait_ms);
return status;
}
/* Returns # of timestamps (or time steps) left in a message */
static inline unsigned int ts_remaining(struct bladerf_sync *s)
{
@ -779,8 +861,10 @@ int sync_rx(struct bladerf_sync *s, void *samples, unsigned num_samples,
buf_src = (uint8_t*)b->buffers[b->cons_i];
pkt_len_dwords = metadata_get_packet_len(buf_src);
user_meta->flags = metadata_get_packet_flags(buf_src);
user_meta->timestamp = metadata_get_timestamp(buf_src);
pkt_len_dwords = metadata_get_packet_len(buf_src);
if (pkt_len_dwords > 0) {
samples_returned += num_samples;
user_meta->actual_count = pkt_len_dwords;

View file

@ -23,7 +23,7 @@
#define STREAMING_SYNC_H_
#include <limits.h>
#include <pthread.h>
#include <stdint.h>
#include <libbladeRF.h>
@ -48,6 +48,16 @@ typedef enum {
SYNC_BUFFER_IN_FLIGHT, /**< Currently being transferred */
} sync_buffer_status;
#ifndef SYNC_RX_MAX_REORDER
#define SYNC_RX_MAX_REORDER 256
#endif
struct rx_reorder_entry {
uint32_t seq;
unsigned int buf_idx;
size_t num_samples;
};
typedef enum {
SYNC_META_STATE_HEADER, /**< Extract the metadata header */
SYNC_META_STATE_SAMPLES, /**< Process samples */
@ -86,12 +96,68 @@ struct buffer_mgmt {
* submitting full buffers to the underlying async system */
sync_tx_submitter submitter;
/* RX-specific tracking for out-of-order completions */
uint32_t *buffer_seq;
uint32_t expected_seq;
uint32_t next_seq;
struct rx_reorder_entry reorder[SYNC_RX_MAX_REORDER];
size_t reorder_len;
unsigned int reorder_limit;
MUTEX lock;
pthread_cond_t buf_ready; /**< Buffer produced by RX callback, or
COND buf_ready; /**< Buffer produced by RX callback, or
* buffer emptied by TX callback */
};
static inline void sync_reset_sequence_tracking(struct buffer_mgmt *b,
unsigned int num_in_flight)
{
if (b == NULL) {
return;
}
if (!b->buffer_seq) {
b->expected_seq = 0;
b->next_seq = 0;
b->reorder_len = 0;
return;
}
for (size_t i = 0; i < SYNC_RX_MAX_REORDER; ++i) {
b->reorder[i].seq = 0;
b->reorder[i].buf_idx = 0;
b->reorder[i].num_samples = 0;
}
for (unsigned int i = 0; i < b->num_buffers; ++i) {
b->buffer_seq[i] = UINT32_MAX;
}
unsigned int limit = num_in_flight;
if (limit > b->num_buffers) {
limit = b->num_buffers;
}
for (unsigned int i = 0; i < limit; ++i) {
b->buffer_seq[i] = i;
}
b->expected_seq = 0;
b->next_seq = limit;
b->reorder_len = 0;
/* Allow a larger reorder window independent of instantaneous slack. */
if (b->num_buffers > 1) {
unsigned int capacity = b->num_buffers - 1;
if (capacity > SYNC_RX_MAX_REORDER) {
capacity = SYNC_RX_MAX_REORDER;
}
b->reorder_limit = capacity;
} else {
b->reorder_limit = 0;
}
}
/* State of API-side sync interface */
typedef enum {
SYNC_STATE_CHECK_WORKER,
@ -190,4 +256,6 @@ unsigned int sync_buf2idx(struct buffer_mgmt *b, void *addr);
void *sync_idx2buf(struct buffer_mgmt *b, unsigned int idx);
int sync_prime_stream(struct bladerf_sync *sync, unsigned int timeout_ms);
#endif

View file

@ -17,6 +17,7 @@
*/
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
@ -43,6 +44,75 @@
void *sync_worker_task(void *arg);
static void mark_buffer_ready(struct buffer_mgmt *b,
unsigned int idx,
size_t num_samples)
{
b->status[idx] = SYNC_BUFFER_FULL;
b->actual_lengths[idx] = num_samples;
COND_SIGNAL(&b->buf_ready);
}
static void flush_reorder_entries(struct buffer_mgmt *b)
{
bool progressed = true;
while (progressed && b->reorder_len > 0) {
progressed = false;
for (size_t i = 0; i < b->reorder_len; ++i) {
if (b->reorder[i].seq == b->expected_seq) {
mark_buffer_ready(b, b->reorder[i].buf_idx,
b->reorder[i].num_samples);
b->expected_seq++;
for (size_t j = i; j + 1 < b->reorder_len; ++j) {
b->reorder[j] = b->reorder[j + 1];
}
b->reorder_len--;
progressed = true;
break;
}
}
}
}
static bool hold_out_of_order_buffer(struct buffer_mgmt *b,
uint32_t seq,
unsigned int idx,
size_t num_samples)
{
if (b->reorder_limit == 0 || b->reorder_len >= b->reorder_limit) {
return false;
}
const uint32_t new_distance = seq - b->expected_seq;
size_t insert_pos = 0;
while (insert_pos < b->reorder_len) {
const uint32_t existing_distance =
b->reorder[insert_pos].seq - b->expected_seq;
if (existing_distance > new_distance) {
break;
}
insert_pos++;
}
for (size_t i = b->reorder_len; i > insert_pos; --i) {
b->reorder[i] = b->reorder[i - 1];
}
b->reorder[insert_pos].seq = seq;
b->reorder[insert_pos].buf_idx = idx;
b->reorder[insert_pos].num_samples = num_samples;
b->reorder_len++;
return true;
}
static void *rx_callback(struct bladerf *dev,
struct bladerf_stream *stream,
struct bladerf_metadata *meta,
@ -80,28 +150,81 @@ static void *rx_callback(struct bladerf *dev,
if (b->resubmit_count == 0) {
if (b->status[b->prod_i] == SYNC_BUFFER_EMPTY) {
/* This buffer is now ready for the consumer */
b->status[samples_idx] = SYNC_BUFFER_FULL;
b->actual_lengths[samples_idx] = num_samples;
pthread_cond_signal(&b->buf_ready);
bool release_now = true;
uint32_t seq = 0;
if (b->buffer_seq) {
seq = b->buffer_seq[samples_idx];
if (seq != b->expected_seq) {
const uint32_t distance = seq - b->expected_seq;
if (distance != 0 && distance <= b->reorder_limit) {
if (hold_out_of_order_buffer(b, seq, samples_idx,
num_samples)) {
release_now = false;
log_verbose("%s worker: buf[%u] held for reorder "
"(seq=%u expect=%u)\n",
worker2str(s), samples_idx, seq,
b->expected_seq);
} else {
log_warning("%s worker: RX reorder window full "
"(limit=%u). Forwarding buf[%u] "
"(seq=%u, expect=%u).\n",
worker2str(s), b->reorder_limit,
samples_idx, seq, b->expected_seq);
}
} else if (distance != 0) {
log_warning("%s worker: RX reorder distance %u exceeds "
"window %u. Forwarding buf[%u].\n",
worker2str(s), distance, b->reorder_limit,
samples_idx);
}
}
}
if (release_now) {
mark_buffer_ready(b, samples_idx, num_samples);
if (b->buffer_seq && seq == b->expected_seq) {
b->expected_seq++;
flush_reorder_entries(b);
}
log_verbose("%s worker: buf[%u] = full\n",
worker2str(s), samples_idx);
}
/* Update the state of the buffer being submitted next */
next_idx = b->prod_i;
b->status[next_idx] = SYNC_BUFFER_IN_FLIGHT;
if (b->buffer_seq) {
b->buffer_seq[next_idx] = b->next_seq++;
}
next_buf = b->buffers[next_idx];
/* Advance to the next buffer for the next callback */
b->prod_i = (next_idx + 1) % b->num_buffers;
log_verbose("%s worker: buf[%u] = full, buf[%u] = in_flight\n",
worker2str(s), samples_idx, next_idx);
if (release_now) {
log_verbose("%s worker: buf[%u] now in_flight\n",
worker2str(s), next_idx);
}
} else {
/* TODO propagate back the RX Overrun to the sync_rx() caller */
log_debug("RX overrun @ buffer %u\r\n", samples_idx);
if (b->reorder_len > 0) {
/* We're holding buffers to restore order. Skip submitting a
* new transfer this time to avoid overwriting held data. */
next_buf = BLADERF_STREAM_NO_DATA;
log_verbose("%s worker: delaying submission while reorder "
"queue drains\n", worker2str(s));
} else {
/* TODO propagate back the RX Overrun to the sync_rx() caller */
log_debug("RX overrun @ buffer %u\r\n", samples_idx);
next_buf = samples;
b->resubmit_count = s->stream_config.num_xfers - 1;
next_buf = samples;
b->resubmit_count = s->stream_config.num_xfers - 1;
}
}
} else {
/* We're still recovering from an overrun at this point. Just
@ -155,7 +278,7 @@ static void *tx_callback(struct bladerf *dev,
completed_idx = sync_buf2idx(b, samples);
assert(b->status[completed_idx] == SYNC_BUFFER_IN_FLIGHT);
b->status[completed_idx] = SYNC_BUFFER_EMPTY;
pthread_cond_signal(&b->buf_ready);
COND_SIGNAL(&b->buf_ready);
/* If the callback is assigned to be the submitter, there are
* buffers pending submission */
@ -230,25 +353,25 @@ int sync_worker_init(struct bladerf_sync *s)
MUTEX_INIT(&s->worker->state_lock);
MUTEX_INIT(&s->worker->request_lock);
status = pthread_cond_init(&s->worker->state_changed, NULL);
if (status != 0) {
log_debug("%s worker: pthread_cond_init(state_changed) failed: %d\n",
status = COND_INIT(&s->worker->state_changed);
if (status != THREAD_SUCCESS) {
log_debug("%s worker: cond_init(state_changed) failed: %d\n",
worker2str(s), status);
status = BLADERF_ERR_UNEXPECTED;
goto worker_init_out;
}
status = pthread_cond_init(&s->worker->requests_pending, NULL);
if (status != 0) {
log_debug("%s worker: pthread_cond_init(requests_pending) failed: %d\n",
status = COND_INIT(&s->worker->requests_pending);
if (status != THREAD_SUCCESS) {
log_debug("%s worker: cond_init(requests_pending) failed: %d\n",
worker2str(s), status);
status = BLADERF_ERR_UNEXPECTED;
goto worker_init_out;
}
status = pthread_create(&s->worker->thread, NULL, sync_worker_task, s);
if (status != 0) {
log_debug("%s worker: pthread_create failed: %d\n", worker2str(s),
status = THREAD_CREATE(&s->worker->thread, sync_worker_task, s);
if (status != THREAD_SUCCESS) {
log_debug("%s worker: create failed: %d\n", worker2str(s),
status);
status = BLADERF_ERR_UNEXPECTED;
goto worker_init_out;
@ -274,7 +397,7 @@ worker_init_out:
}
void sync_worker_deinit(struct sync_worker *w,
pthread_mutex_t *lock, pthread_cond_t *cond)
MUTEX *lock, COND *cond)
{
int status;
@ -289,7 +412,7 @@ void sync_worker_deinit(struct sync_worker *w,
if (lock != NULL && cond != NULL) {
MUTEX_LOCK(lock);
pthread_cond_signal(cond);
COND_SIGNAL(cond);
MUTEX_UNLOCK(lock);
}
@ -297,10 +420,10 @@ void sync_worker_deinit(struct sync_worker *w,
if (status != 0) {
log_warning("Timed out while stopping worker. Canceling thread.\n");
pthread_cancel(w->thread);
THREAD_CANCEL(w->thread);
}
pthread_join(w->thread, NULL);
THREAD_JOIN(w->thread, NULL);
log_verbose("%s: Worker joined.\n", __FUNCTION__);
async_deinit_stream(w->stream);
@ -312,7 +435,7 @@ void sync_worker_submit_request(struct sync_worker *w, unsigned int request)
{
MUTEX_LOCK(&w->request_lock);
w->requests |= request;
pthread_cond_signal(&w->requests_pending);
COND_SIGNAL(&w->requests_pending);
MUTEX_UNLOCK(&w->request_lock);
}
@ -320,31 +443,14 @@ int sync_worker_wait_for_state(struct sync_worker *w, sync_worker_state state,
unsigned int timeout_ms)
{
int status = 0;
struct timespec timeout_abs;
const int nsec_per_sec = 1000 * 1000 * 1000;
if (timeout_ms != 0) {
const unsigned int timeout_sec = timeout_ms / 1000;
status = clock_gettime(CLOCK_REALTIME, &timeout_abs);
if (status != 0) {
return BLADERF_ERR_UNEXPECTED;
}
timeout_abs.tv_sec += timeout_sec;
timeout_abs.tv_nsec += (timeout_ms % 1000) * 1000 * 1000;
if (timeout_abs.tv_nsec >= nsec_per_sec) {
timeout_abs.tv_sec += timeout_abs.tv_nsec / nsec_per_sec;
timeout_abs.tv_nsec %= nsec_per_sec;
}
MUTEX_LOCK(&w->state_lock);
status = 0;
while (w->state != state && status == 0) {
status = pthread_cond_timedwait(&w->state_changed,
while (w->state != state && status == THREAD_SUCCESS) {
status = COND_TIMED_WAIT(&w->state_changed,
&w->state_lock,
&timeout_abs);
timeout_ms);
}
MUTEX_UNLOCK(&w->state_lock);
@ -352,7 +458,7 @@ int sync_worker_wait_for_state(struct sync_worker *w, sync_worker_state state,
MUTEX_LOCK(&w->state_lock);
while (w->state != state) {
log_verbose(": Waiting for state change, current = %d\n", w->state);
status = pthread_cond_wait(&w->state_changed,
status = COND_WAIT(&w->state_changed,
&w->state_lock);
}
MUTEX_UNLOCK(&w->state_lock);
@ -362,7 +468,7 @@ int sync_worker_wait_for_state(struct sync_worker *w, sync_worker_state state,
log_debug("%s: Wait on state change failed: %s\n",
__FUNCTION__, strerror(status));
if (status == ETIMEDOUT) {
if (status == THREAD_TIMEOUT) {
status = BLADERF_ERR_TIMEOUT;
} else {
status = BLADERF_ERR_UNEXPECTED;
@ -392,7 +498,7 @@ static void set_state(struct sync_worker *w, sync_worker_state state)
{
MUTEX_LOCK(&w->state_lock);
w->state = state;
pthread_cond_signal(&w->state_changed);
COND_SIGNAL(&w->state_changed);
MUTEX_UNLOCK(&w->state_lock);
}
@ -408,7 +514,7 @@ static sync_worker_state exec_idle_state(struct bladerf_sync *s)
while (s->worker->requests == 0) {
log_verbose("%s worker: Waiting for pending requests\n", worker2str(s));
pthread_cond_wait(&s->worker->requests_pending,
COND_WAIT(&s->worker->requests_pending,
&s->worker->request_lock);
}
@ -434,7 +540,7 @@ static sync_worker_state exec_idle_state(struct bladerf_sync *s)
}
}
pthread_cond_signal(&s->buf_mgmt.buf_ready);
COND_SIGNAL(&s->buf_mgmt.buf_ready);
} else {
s->buf_mgmt.prod_i = s->stream_config.num_xfers;
@ -445,6 +551,9 @@ static sync_worker_state exec_idle_state(struct bladerf_sync *s)
s->buf_mgmt.status[i] = SYNC_BUFFER_EMPTY;
}
}
sync_reset_sequence_tracking(&s->buf_mgmt,
s->stream_config.num_xfers);
}
MUTEX_UNLOCK(&s->buf_mgmt.lock);
@ -477,7 +586,7 @@ static void exec_running_state(struct bladerf_sync *s)
* the stream error code back to the API caller */
if (status != 0) {
MUTEX_LOCK(&s->buf_mgmt.lock);
pthread_cond_signal(&s->buf_mgmt.buf_ready);
COND_SIGNAL(&s->buf_mgmt.buf_ready);
MUTEX_UNLOCK(&s->buf_mgmt.lock);
}
}

View file

@ -22,7 +22,7 @@
#include "host_config.h"
#include "sync.h"
#include <libbladeRF.h>
#include <pthread.h>
#include "thread.h"
#if BLADERF_OS_WINDOWS || BLADERF_OS_OSX
#include "clock_gettime.h"
@ -49,7 +49,7 @@ typedef enum {
} sync_worker_state;
struct sync_worker {
pthread_t thread;
THREAD thread;
struct bladerf_stream *stream;
bladerf_stream_cb cb;
@ -58,7 +58,7 @@ struct sync_worker {
sync_worker_state state;
int err_code;
MUTEX state_lock;
pthread_cond_t state_changed; /* Worker thread uses this to inform a
COND state_changed; /* Worker thread uses this to inform a
* waiting main thread about a state
* change */
@ -66,7 +66,7 @@ struct sync_worker {
* the sync->buf_mgmt.lock
*/
unsigned int requests;
pthread_cond_t requests_pending;
COND requests_pending;
MUTEX request_lock;
};
@ -90,8 +90,8 @@ int sync_worker_init(struct bladerf_sync *s);
* workers.
*/
void sync_worker_deinit(struct sync_worker *w,
pthread_mutex_t *lock,
pthread_cond_t *cond);
MUTEX *lock,
COND *cond);
/**
* Wait for state change with optional timeout

View file

@ -5,6 +5,14 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/nuand/bladeRF
================================================================================
v1.1.0 (2025-05-06)
--------------------------------
* Add bladerf_image_type_to_string API binding
* Add missing RFIC_BIST loopback type
* Improve enum string handling and conversion functions
* Fix module default value handling in calibrate method
* Standardize version information handling
v1.0.5 (2021-10-04)
--------------------------------
* Update MATLAB binds to keep up with libbladeRF

View file

@ -611,6 +611,8 @@ fcns.thunkname{fcnNum}='int32voidPtrbladerf_pmic_registervoidPtrThunk';fcns.name
% int bladerf_get_rf_switch_config ( struct bladerf * dev , bladerf_rf_switch_config * config );
fcns.thunkname{fcnNum}='int32voidPtrvoidPtrThunk';fcns.name{fcnNum}='bladerf_get_rf_switch_config'; fcns.calltype{fcnNum}='Thunk'; fcns.LHS{fcnNum}='int32'; fcns.RHS{fcnNum}={'bladerfPtr', 'bladerf_rf_switch_configPtr'};fcnNum=fcnNum+1;
% const char* bladerf_image_type_to_string(bladerf_image_type type);
fcns.thunkname{fcnNum}='cstringint32Thunk';fcns.name{fcnNum}='bladerf_image_type_to_string'; fcns.calltype{fcnNum}='Thunk'; fcns.LHS{fcnNum}='cstring'; fcns.RHS{fcnNum}={'bladerf_image_type'};fcnNum=fcnNum+1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Structures
@ -887,6 +889,20 @@ enuminfo.bladerf_pmic_register=struct('BLADERF_PMIC_CONFIGURATION', 0, ...
enuminfo.bladerf_clock_select=struct('CLOCK_SELECT_ONBOARD', 0, ...
'CLOCK_SELECT_EXTERNAL', 1);
enuminfo.bladerf_image_type=struct('BLADERF_IMAGE_TYPE_INVALID', -1, ...
'BLADERF_IMAGE_TYPE_RAW', 0, ...
'BLADERF_IMAGE_TYPE_FIRMWARE', 1, ...
'BLADERF_IMAGE_TYPE_FPGA_40KLE', 2, ...
'BLADERF_IMAGE_TYPE_FPGA_115KLE', 3, ...
'BLADERF_IMAGE_TYPE_FPGA_A4', 4, ...
'BLADERF_IMAGE_TYPE_FPGA_A9', 5, ...
'BLADERF_IMAGE_TYPE_CALIBRATION', 6, ...
'BLADERF_IMAGE_TYPE_RX_DC_CAL', 7, ...
'BLADERF_IMAGE_TYPE_TX_DC_CAL', 8, ...
'BLADERF_IMAGE_TYPE_RX_IQ_CAL', 9, ...
'BLADERF_IMAGE_TYPE_TX_IQ_CAL', 10, ...
'BLADERF_IMAGE_TYPE_FPGA_A5', 11, ...
'BLADERF_IMAGE_TYPE_GAIN_CAL', 12);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output

View file

@ -5,6 +5,27 @@ For more detailed information, please see the git change log and issue tracker
hosted on GitHub: https://github.com/nuand/bladeRF
================================================================================
v1.4.0 (2025-05-06)
--------------------------------
* add support for SC16_Q11_META format
* update Python binding definitions
v1.3.0 (2023-02-13)
--------------------------------
* add special case for loading Windows DLL in Python bindings
* update Python bindings definitions
v1.2.1 (2021-10-04)
--------------------------------
* add bladeRF 2.0 micro xA5 support
* fix get_gain_modes and get_*_range functions
* fix Python binding compatibility issue on macOS
v1.2.0 (2019-07-31)
--------------------------------
* add OTP functions
* update FPGA flash type definitions
v1.1.2 (2020-12-23)
--------------------------------
* update definitions for libbladeRF v2.4.0

View file

@ -19,7 +19,7 @@ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
setup(
name='bladerf',
version='1.3.0',
version='1.4.0',
description='CFFI-based Python 3 binding to libbladeRF',
long_description=long_description,
url='https://github.com/Nuand/bladeRF',

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.10...3.27)
add_subdirectory(test_async)
add_subdirectory(test_bootloader_recovery)
@ -10,6 +10,7 @@ add_subdirectory(test_ctrl)
add_subdirectory(test_freq_hop)
add_subdirectory(test_fw_check)
add_subdirectory(test_open)
add_subdirectory(test_oversample)
add_subdirectory(test_packet)
add_subdirectory(test_parse)
add_subdirectory(test_peripheral_timing)

View file

@ -1,15 +1,15 @@
contourpy==1.1.0
cycler==0.11.0
fonttools==4.43.0
kiwisolver==1.4.5
matplotlib==3.7.2
numpy==1.25.2
packaging==23.1
pandas==2.0.3
Pillow==10.3.0
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2023.3
scipy==1.11.2
six==1.16.0
tzdata==2023.3
contourpy>=1.1.1
cycler==0.12.1
fonttools==4.56.0
kiwisolver>=1.4.7
matplotlib>=3.7.5
numpy>=1.24.4
packaging==24.2
pandas>=2.0.3
pillow>=10.4.0
pyparsing>=3.1.4
python-dateutil==2.9.0.post0
pytz==2025.1
scipy>=1.8.0
six==1.17.0
tzdata==2025.1

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_async C)
set(INCLUDES

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_bootloader_recovery C)
set(INCLUDES

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_c C)
set(INCLUDES ${libbladeRF_SOURCE_DIR}/include)

View file

@ -1,12 +1,16 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_clock_select C)
set(INCLUDES ${libbladeRF_SOURCE_DIR}/include)
set(INCLUDES ${libbladeRF_SOURCE_DIR}/include ${BLADERF_HOST_COMMON_INCLUDE_DIRS})
set(SRC src/main.c)
if(MSVC)
set(SRC ${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c
)
set(INCLUDES ${INCLUDES} ${MSVC_C99_INCLUDES})
endif()
include_directories(${INCLUDES} ${CURL_INCLUDE_DIR} include)
add_executable(${PROJECT_NAME} src/main.c)
include_directories(${INCLUDES} include)
add_executable(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME} libbladerf_shared)

View file

@ -27,8 +27,10 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include "getopt.h"
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h>
#endif
#include <time.h>
#include <signal.h>
#include "libbladeRF.h"
@ -173,7 +175,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "Attempting to reopen device...\n");
bladerf_close(dev);
dev = NULL;
sleep(3);
/* Wait for device to be ready */
#ifdef _WIN32
Sleep(3000); // Windows uses milliseconds
#else
sleep(3); // Unix uses seconds
#endif
CHECK_STATUS(bladerf_open(&dev, device_string));
}

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_config_file C)
set(TEST_CONFIG_FILE_INCLUDES
@ -34,21 +34,15 @@ set(SRC
set(TEST_CONFIG_FILE_LIBS libbladerf_shared)
if(MSVC)
find_package(LibPThreadsWin32 REQUIRED)
set(TEST_CONFIG_FILE_INCLUDES
${TEST_CONFIG_FILE_INCLUDES}
${MSVC_C99_INCLUDES}
${LIBPTHREADSWIN32_INCLUDE_DIRS}
)
set(SRC
${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/clock_gettime.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/mkdtemp.c
)
set(TEST_CONFIG_FILE_LIBS
${TEST_CONFIG_FILE_LIBS}
${LIBPTHREADSWIN32_LIBRARIES}
)
endif()
add_definitions(-DLIBBLADERF_SEARCH_PREFIX="${CMAKE_INSTALL_PREFIX}")

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_cpp CXX)
include_directories(${libbladeRF_SOURCE_DIR}/include)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_ctrl C)
set(INCLUDES
@ -13,14 +13,10 @@ endif()
set(LIBS libbladerf_shared)
if(MSVC)
find_package(LibPThreadsWin32 REQUIRED)
set(INCLUDES ${INCLUDES} ${LIBPTHREADSWIN32_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
else(MSVC)
if(NOT MSVC)
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif(MSVC)
endif(NOT MSVC)
set(SRC
src/main.c

View file

@ -27,15 +27,15 @@
* while concurrently runing full duplex streams via the sync interface */
#include "test_ctrl.h"
#include <pthread.h>
#include "thread.h"
DECLARE_TEST_CASE(threads);
struct sync_task {
struct bladerf *dev;
bladerf_direction direction;
pthread_t thread;
pthread_mutex_t lock;
THREAD thread;
MUTEX lock;
bool launched;
bool run;
int status;
@ -53,7 +53,7 @@ struct thread_state {
struct app_params *p;
failure_count failures;
struct thread_test_case const *tc;
pthread_t thread;
THREAD thread;
};
static const struct thread_test_case tc[] = {
@ -69,9 +69,9 @@ static const struct thread_test_case tc[] = {
static inline void get_sync_task_state(struct sync_task *t, bool *run)
{
pthread_mutex_lock(&t->lock);
MUTEX_LOCK(&t->lock);
*run = t->run;
pthread_mutex_unlock(&t->lock);
MUTEX_UNLOCK(&t->lock);
}
static void *stream_task(void *arg)
@ -129,9 +129,9 @@ out:
}
free(samples);
pthread_mutex_lock(&t->lock);
MUTEX_LOCK(&t->lock);
t->status = status;
pthread_mutex_unlock(&t->lock);
MUTEX_UNLOCK(&t->lock);
return NULL;
}
@ -144,15 +144,15 @@ static void init_task(struct sync_task *t,
t->run = true;
t->status = 0;
t->direction = dir;
pthread_mutex_init(&t->lock, NULL);
MUTEX_INIT(&t->lock);
}
static int launch_task(struct sync_task *t)
{
int status;
status = pthread_create(&t->thread, NULL, stream_task, t);
if (0 == status) {
status = THREAD_CREATE(&t->thread, stream_task, t);
if (THREAD_SUCCESS == status) {
t->launched = true;
}
@ -162,10 +162,10 @@ static int launch_task(struct sync_task *t)
static inline int deinit_task(struct sync_task *t)
{
if (t->launched) {
pthread_mutex_lock(&t->lock);
MUTEX_LOCK(&t->lock);
t->run = false;
pthread_mutex_unlock(&t->lock);
pthread_join(t->thread, NULL);
MUTEX_UNLOCK(&t->lock);
THREAD_JOIN(t->thread, NULL);
return t->status;
} else {
return 0;
@ -257,9 +257,9 @@ failure_count test_threads(struct bladerf *dev, struct app_params *p, bool quiet
}
status =
pthread_create(&threads[i].thread, NULL, run_test_fn, &threads[i]);
THREAD_CREATE(&threads[i].thread, run_test_fn, &threads[i]);
if (0 == status) {
if (THREAD_SUCCESS == status) {
PRINT(" Started test_%s thread...\n", threads[i].tc->test->name);
threads[i].launched = true;
} else {
@ -271,7 +271,7 @@ failure_count test_threads(struct bladerf *dev, struct app_params *p, bool quiet
for (i = 0; i < num_threads; i++) {
if (threads[i].launched) {
pthread_join(threads[i].thread, NULL);
THREAD_JOIN(threads[i].thread, NULL);
PRINT("\n Joined test_%s thread.\n", threads[i].tc->test->name);
failures += threads[i].failures;
}

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_digital_loopback C)
set(INCLUDES
@ -14,14 +14,10 @@ endif()
set(LIBS libbladerf_shared)
if(MSVC)
find_package(LibPThreadsWin32 REQUIRED)
set(INCLUDES ${INCLUDES} ${LIBPTHREADSWIN32_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
else(MSVC)
if(NOT MSVC)
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif(MSVC)
endif(NOT MSVC)
add_definitions(-DLOGGING_ENABLED=1)

View file

@ -29,13 +29,12 @@
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include "conversions.h"
#include "log.h"
#include "test_common.h"
#include <libbladeRF.h>
#include "async.h"
#include "thread.h"
/******************************************************************************
* Type definitions
@ -453,7 +452,7 @@ int main(int argc, char *argv[])
struct rx_buffer_state rx_state;
struct tx_buffer_state tx_state;
struct bladerf_stream *rx_stream, *tx_stream;
pthread_t rx_thread, tx_thread;
THREAD rx_thread, tx_thread;
bladerf_log_level level;
int status;
bool ok;
@ -716,9 +715,9 @@ int main(int argc, char *argv[])
goto error;
}
status = pthread_create(&tx_thread, NULL, tx_streamer, tx_stream);
if (status < 0) {
log_error("pthread_create(TX): %s\n", strerror(status));
status = THREAD_CREATE(&tx_thread, tx_streamer, tx_stream);
if (status != THREAD_SUCCESS) {
log_error("THREAD_CREATE(TX): %s\n", strerror(status));
goto error;
}
@ -728,16 +727,16 @@ int main(int argc, char *argv[])
goto error;
}
status = pthread_create(&rx_thread, NULL, rx_streamer, rx_stream);
if (status < 0) {
log_error("pthread_create(RX): %s\n", strerror(status));
status = THREAD_CREATE(&rx_thread, rx_streamer, rx_stream);
if (status != THREAD_SUCCESS) {
log_error("THREAD_CREATE(RX): %s\n", strerror(status));
goto error;
}
log_info("Loopback test running. Press Ctrl-C to exit...\n");
pthread_join(tx_thread, NULL);
pthread_join(rx_thread, NULL);
THREAD_JOIN(tx_thread, NULL);
THREAD_JOIN(rx_thread, NULL);
log_info("IQ Matches: %zu / %zu (%.1f%%)\n", good_count,
good_count + bad_count,

View file

@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_fpga_load C)
set(INCLUDES ${libbladeRF_SOURCE_DIR}/include)
set(INCLUDES ${libbladeRF_SOURCE_DIR}/include ${BLADERF_HOST_COMMON_INCLUDE_DIRS})
set(SRC src/main.c)
if(MSVC)
set(INCLUDES ${INCLUDES} ${MSVC_C99_INCLUDES})
set(SRC ${SRC} ${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c)
endif()
include_directories(${INCLUDES} ${CURL_INCLUDE_DIR} include)
add_executable(${PROJECT_NAME} src/main.c)
include_directories(${INCLUDES} include)
add_executable(${PROJECT_NAME} ${SRC})
target_link_libraries(${PROJECT_NAME} libbladerf_shared)

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_freq_hop C)
set(INCLUDES
@ -11,9 +11,6 @@ set(LIBS libbladerf_shared)
if(MSVC)
set(INCLUDES ${INCLUDES} ${MSVC_C99_INCLUDES})
find_package(LibPThreadsWin32 REQUIRED)
set(INCLUDES ${INCLUDES} ${LIBPTHREADSWIN32_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
endif()
set(SRC

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_fw_check C)
set(INCLUDES
@ -19,14 +19,10 @@ else()
add_definitions(-DLIBBLADERF_SEARCH_PREFIX="${CMAKE_INSTALL_PREFIX}")
endif()
if(MSVC)
find_package(LibPThreadsWin32 REQUIRED)
set(INCLUDES ${INCLUDES} ${LIBPTHREADSWIN32_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBPTHREADSWIN32_LIBRARIES})
else(MSVC)
if(NOT MSVC)
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif(MSVC)
endif(NOT MSVC)
set(SRC
src/main.c

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_gain_calibration C)
set(INCLUDES
@ -8,6 +8,11 @@ set(INCLUDES
${BLADERF_HOST_COMMON_INCLUDE_DIRS}
)
set(LIBS libbladerf_shared)
if(NOT MSVC)
set(LIBS ${LIBS} m)
endif()
if(LIBBLADERF_SEARCH_PREFIX_OVERRIDE)
add_definitions(-DLIBBLADERF_SEARCH_PREFIX="${LIBBLADERF_SEARCH_PREFIX_OVERRIDE}")
else()
@ -23,7 +28,7 @@ set(SRC
include_directories(${INCLUDES})
add_executable(libbladeRF_test_gain_calibration ${SRC})
target_link_libraries(libbladeRF_test_gain_calibration libbladerf_shared m)
target_link_libraries(libbladeRF_test_gain_calibration ${LIBS})
configure_file(example_measurements/rx_sweep_0.csv
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/rx_sweep_0.csv

View file

@ -20,10 +20,12 @@
*/
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include "host_config.h"
#include <string.h>
#include "libbladeRF.h"
#ifndef F_OK
#define F_OK 0
#endif
int read_and_print_binary(const char *binary_path) {
uint64_t frequency;
float power;

View file

@ -20,7 +20,10 @@
*/
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#ifdef __WIN32
#include <io.h>
#endif
#include "host_config.h"
#include "libbladeRF.h"
#include "file_operations.h"

View file

@ -1,23 +1,24 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_gain_compare C)
set(INCLUDES
${libbladeRF_SOURCE_DIR}/include
${BLADERF_HOST_COMMON_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../common/include
${CMAKE_CURRENT_SOURCE_DIR}/../../libbladeRF/src/streaming
)
set(LIBS libbladerf_shared)
if(MSVC)
set(INCLUDES ${INCLUDES} ${MSVC_C99_INCLUDES})
endif()
add_definitions(-DLOGGING_ENABLED=1)
set(SRC
src/main.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c
${BLADERF_HOST_COMMON_SOURCE_DIR}/log.c
)
set(SRC src/main.c ${BLADERF_HOST_COMMON_SOURCE_DIR}/conversions.c)
if(MSVC)
set(SRC ${SRC}
${BLADERF_HOST_COMMON_SOURCE_DIR}/windows/getopt_long.c
)
endif()
include_directories(${INCLUDES})
add_executable(libbladeRF_test_gain_compare ${SRC})
target_link_libraries(libbladeRF_test_gain_compare ${LIBS})
target_link_libraries(libbladeRF_test_gain_compare libbladerf_shared)

View file

@ -5,7 +5,7 @@ kiwisolver==1.4.5
matplotlib==3.8.0
numpy==1.26.0
packaging==23.2
Pillow==10.0.1
Pillow==11.3.0
pyparsing==3.1.1
python-dateutil==2.8.2
six==1.16.0

View file

@ -1,7 +1,7 @@
#include <stdio.h>
#include <inttypes.h>
#include <libbladeRF.h>
#include <unistd.h>
#include "host_config.h"
#include "log.h"
#define CHECK(func_call) do { \

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10...3.27)
project(libbladeRF_test_interleaver C)
set(INCLUDES

Some files were not shown because too many files have changed in this diff Show more