Commit graph

59 commits

Author SHA1 Message Date
Nick "Darkfiber" Wolff
327dce57b1 host: Minimal build fixes for FreeBSD
Work still needs to be done to troubleshoot libusb issues.
2015-12-14 11:36:15 -05:00
Jon Szymaniak
c5d1e4a9f3 host/common: Made devcfg_perform_sync_config() parameter const 2015-11-29 21:20:54 -05:00
Jon Szymaniak
672cf27eae host/common: Added string to uint64 and double w/ suffix conversions 2015-10-08 12:48:55 -04:00
Jon Szymaniak
bf9f8a62a4 host: Moved device config helpers to host/common
People may find these useful when developing their own tools or
contributions to the bladeRF codebase.
2015-06-21 23:07:40 -04:00
Jon Szymaniak
3cfb507f91 host_common: Use size_t for array length, MSVC build fix
size_t or unsigned int are preferred for variables that describe
the length of an array.

This change fixes an additional MSVC build issue caused by
test_scheduled_retune.
2015-06-21 22:52:19 -04:00
Jon Szymaniak
cd6cb0cca7 host/common: Added SC16Q11 <-> float conversion routines 2015-04-10 13:39:09 -04:00
Jon Szymaniak
4d5027bc41 host: Don't redefine inline for C++ (Windows) in host-compat header
It appears the 'inline' keyword still isn't supported as of VS2013
(MSVC 18.00). However, we shouldn't be re-defining it
if building with VS's C++ compiler.
2015-01-22 18:47:31 -05:00
Jon Szymaniak
41bcf7b12c host: Centralized duplicated code
Moved function to get string description to conversions.c.

There's a similar function within libbladeRF's backend.c, but that
is intended to be used in the device information string; this is
intended to be a bit more humand-readable.
2014-12-18 17:58:21 -05:00
Jon Szymaniak
7218273716 libbladeRF_test: Added common cmdline arg handling and device config
Most of the libbladeRF_test items contain their own command line
argument handling, yielding repeated code and inconsistent invocations.

This commit introduces common command-line argument handling and device
configuration for the most used device parameters.

Future patches will migrate the tests over to using this functionality.
New tests should use this immediately.
2014-11-18 17:09:11 -05:00
Jon Szymaniak
64275e768f host: Updated and moved Windows C99 compatibility headers
Visual Studio 2013 now includes these headers, so they have
been moved as not to conflict (even though they are intended to
be equivalent.)

Our stdbool.h was providing an incorrect typedef; sizeof(bool)
should have been 1, not sizeof(int).

Per http://msdn.microsoft.com/en-us/library/tf4dy80a.aspx:
    "In Visual C++4.2, the Standard C++ header files contained a typedef
    that equated bool with int. In Visual C++ 5.0 and later, bool is
    implemented as a built-in type with a size of 1 byte. That means
    that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in
    Visual C++ 5.0 and later, the same call yields 1. This can cause
    memory corruption problems if you have defined structure members of
    type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or
    DLLs built with the 4.2 and 5.0 or later compilers."
2014-11-14 15:19:18 -05:00
Jon Szymaniak
7c0969a44d host: Enable short source file name and line # in log output by default
When making log_* calls, add these two lines to the corresponding
CMake file prior to add_library() or add_executable():

    set(SRC_TO_SHORTEN ${MY_SRC_LIST})
    include(ShortFileMacro)

Many thanks to LazyDodo for providing the CMake approach for doing this,
and to rwr for suggesting this change.
2014-10-02 12:29:14 -04:00
Jon Szymaniak
c4d5bbe8b4 bladeRF-cli: Added '#' end-of-line comment
All characters following '#' are ignored as part of an end-of-line
comment.

Thank you to Karl Lehenbauer for suggesting this change.
2014-08-15 01:47:36 -04:00
Jon Szymaniak
7b0cc24f95 libbladeRF: Introduced thread-safety to the API
Top-level API functions now acquire a per-device "control lock" before
performing control, programming, and low-level access operations.
(Specifically, these are the functions that manipulate the device handle
and utilize the FX3 <-> FPGA UART.)

Synchronous data transfer functions now hold a per-device, per-module
"sync lock" to ensure these operations are carried out atomically. The
control lock is also held during sync configuration, as upcoming changes
to introduce metadata support will require flipping some config bits on
the FPGA during this operation.

Only these top-level functions shall acquire these locks; the core logic
code should be able to assume that locks are already acquired.

To alleviate confusion, functions that are *not* part of the API, and
therefore are safe to call within the core logic, are stripped of the
bladerf_ prefix.

Now that pthreads is a required dependency, use of the sync API is
is no longer marked optional in the libbladeRF build.
ENABLE_LIBBLADERF_SYNC and related items have been removed from the
CMake build.
2014-08-02 19:22:49 -04:00
Jon Szymaniak
a151ba4f99 bladeRF-cli: Handle unterminated quote as a non-fatal error condition
And additional return value has been added to str2args in order to
differentiate between an unexpected fatal (e.g, memory) error and
unterminated quotes.

This was previously causing cmd_handle() to fall through to an
"Unknown error" case, which is treated as a fatal error, resulting in
the CLI being terminated.

Thank you to Jens Elofsson (jenselo) for tracking down and reporting the
underlying defect! (Issue #259)
2014-06-30 01:34:00 -04:00
Jon Szymaniak
67938789f9 libbladeRF: Load calibration tables or FPGA bitstream on device open
On Linux and OSX, the following directories will be searched,
in the order listed:
    ~/.config/Nuand/bladeRF
    ~/.Nuand/bladeRF
    /etc/Nuand/bladeRF

In Windows, %appdata%/Nuand/bladeRF will searched.

The following files will be loaded, if found in these search paths:

    FPGA image: hostedx40.rbf or hostedx115.rbf, depending on the
                size of the FPGA reported by the device.

    DC Calibration tables: <serial>_dc_<rx|tx>.tbl

libbladeRF: Added Windows support to file_find
2014-06-30 00:04:39 -04:00
Jon Szymaniak
c1ffb2dafe libbladeRF: Moved ARRAY_SIZE() macro to host config header 2014-06-30 00:04:38 -04:00
Jon Szymaniak
952db39be0 libbladeRF: Added DC calibration table structure and routines 2014-06-30 00:04:37 -04:00
Ryan Tucker
b24cf702b6 Support Windows builds with MinGW
- Our surrogate inttypes.h is only needed for Visual Studio 2010 and
  earlier, due to the lack of C99 support.
- Move all the inttypes.h includes into host_config.h, where we can
  do the ugly in a centralized location
- MinGW on Linux is case-sensitive -- reflect that when including
  windows.h.
2014-06-21 13:41:44 -04:00
Jon Szymaniak
e0f6ee0eea bladeRF-cli: Added -e <command> support
This option allows interactive mode commands to be executed from the
command line. Multiple -e <cmd> arguments may be provided; they will be
executed in the order they are specified.

Operations/command are performed in the following order:
    - Command line options (e.g., FPGA load, firmware flash)
    - Commands from '-e <cmd>' arguments
    - Commands from script files
    - Interactive mode commands
2014-05-28 21:33:27 -04:00
Jon Szymaniak
28cb63e375 common: Fixed comment typo introduced in 18c4e23a 2014-05-06 23:28:23 -04:00
Jon Szymaniak
18c4e23a56 libbladeRF: Fixed OSX build issue due to invalid endian wrapper macro 2014-05-06 22:57:26 -04:00
Jon Szymaniak
fc6827f03f libbladeRF: Refactored backend i/f to allow for new USB drivers
This work is largely based upon or directly from contributions by LazyDodo.

To allow for other USB drivers (e.g., native host drivers, the CyAPI) to
be more easily integrated, all driver-agnostic bladeRF<->USB code has
been moved to a generic USB backend. The intent is here is to decouple
bladeRF-specific logic from these USB "driver" interfaces to remove
unnecessary code duplication.

The contained changes include:
 - Splitting the libusb backend code into backend/usb/usb.c and
   backend/usb/libusb.c, and some cleanup in the moved code.

 - Removal of the flash_firmware() backend function. This is has been
   moved to flash.c, and is implemented atop the backend flash
   functions.

 - Removal of legacy support in the USB code. All legacy support
   is planned for removal and replacement with an appropriate
   error code to denote that a FW upgrade is required.
2014-05-06 21:59:41 -04:00
Jon Szymaniak
3ad30c3b5a libbladeRF: Windows build fix for test_sync program
Build error results from treating warnings as errors, with possible overflow in 64 -> 32bit conversion.
2014-03-08 19:55:22 -05:00
Jon Szymaniak
ffb54863b2 libbladeRF: Added loopback and clean SIGTERM handling to test_sync 2014-03-08 19:55:21 -05:00
Jon Szymaniak
daaa2e92c8 libbladeRF: Re-implemented sync interface, updated API docs, renamed timeout function
The sync interface has been re-implemented atop the existing
asynchronous interface. This is currently opt-in and only enable when
pthreads support is enabled and available.

Some clarifications have been made in the API documentation,
specifically in the explanations of the various stream parameters.

The bladerf_set_transfer_timeout and bladerf_get_transfer_timeout have
been named more appropriately, as these control stream transfer
timeouts, as opposed to all transfers.
2014-03-08 19:55:21 -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
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
cae59d8900 common: Add sha256 code from FreeBSD 2013-11-28 13:58:08 -05:00
Daniel Gröber
0518009046 common: add BE32 <-> HOST endian conversion 2013-11-28 13:58:08 -05:00
Jon Szymaniak
12a4313cc1 bladeRF-cli: Improved script support, quoted param support, misc. cleanup
Scripts can be invoked from within other scripts, using the "run"
command. An error is reported if a recursive loop is detected.

An "echo" command has been added for debug purposes.

Parameters may now be surrounded in double quotes to include spaces.

Removed extraneous error messages from main(); The preceding functions
print error messages if needed.

Removed error-out if no device is attached. This allows scripts to be
run if the device is not attached. Commands already verify that a device
is attached, if required.
2013-11-11 22:14:53 -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
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
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
9dad2af0de Windows: Call Sleep() with a value > 0.
From the documentation:

"A value of zero causes the thread to relinquish the remainder of its
time slice to any other thread of equal priority that is ready to run.
If there are no other threads of equal priority ready to run, the
function returns immediately, and the thread continues execution."

Thanks Simon!
2013-09-29 12:05:14 -04:00
litghost
abe064cea8 Fixes for Windows build warnings on VS2012 2013-09-27 16:31:37 +00:00
Keith Rothman
57116c919a [FX3/libbladeRF] Major refactoring of FX3 application
- Split RF, FPGA load, and firmware methods into seperate .c files
 - Split several vendor requests to eliminate magic glEp0Idx and to allow
   for better error handling
   - Updated libbladeRF to use new vendor requests and properly check return
     code.
 - Changed glSpiPageSize from global to #define
 - Move OTP handling into firmware.c
 - Version bump

Conflicts:

	fx3_firmware/bladeRF.c
2013-09-22 08:06:48 +00: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
Nuand
264fb4428e Merge pull request #103 from litghost/windows_build_fix
[test_repeater] Fixed windows build
2013-09-15 00:00:37 -07:00
litghost
c5c3cb11a2 [test_repeater] Fixed windows build 2013-09-14 23:22:11 -07:00
Robert Ghilduta
e9bc007b39 host_config.h.in: fix Sleep() argument
Windows' Sleep() function expects the argument to be specified in milliseconds
2013-09-14 23:19:13 -07:00
Keith Rothman
b530c7266d Initial version of bladeRF-flash tool 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
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
Brian Padalino
9e0be95110 Merge branch 'issue66' of https://github.com/frank8371/bladeRF into frank8371-issue66
Enhancement to support suffixes on the command line.
2013-09-05 20:19:16 -04:00
Robert Ghilduta
c28acaed83 fix Windows string format function usage 2013-09-04 20:27:38 -05:00
Frank Jenner
2761491a58 Added support for suffixes on numeric values
Added a new conversion function that accepts a list of suffix to
multiplier mappings, and applies the appropriate multiplier to the input
value. Utilized this new conversion function in the CLI for set
bandwidth, set samplerate, and set frequency.
2013-09-04 20:37:15 -04:00
Jon Szymaniak
b0d82cc95e host common: Corrected return type for str2uint64 2013-09-04 19:22:14 -04:00
Jon Szymaniak
9c6892c130 host: Disabled file and line information from log messages by default.
This information (which is helpful when asking questions on IRC or
in the forums), can be enabled via the CMake argument,
     -DENABLE_LOG_FILE_INFO=ON
2013-09-04 01:33:41 -04:00