This adds a bladerf_get_fpga_bytes() function, which returns the
expected length of the FPGA image.
This is a dynamic replacement for BLADERF_FLASH_BYTE_LEN_FPGA,
which has been removed.
In particular, this is used in spi_flash_write_fpga_bitstream() and
spi_flash_erase_fpga() to determine the number of blocks to erase
during FPGA flashing operations.
This fixes an issue where xA9 boards were not being adequately
erased before writing.
Replaced these macros with appropriate calculations using
BLADERF_FLASH_ADDR_FIRMWARE and the page size held in the device's flash
architecture structure. Page size may change depending on the flash
used.
Replaced this macro with an appropriate calculation using the
BLADERF_FLASH_ADDR_FPGA macro and the page size held in the device's
flash architecture structure. Page size may change depending on the
flash used.
API change:
- bladerf_image_write(): new parameter: bladeRF device handle
Change is inspired by the pending removal of BLADERF_FLASH_EB_SIZE
macro. This macro really shouldn't be exposed to the world, nor
should it be constant as it may change depending on the flash
used on the board.
API new function:
- bladerf_erase_flash_bytes(): new function
Similar to the existing bladerf_erase_flash() function, but
handles the conversion from bytes to flash erase block pages
internally. This function is recommended for new designs because
the erase block size may change depending on the board. This
function also checks for proper alignment along erase block
boundaries.
General changes:
Although the macro still exists (for now), all uses of
BLADERF_FLASH_EB_SIZE have been replaced with equivalent
dev->flash_arch->ebsize_bytes because the value may change depending
on the flash used on the board.
New API functions:
- bladerf_read_flash_bytes()
This function is nearly identical to the existing
bladerf_read_flash() function, but takes the address and length in
units of bytes instead of flash pages. The function performs the
necessary conversions from bytes to pages internally based on the
specific flash architecture in use.
- bladerf_write_flash_bytes()
Same as above, for writes.
New code is advised to use these byte-unit functions instead of the
older page-unit functions because the page size may not be guaranteed to
be 256 bytes in future bladeRF platforms.
The BLADERF_FLASH_NUM_EBS macro was replaced with data from the device's
flash architecture structure (e.g. dev->flash_arch->num_ebs).
Functions with new parameters include:
- spi_flash.c: check_eb_access() - bladeRF device handle
The BLADERF_FLASH_NUM_PAGES macro was replaced with data from the
device's flash architecture structure (e.g. dev->flash_arch->num_pages).
Functions with new parameters include:
- spi_flash.c: check_page_access() - bladeRF device handle
API changes:
- bladerf_alloc_image(): new parameter - bladeRF device handle
- bladerf_alloc_cal_image(): new parameter - bladeRF device handle
General changes:
Although the macro still exists (for now), all uses of the
BLADERF_FLASH_TOTAL_SIZE macro have been replaced with equivalent
dev->flash_arch->tsize_bytes because the value may change depending on
teh flash used on the board.
During this process, some function prototypes were modified so the
device handle could be passed in, thus allowing flash architecture
data to be extracted.
- calibration.c: dc_cal_tbl_image_load()
- image.c: is_valid_addr_len()
General documentation cleanup, function name adjustments, merging of
redundant structures, etc.
fpga_common/ad936x_helpers:
Contains wrappers for AD936x RFIC functionality.
fpga_common/bladerf2_common:
Contains bladeRF2-specific helper functions and constants.
fpga_common/ad936x_params:
Reformat (no more tabs, phew)
Move ina219 shunt const to bladerf2_common
host/common/range:
Move functions and macros for handling bladerf_range structs
../libbladeRF/include/bladeRF2.h:
Explicitly index RX/TX FIR enums
Update references to ad936x_params.c
../libbladeRF/src/board/bladerf2/common:
New macros for boilerplate:
- WITH_MUTEX: wrap around locked blocks
- CHECK_STATUS: calls function, checks return code
- CHECK_AD936X: calls function, checks return code, translates
from AD936x to libbladeRF error codes
- CHECK_*_LOCKED: above, but unlocks mutex before erroring
- NULL_CHECK: checks a var for null
Move helper functions into here
../libbladeRF/src/board/bladerf2/bladerf2.c:
Use new macros
Code style fixes
Remove redundant code
A few changes to the bladerf_quick_tune structure:
- rename 'profile' to 'rffe_profile' for clarity
- delete 'data[16]' not needed anymore and preserves ABI compatibility
- add 'nios_profile' for indexing the profile stored in the BBP
- add 'port' for storing the RFFE port settings
- add 'spdt' for storing the external RF switch settings
Improvements to bladerf2_get_quick_tune():
- Send rffe_fastlock_save packet to instruct Nios to save a copy of
the RFFE fast lock profile to itself. This means the fast lock
profile data (16 bytes) no longer needs to be transmitted to/from
the Nios and the host machine (retune speedup).
- Save the RFFE port setting to the quick tune structure so it may be
sent down to the Nios when scheduling a retune.
Saving the 16-bytes of fast lock profile data to the host is no longer
necessary because it is stored on the Nios itself. This has two
additional benefits: quicker retunes (the profile data does not need to
be shuffled across USB), and it preserves ABI compatibility because the
size of the bladerf_quick_tune struct does not increase compared to
previous versions of libbladeRF.
Update bladerf_quick_tune structure for bladeRF2 data. It now contains:
- profile (profile number, integer)
- data (profile data, 16 bytes)
Fill in the bladerf2_get_quick_tune() function. The bladeRF2's RFIC uses
the concept of fast lock profiles, of which there are 8 for TX and 8 for
RX. These profiles store the VCO information needed to quickly change
frequencies. To use more than 8 profiles, the profiles may be stored
off-chip, which is what we're doing here.
1. It is assumed the RFIC has been tuned to a particular frequency.
2. The profile is created using ad9361_fastlock_store().
3. The profile is read back and stored in host memory using
ad9361_fastlock_save().
Adds a new API call, bladerf_get_fpga_source(), which queries
the firmware for the source of the most recent FPGA programming.
This requires firmware v2.3.1 or later. Using an older firmware
will result in BLADERF_ERR_UNSUPPORTED.
This adds two new values for the bladerf_trigger_signal enum,
BLADERF_TRIGGER_J51_1 and BLADERF_TRIGGER_MINI_EXP_1, as well
as the necessary backend processing to make them work.
It turns out that it doesn't actually matter which one is chosen;
they all behave identically and interchangeably once they're passed
to the Nios interface functions.
The reason for this change is to reduce confusion, as the bladeRF
x40/x115 use J71-4 for mini_exp[1] and the bladeRF xA4/xA9 use
J51-1.
bladerf_open() will retrieve the SPI flash ID information from
the FX3 and decode it to get the flash density, page size, and other
architectural information required for flash interaction.
If the FX3 firmware does not support flash ID readback, assumptions will
be made based on the FPGA size. If FPGA size is not available, sane
defaults will be used. This should be sufficient to read calibration and
other important data from flash for board operation. Flashing an FPGA,
however, may not work depending on the device specifics.
Adds a bladerf_get_serial_struct function, which is similar
in functionality to bladerf_get_serial, but instead of requiring
a user-supplied buffer of at least BLADERF_SERIAL_LENGTH bytes,
it expects a pointer to a struct bladerf_serial which itself has
a buffer of BLADERF_SERIAL_LENGTH bytes as a member.
This turns BLADERF_SERIAL_LENGTH into an API-internal value,
instead of something that API users have to be intently aware of.
Fixes#382
Adds 'manufacturer' and 'product' members to the
bladerf_devinfo struct, and ensures they are properly
initialized and populated during enumeration.
These contain the human-readable manufacturer and
product names from the USB device descriptor.
Adds new format macros for displaying bladerf_frequency and
bladerf_timestamp values to libbladeRF.h.
Transitions bladerf1.c and bladerf2.c to use these new macros,
and also cleans up a few more places where the typedefs aren't
currently used.
Also fixes a doxygen warning for undocumented #defines in
bladeRF2.h.
Fixes#577Fixes#618Fixes#620
* Revert "bladeRF-cli: ensure device is initialized after deferred open"
This reverts commit 5ed03a3b01.
* Revert "bladeRF-cli: print product string where relevant"
This reverts commit 2ccd6e3d5e.
* Revert "libbladeRF: add 'product' string to devinfo"
This reverts commit 11a71d835a.
* Revert "bladeRF-cli: update print/sets to use typedefs"
This reverts commit a4b176c516.
* Revert "libbladeRF: add format macros for frequency, timestamp"
This reverts commit 1cf6a7871c.
Adds a 'product' member to the bladerf_devinfo struct, and
populates it during device enumeration.
This will contain a human-readable description of the found
device, built from the USB Manufacturer and Product strings.
Adds new format macros for displaying bladerf_frequency and
bladerf_timestamp values to libbladeRF.h.
Transitions bladerf1.c and bladerf2.c to use these new macros,
and also cleans up a few more places where the typedefs aren't
currently used.
These settings generally don't need to be manually adjusted,
because higher-level functions (e.g. bladerf_set_frequency)
handle the setup in coordination with the rest of the RF
hardware (e.g. via bladerf_get_rf_switch_config).
Fixes#607
The nios_gpio bit assignment for AGC_EN was already being used for
led(1). This commit also fixes a bug in the agc_band_sel signal
assignment introduced in 3b670ca.