Commit graph

52 commits

Author SHA1 Message Date
Jon Szymaniak
fabc0e89ac libbladeRF: Specified calling convention for Windows and removed unneeded externs
Misc. reformatting and a few doxygen touchups also included.
2013-12-05 23:51:48 -05:00
Jon Szymaniak
0ab08662c0 libbladeRF: Typo fix in API header 2013-11-28 15:40:49 -05:00
Jon Szymaniak
30997a9f61 libbladeRF, bladeRF-cli: Reworked cal data generation and misc cleanup
The function to create cal data now is a wrapper around
bladerf_alloc_image() which initializes the returned image with
calibration data.

The associated CLI command now allows this to be either written to a
file or to the device directly.

API header cleanup: Pushed the lower level functions to to the end of
the header, so the functions people will use more frequently will be at
the top of the generated documentation.

Also added a missing API_EXPORT and made the Doxygen color scheme a little
more blue. (Tired of grayscale ;) )

Windows cleanup: Added get_timestamp() implementation, cleaned up
warnings, address some portability issues.
2013-11-28 14:14:38 -05:00
Jon Szymaniak
11c84b023d libbladeRF: Fixed length of FPGA region of flash in API header 2013-11-28 14:08:13 -05:00
Jon Szymaniak
ad3faf9dd7 bladeRF-cli: Added flash_image command and alphabetized commands 2013-11-28 14:07:49 -05:00
Jon Szymaniak
fd7af2edc6 libbladeRF, bladeRF-cli: Simplified flash image format and handling
These changes simplify the image format a bit; the metadata fields are
flattened into the image to simplify both image creation and manually
viewing/extracting contents from images.

The checksum has been moved to directly after the file format's magic
value (i.e., signature), to make it a bit easier to just extract data
via dd. Similar to the approach used by mkimage for U-Boot headers,
the checksum calculation is performed over the entire image, with the
checksum field zeroed out.

Touched up CLI backup/restore commands and separated <address>
and <length> to separate args.
2013-11-28 14:05:54 -05:00
Daniel Gröber
bb0128e15e libbladeRF: Supporting changes for backup/restore of flash
- Verify flash pages as they are written
- Add function for initializing the calibration region in flash
- Add functions to read/write flash images with sha256 and metadata
- Add support for unaligned read/program
2013-11-28 13:58:08 -05:00
Jon Szymaniak
dafcd5f55e libbladeRF: Removed prototype for removed function. 2013-11-08 19:56:09 -05:00
Jon Szymaniak
625694eaa5 license: License changes on various portions of the codebase
Where possible (and with contributor permission), items have been
changed to LGPLv2.1 or MIT licenses to avoid issues with any proprietary
libraries from vendors (HDL and FW), allow static linking (with headless
mode operation in mind), and to generally present users with more
permissive licenses.

File headers and the COPYING have been updated accordingly. Third party
sources have been either removed, replaced, or relocated in the source
tree, in accordance with the licenses decided upon for each part of the tree.

Contributor Assignment Agreements have been added, and it is required
that these be submitted before significant patches and pull requests
are accepted.
2013-10-27 00:17:35 -04:00
Jon Szymaniak
7a1b2c1462 common, libbladeRF: log.c support can be disabled at compile-time
CMake option added to disable log.c for libbladeRF. Adjustments made
to other files as needed to address warnings (becoming errors via
-Werror and /Wx).

Removed return values for log-related functions, as these were unused
and made it slightly more annoying to make this change. The libbladeRF
minor version has been bumped to note this change in the currently
unstable series v0.x.x series.
2013-10-21 22:44:59 -04:00
Jon Szymaniak
8c057b61fa libbladeRF, utils: Moving ezusb code out of lib into utils
With future license-related cleanup, all GPLv2 programs will live
in the utilities directory. As such, ezusb.c has been moved out
of the library, and the bladeRF-cli utility has been modified to
use this directly.
2013-10-21 21:05:17 -04:00
Robert Ghilduta
c901555061 libbladeRF: add the ability to specify transfer timeout value 2013-10-16 23:49:11 -07:00
Jon Szymaniak
dce050890d bladeRF-cli: rx/tx now use async interface, libbladeRF: USB dev speed API call
The rx and tx CLI commands now use the asynchronous stream interface to
yield more acceptable performance, and this code has been overhauled for
better readability. Command parameters have been added to allow for
configuration of the stream.

Although a bit overzealous, as "lock it if you use it" approach is taken
here. Optimizations may follow later..

Some rx/tx parameters now support K/M/G suffixes, where relevant.

To support sample rate sanity checks, an API function to check the
current USB speed has been added to libbladeRF. This speed is now
reported in the CLI 'info' command.
2013-10-14 22:42:19 -04:00
Jon Szymaniak
755bd6aca9 libbladeRF, bladeRF-cli: Added support for retrieving USB device speed
Exposed API function and updated struct bladerf and both backends to
use the new enum.

Cleaned up warnings and unneccesary items in the API header.
2013-10-13 20:34:43 -04:00
Daniel Gröber
89a05274e2 Merge master into dev-flash-addressing (using imerge) 2013-10-09 12:21:37 +02:00
Robert Ghilduta
37df2984e1 libbladeRF: add FPGA flash autoload functionality
This commit adds the command line and libbladeRF support for flashing an image
to flash so that the bladeRF will auto-load the image when it boots. An rbf can
be loaded by running `bladeRF-cli -H ./hostedx40.rbf`. This will cause the FX3
firmware to load the FPGA image from flash the next time the unit boots, this
should not cause any problems reprogramming the device after it's already
loaded. To disable the auto-load feature after enabling it run
`bladeRF-cli -H X`, this destroys the FPGA image stored in flash.
2013-10-09 01:11:08 -07:00
Jon Szymaniak
ab36a93813 libbbladeRF, utilities: Migrating to major.minor.patch for version #'s
The API now presents a version structure that includes major, minor, and
patch versions. It additionally provides a "describe" string which
includes these version items in a string format, with any additional
annotations (such as git revision and dirty flag).

This changeset removes the older version functions, breaking reverse
compatibility (intentionally). Bumped minor version to reflect this change.
(The 0.Y.Z series is considered unstable at this time.)
2013-10-03 22:50:43 -04:00
Brian Padalino
0b4c95b90d Added FX3 Version String
[fx3]: Use CMake to make a version string which is populated at runtime that is
very similar to the git version strings for the library and CLI.

[libbladeRF]: Added a an API call to get the string representation of the
firmware.  Errors getting this string will result in '?' being populated in the
returned string.

[cli]: Added a firmware string which is printed under the actual string itself.
2013-10-03 22:47:33 -04:00
Ryan Tucker
66536f2d5d Update cmake_minimum_required to 2.8.3 for host/
Resolves issue #123

host/CMakeLists.txt uses CMAKE_CURRENT_LIST_DIR, which does not exist
before 2.8.3.  Updating this to avoid obscure build errors on old
machines.

Also adding a few missing cmake_minimum_required directives to avoid
a warning that likes to pop up when they're missing.
2013-09-29 12:54:25 -04:00
Daniel Gröber
6c81a46ac0 libbladeRF: Change addressing of flash access functions to bytes 2013-09-27 03:11:31 +02:00
Jon Szymaniak
9015bdbb5c libbladeRF, bladeRF-flash: Added device identifier info matching to API routines
Initializing, extracting, and comparing device identifier information
(struct bladerf_devinfo) is now exposed through the API. Among other
things, this allow users to check if a device specifier string matches a
device they already have a handle for.

To support this, a copy of bladerf_devinfo information is now kept around in
the device handle; backends are responsible for populating this in their
open() implementation. A couple of the fields were already present, so
this only adds a couple small variables worth of overhead.

Some re-arranging of the linux and libusb probe and open calls has been done
to achieve this. A few warnings and bugs were addressed in this process:

  - The Linux backend was attempting to fill in a serial number via
    a cached entry.

  - There was some potential for a read of an uninitialized portion
    of an otp buffer.

  - Missing serial # has been made non-fatal. (Some developers'
    device do not have serial numbers.)

Files associated with this functionality was moved from host/common
back into the library, which should now be used instead. bladeRF-flash
has been updated to use these new API functions.
2013-09-18 23:15:48 -04:00
Keith Rothman
d36f91cb7d Initial JUMP_TO_BOOTLOADER support
- Added method to libbladeRF
 - Added new VID/PID pair to udev rule to prevent requiring root access
 - Added jump_to_boot bladeRF-cli command
 - Fixed most warnings in FX3 firmware
2013-09-15 05:32:04 +00:00
Keith Rothman
1c4fa232eb [libbladeRF/bladeRF-cli] Added support booting directly from the FX3 bootloader 2013-09-15 05:31:57 +00:00
Keith Rothman
ee37214898 [libbladeRF] Exposed erase/read/write functions 2013-09-15 04:59:03 +00:00
Jon Szymaniak
354625e809 libbladeRF: Clarified a few items in the header documentation. 2013-09-14 18:02:27 -04:00
Jon Szymaniak
ce2367c562 libbladeRF: Cleaned up a few minor Doxygen warnings 2013-09-14 17:39:43 -04:00
Jon Szymaniak
6819369b61 libbladeRF: bladerf_load_fpga no longer checks current FPGA status
This check was only being used to print an informational message.
However, it was supposed to be used to change the return value to
indicate the FPGA being re-loaded versus loaded.

Because the caller can check the FPGA state via
bladerf_is_fpga_configured(), this check has been pulled out, and the
interface now specifies that this functions return value only indicates
success (0) or failure (error code).
2013-09-14 17:14:47 -04:00
Brian Padalino
46eacaa462 libbladeRF: si5338 refactored to support fractional sample rates. 2013-09-14 16:52:59 -04:00
Jon Szymaniak
2dcae9eeb2 libbladeRF & common: Renamed logging routines to address conflicts
The common logging functions have been renamed in order to not
conflict with the library's bladerf_log_set_verbosity().
2013-09-11 00:29:14 -04:00
Adam Greig
38273dcd8a libbladeRF: Add bladerf_set/get_lpf_mode
Add functions to bypass and disable the LPF and check whether it is currently
bypassed or disabled.
2013-09-09 03:55:03 +01:00
Jon Szymaniak
56693c0675 libbladeRF: Changed bladerf_stream parameters, refactored stream init
Parameters have been removed from the bladerf_stream() call, because
these parameters would already have been associated with the provided
stream via the bladerf_init_stream() call.

A backend stream_init() has been added, and libusb transfer
initialization has been moved into the implementation of this
backend-specific function.  This is required to ensure that
bladerf_deinit() stream can be called directly after
bladerf_init_stream(), without a call to bladerf_stream().  Such
a use case might occur if an error was detected before kicking off the
stream.
2013-09-05 00:06:14 -04:00
Jon Szymaniak
985a8a4548 libbladeRF: Added API_EXPORT for API routines. 2013-09-03 00:02:58 -04:00
Frank Jenner
3655b3d516 Added variable-level logging mechanism
Added a mechanism to log messages with different priority levels, and to
filter which messages are output by setting a threshold level. The
function to set the current log level/verbosity is exposed through
libbladeRF.h, while the logging function/macros themselves are private
to this project, and are present in log.c/log.h. Callers should use the
convenience macros bladerf_log_[level]() to issue their log messages.
These macros piece together a format string that contains the message
priority and, for warning and higher priorities, the function and line
number on which the message was logged. Also, warning level and higher
level messages are output to stderr, rather than stdout.
2013-09-02 15:39:41 -04:00
Brian Padalino
826b5888fe libbladeRF: First stab at DC offset calibration.
Some users have shown large DC offsets.  I've seen these offsets
initially but they become much more reasonable after the first
few sample buffers come out of the FPGA.

Currently DC offset appears to be +/-30 or so after running
the calibration.

In the cli, run 'cal' to run through all modules of calibration.
2013-09-01 15:57:15 -04:00
Brian Padalino
4d8312b59b libbladeRF: Add API to change the ADC sampling location.
The ADC can be configured to sample from the internal inputs
or from the external pins.  Adding the API to change the sampling
between internal and external.  Also using the appropriate API
function for the CLI.
2013-08-28 23:48:53 -04:00
Jon Szymaniak
b82952687e libbladeRF: Cleaned up a few items and issues in OTP/cal readback.
This addresses some invalid accesses reported by valgrind. However, a few issues remain:
  - Accessing calibration data on a 2.0 port causes an invalid access
  - The libusb backend's implemation of open() will need to be
  refactored in order to support matching on serial numbers.
2013-08-27 00:07:13 -04:00
Jon Szymaniak
e5b8f42279 Fixed misc. (nonfunctional) typos 2013-08-26 20:06:46 -04:00
Robert Ghilduta
10ffba1b39 Add device reset functionality
This commit adds the much needed device reset functionality that allows the
device to reset after an upgrade and start running the new firmware.
2013-08-25 18:21:07 -07:00
Robert Ghilduta
33957f17c1 libbladeRF: cache calibration and OTP data reads
This commit caches the caclibration and OTP data reads, and performs them when
the USB device is "open()"ed.
2013-08-25 18:21:01 -07:00
Jon Szymaniak
439e099b01 libbladeRF: Renamed configuration GPIO read/write functions
Renamed to avoid confusion with expansion board GPIO routines that
will be added in the future.
2013-08-25 12:27:25 -04:00
Jon Szymaniak
792894c228 libbladeRF: [WIP] Changed API interfaces to use int instead of ssize_t.
This is intended to simplify some portability issues, since an int
type is sufficient in the few spots where we had ssize_t.

We'll need to still add a ssize_t wrapper around the Windows
[SSIZE_T](msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx#SSIZE_T)
for use inside the library.
2013-08-23 01:44:13 -04:00
Jon Szymaniak
c1de666afb libbladeRF: Touched up note about LOW_LEVEL routines. 2013-08-22 22:37:04 -04:00
Jon Szymaniak
6a76a4817e libbladeRF: Updated header file and documentation for async changes
Added check that # transfers <= # buffers in bladerf_stream(),
as this is noted in the interface documentation.
2013-08-22 22:28:06 -04:00
Jon Szymaniak
8cc9f2a4b5 libbladeRF: Cleaned up API enumerations and macro definitions.
The _t suffix on enums has been removed, as "_t" is reserved for
POSIX types.

To avoid naming collisions, macro definitions and enumeration values are
now prefixed with at least "BLADERF_".

Also in the mix is a stubbed out "unsupported" implementation of the
stream routines for the Linux driver backend.
2013-08-22 01:01:23 -04:00
Jon Szymaniak
32ec6d97ef libbladeRF: [WIP] Touched up error handling in libusb backend.
Added some memory allocation checks and attempts to tear down the
stream at the first sign of errors, avoiding submitting transfers
if intialization errors occurred. Also did some misc. error
code house keeping.

STREAM_ERROR has been removed. Use STREAM_SHUTTING_DOWN and the
bladerf_stream->error_code field to differentiate between a clean an
error-driven shutdown.

It appears that attempting to use the libusb backend before the FPGA is
loaded yields erroneous behavior when attempting to load the FPGA after
encountering a BLADERF_ERR_IO. (This situation requires a power on reset
of the board.) As such, an FPGA check has been added to the async test
program.
2013-08-20 00:11:22 -04:00
Brian Padalino
f349d209eb libbladeRF: [WIP] Fixed streams for both TX and RX.
Using libusb for streams of both TX and RX.  The example
tx_async test is now for both and wil save off samples
in CSV to a file.  The code still needs to be audited
before it can be brought down to the mainline.
2013-08-18 23:58:42 -04:00
Brian Padalino
5fc3284e2c libbladeRF: [WIP] Zero copy TX async interface. 2013-08-18 20:15:54 -04:00
Jon Szymaniak
456efcbd90 libbladeRF: [WIP] Updated a few fields.
Does not compile.
2013-08-18 16:30:05 -04:00
Brian Padalino
b926523b17 libbladeRF: [WIP] Updating test program. 2013-08-18 14:03:25 -04:00
Jon Szymaniak
29cabea762 libbladeRF: [WIP] Starting to re-work today's design. 2013-08-17 23:27:56 -04:00