aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/AUTHORS10
-rw-r--r--host/config/Version.cmake2
-rw-r--r--host/docs/CMakeLists.txt1
-rw-r--r--host/docs/coding.rst7
-rw-r--r--host/docs/images.rst103
-rw-r--r--host/docs/index.rst1
-rw-r--r--host/docs/usrp2.rst36
-rw-r--r--host/examples/CMakeLists.txt8
-rw-r--r--host/examples/tx_continuous_samples.cpp110
-rw-r--r--host/examples/tx_waveforms.cpp144
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/images.hpp38
-rw-r--r--host/lib/CMakeLists.txt12
-rw-r--r--host/lib/constants.hpp.in6
-rw-r--r--host/lib/usrp/misc_utils.cpp65
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp34
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp6
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp5
-rw-r--r--host/lib/usrp/usrp2/fw_common.h8
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp2
-rw-r--r--host/lib/utils/CMakeLists.txt1
-rw-r--r--host/lib/utils/images.cpp40
-rw-r--r--host/lib/utils/paths.cpp22
23 files changed, 434 insertions, 228 deletions
diff --git a/host/AUTHORS b/host/AUTHORS
index 137eba0e6..7292da8f9 100644
--- a/host/AUTHORS
+++ b/host/AUTHORS
@@ -1,5 +1,6 @@
Matt Ettus - matt@ettus.com
- USRP1/USRP2 FPGA code
+ USRP1 FPGA code
+ USRP2 FPGA code
Josh Blum - josh@ettus.com
driver framework
@@ -14,4 +15,11 @@ Jason Abele - jason@ettus.com
WBX host code
Eric Blossom - eb@comsec.com
+ USRP1 firmware
USRP2 firmware
+
+Tom Tsou - ttsou@vt.edu
+ UHD-USB framework
+ LIBUSB host code
+ USRP1 host code
+ USRP1 firmware
diff --git a/host/config/Version.cmake b/host/config/Version.cmake
index a592a4565..9e4b6b306 100644
--- a/host/config/Version.cmake
+++ b/host/config/Version.cmake
@@ -42,7 +42,7 @@ ELSE(${GIT} STREQUAL "GIT-NOTFOUND")
#extract the timestamp from the git log entry
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMAND ${PYTHON_EXECUTABLE} -c "import re; print re.match('^.*Date:\\s*(\\d*).*$', '''${_git_log}''', re.MULTILINE | re.DOTALL).groups()[0]"
+ COMMAND ${PYTHON_EXECUTABLE} -c "import re; print re.match('^.*Date:\\s*(\\d*).*$', ''' ${_git_log} ''', re.MULTILINE | re.DOTALL).groups()[0]"
OUTPUT_VARIABLE _git_timestamp OUTPUT_STRIP_TRAILING_WHITESPACE
)
diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt
index d0041f71c..b4383f88d 100644
--- a/host/docs/CMakeLists.txt
+++ b/host/docs/CMakeLists.txt
@@ -24,6 +24,7 @@ SET(manual_sources
coding.rst
dboards.rst
general.rst
+ images.rst
usrp2.rst
)
diff --git a/host/docs/coding.rst b/host/docs/coding.rst
index 84f9abf3e..23f350b0f 100644
--- a/host/docs/coding.rst
+++ b/host/docs/coding.rst
@@ -64,7 +64,12 @@ Integrating custom hardware
------------------------------------------------------------------------
Creators of custom hardware can create drivers that use the UHD API.
These drivers can be built as dynamically loadable modules that the UHD will load at runtime.
-For a module to be loaded at runtime, it must be found in the UHD_MODULE_PATH environment variable.
+
+For a module to be loaded at runtime, it must be:
+
+* found in the UHD_MODULE_PATH environment variable,
+* installed into the <prefix>/share/uhd/modules directory,
+* or installed into /usr/share/uhd/modules directory (unix only).
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Custom motherboard
diff --git a/host/docs/images.rst b/host/docs/images.rst
new file mode 100644
index 000000000..612a00aa5
--- /dev/null
+++ b/host/docs/images.rst
@@ -0,0 +1,103 @@
+========================================================================
+UHD - Firmware and FPGA Image Application Notes
+========================================================================
+
+.. contents:: Table of Contents
+
+------------------------------------------------------------------------
+Images Overview
+------------------------------------------------------------------------
+Every USRP device must be loaded with special firmware and FPGA images.
+The methods of loading images into the device varies among devices:
+
+* **USRP1:** The host code will automatically load the firmware and FPGA at runtime.
+* **USRP2:** The user must manually write the images onto the USRP2 SD card.
+
+------------------------------------------------------------------------
+Pre-built images
+------------------------------------------------------------------------
+
+Pre-built images are available for download.
+See the UHD wiki for the download link.
+
+The pre-built images come in platform-specific installer packages
+and platform-independent archive files:
+
+* **Linux:** DEB or RPM installer
+* **Windows:** not available yet...
+* **Macintosh:** not available yet...
+* **Platform-independent:** ZIP or TAR.GZ archive
+
+^^^^^^^^^^^^^^^^^^
+Linux installers
+^^^^^^^^^^^^^^^^^^
+The Linux-based installers will install the images into /usr/share/uhd/images.
+On a Linux system, the UHD will always search this path for image files.
+
+Commands to install a linux rpm or deb package:
+
+::
+
+ sudo rpm -i <linux-images-installer>.rpm
+
+ -- OR --
+
+ sudo dpkg -i <linux-images-installer>.deb
+
+^^^^^^^^^^^^^^^^^^^^^^
+Archive install
+^^^^^^^^^^^^^^^^^^^^^^
+When installing images from an archive, there are two options:
+
+**Option 1:**
+
+Unpack the archive into the UHD installation prefix.
+The UHD will always search <prefix>/share/uhd/images for image files.
+Where <prefix> was set by the CMAKE_INSTALL_PREFIX at configure-time.
+
+**Option 2:**
+
+Unpack the archive anywhere and set the UHD_IMAGE_PATH environment variable.
+The UHD_IMAGE_PATH may contain a list of directories to search for image files.
+
+------------------------------------------------------------------------
+Building images
+------------------------------------------------------------------------
+
+The UHD source repository comes with the source code necessary to build
+both firmware and FPGA images for all supported devices.
+The build commands for a particular image can be found in <uhd-repo-path>/images/Makefile.
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Xilinx FPGA builds
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Xilinx ISE 12.x and up is required to build the Xilinx FPGA images.
+The build requires that you have a unix-like environment with make.
+Make sure that xtclsh from the Xilinx ISE bin directory is in your $PATH.
+
+See <uhd-repo-path>/fpga/usrp2/top/*
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Microblaze firmware builds
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The Microblaze GCC compiler from the Xilinx EDK is required to build the Microblaze firmware images.
+The build requires that you have a unix-like environment with autotools and make.
+Make sure that mb-gcc from the Xilinx EDK/microblaze directory is in your $PATH.
+
+See <uhd-repo-path>/firmware/microblaze
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Altera FPGA builds
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Quartus is required to build the Altera FPGA images.
+Pre-built images can also be found in <uhd-repo-path>/fpga/usrp1/rbf
+
+See <uhd-repo-path>/fpga/usrp1/toplevel/*
+
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+FX2 firmware builds
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+The sdcc compiler is required to build the FX2 firmware images.
+The build requires that you have a unix-like environment with autotools and make.
+
+See <uhd-repo-path>/firmware/fx2
diff --git a/host/docs/index.rst b/host/docs/index.rst
index b31a3d0ac..6973ede19 100644
--- a/host/docs/index.rst
+++ b/host/docs/index.rst
@@ -21,6 +21,7 @@ Building the UHD
Application Notes
^^^^^^^^^^^^^^^^^^^^^
* `General App Notes <./general.html>`_
+* `Firmware and FPGA Image Notes <./images.html>`_
* `USRP2 App Notes <./usrp2.html>`_
* `Daughterboard App Notes <./dboards.html>`_
diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst
index bc4ea0e44..3ac326f58 100644
--- a/host/docs/usrp2.rst
+++ b/host/docs/usrp2.rst
@@ -5,42 +5,6 @@ UHD - USRP2 Application Notes
.. contents:: Table of Contents
------------------------------------------------------------------------
-Building firmware and FPGA images
-------------------------------------------------------------------------
-
-^^^^^^^^^^^^^^^^^^
-FPGA Image
-^^^^^^^^^^^^^^^^^^
-Xilinx ISE 10.1 and up is required to build the FPGA image for the USRP2.
-The build requires that you have a unix-like environment with make.
-Make sure that xtclsh from the Xilinx ISE bin directory is in your $PATH.
-
-Run the following commands:
-::
-
- cd <uhd-repo-path>/fpga/usrp2/top/u2_rev3
- make -f Makefile.udp bin
-
-*The image file will be ./build/u2_rev3.bin*
-
-^^^^^^^^^^^^^^^^^^
-Firmware Image
-^^^^^^^^^^^^^^^^^^
-The Microblaze GCC compiler from the Xilinx EDK is required to build the firmware.
-The build requires that you have a unix-like environment with autotools and make.
-Make sure that mb-gcc from the Xilinx EDK/microblaze directory is in your $PATH.
-
-Run the following commands:
-::
-
- cd <uhd-repo-path>/firmware/microblaze
- ./boostrap
- ./configure --host=mb
- make
-
-*The image file will be ./usrp2/usrp2_txrx_uhd.bin*
-
-------------------------------------------------------------------------
Load the images onto the SD card
------------------------------------------------------------------------
**Warning!**
diff --git a/host/examples/CMakeLists.txt b/host/examples/CMakeLists.txt
index 10a9a833a..c3bbbcd04 100644
--- a/host/examples/CMakeLists.txt
+++ b/host/examples/CMakeLists.txt
@@ -16,9 +16,6 @@
#
-ADD_EXECUTABLE(tx_continuous_samples tx_continuous_samples.cpp)
-TARGET_LINK_LIBRARIES(tx_continuous_samples uhd)
-
ADD_EXECUTABLE(benchmark_rx_rate benchmark_rx_rate.cpp)
TARGET_LINK_LIBRARIES(benchmark_rx_rate uhd)
@@ -28,10 +25,13 @@ TARGET_LINK_LIBRARIES(rx_timed_samples uhd)
ADD_EXECUTABLE(tx_timed_samples tx_timed_samples.cpp)
TARGET_LINK_LIBRARIES(tx_timed_samples uhd)
+ADD_EXECUTABLE(tx_waveforms tx_waveforms.cpp)
+TARGET_LINK_LIBRARIES(tx_waveforms uhd)
+
INSTALL(TARGETS
- tx_continuous_samples
benchmark_rx_rate
rx_timed_samples
tx_timed_samples
+ tx_waveforms
RUNTIME DESTINATION ${PKG_DATA_DIR}/examples
)
diff --git a/host/examples/tx_continuous_samples.cpp b/host/examples/tx_continuous_samples.cpp
deleted file mode 100644
index cf70b07fb..000000000
--- a/host/examples/tx_continuous_samples.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/utils/thread_priority.hpp>
-#include <uhd/utils/safe_main.hpp>
-#include <uhd/usrp/simple_usrp.hpp>
-#include <boost/program_options.hpp>
-#include <boost/thread/thread_time.hpp> //system time
-#include <boost/format.hpp>
-#include <iostream>
-#include <complex>
-
-namespace po = boost::program_options;
-
-int UHD_SAFE_MAIN(int argc, char *argv[]){
- uhd::set_thread_priority_safe();
-
- //variables to be set by po
- std::string args;
- size_t total_duration;
- size_t samps_per_packet;
- double tx_rate, freq;
- float ampl;
-
- //setup the program options
- po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
- ("duration", po::value<size_t>(&total_duration)->default_value(3), "number of seconds to transmit")
- ("spp", po::value<size_t>(&samps_per_packet)->default_value(1000), "number of samples per packet")
- ("txrate", po::value<double>(&tx_rate)->default_value(100e6/16), "rate of outgoing samples")
- ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
- ("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of each sample")
- ("dilv", "specify to disable inner-loop verbose")
- ;
- po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
-
- //print the help message
- if (vm.count("help")){
- std::cout << boost::format("UHD TX Continuous Samples %s") % desc << std::endl;
- return ~0;
- }
-
- bool verbose = vm.count("dilv") == 0;
-
- //create a usrp device
- std::cout << std::endl;
- std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
- uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(args);
- uhd::device::sptr dev = sdev->get_device();
- std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl;
-
- //set properties on the device
- std::cout << boost::format("Setting TX Rate: %f Msps...") % (tx_rate/1e6) << std::endl;
- sdev->set_tx_rate(tx_rate);
- std::cout << boost::format("Actual TX Rate: %f Msps...") % (sdev->get_tx_rate()/1e6) << std::endl;
- sdev->set_tx_freq(freq);
-
- //allocate data to send
- std::vector<std::complex<float> > buff(samps_per_packet, std::complex<float>(ampl, ampl));
-
- //setup the metadata flags
- uhd::tx_metadata_t md;
- md.start_of_burst = true; //always SOB (good for continuous streaming)
- md.end_of_burst = false;
-
- //send the data in multiple packets
- boost::system_time end_time(boost::get_system_time() + boost::posix_time::seconds(total_duration));
- while(end_time > boost::get_system_time()){
- //send samples per packet (driver fragments internally)
- size_t num_tx_samps = dev->send(
- &buff.front(), samps_per_packet, md,
- uhd::io_type_t::COMPLEX_FLOAT32,
- uhd::device::SEND_MODE_FULL_BUFF
- );
- if(verbose) std::cout << std::endl << boost::format("Sent %d samples") % num_tx_samps << std::endl;
- }
-
- //send a mini EOB packet
- if(verbose) std::cout << std::endl << boost::format("Sending packet with end-of-burst") << std::endl;
- md.start_of_burst = false;
- md.end_of_burst = true;
- dev->send(
- NULL, 0, md,
- uhd::io_type_t::COMPLEX_FLOAT32,
- uhd::device::SEND_MODE_FULL_BUFF
- );
-
- //finished
- std::cout << std::endl << "Done!" << std::endl << std::endl;
-
- return 0;
-}
diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp
new file mode 100644
index 000000000..e9cf210bb
--- /dev/null
+++ b/host/examples/tx_waveforms.cpp
@@ -0,0 +1,144 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include <uhd/utils/thread_priority.hpp>
+#include <uhd/utils/safe_main.hpp>
+#include <uhd/usrp/simple_usrp.hpp>
+#include <boost/program_options.hpp>
+#include <boost/thread/thread_time.hpp> //system time
+#include <boost/format.hpp>
+#include <iostream>
+#include <complex>
+#include <cmath>
+
+namespace po = boost::program_options;
+
+int UHD_SAFE_MAIN(int argc, char *argv[]){
+ uhd::set_thread_priority_safe();
+
+ //variables to be set by po
+ std::string args, wave_type;
+ size_t total_duration, amspb;
+ double rate, freq, wave_freq;
+ float ampl, gain;
+
+ //setup the program options
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "help message")
+ ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
+ ("duration", po::value<size_t>(&total_duration)->default_value(3), "number of seconds to transmit")
+ ("amspb", po::value<size_t>(&amspb)->default_value(10000), "approximate mimimum samples per buffer")
+ ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of outgoing samples")
+ ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
+ ("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of the waveform")
+ ("gain", po::value<float>(&gain)->default_value(float(0)), "gain for the RF chain")
+ ("wave-type", po::value<std::string>(&wave_type)->default_value("SINE"), "waveform type (CONST, SQUARE, RAMP, SINE)")
+ ("wave-freq", po::value<double>(&wave_freq)->default_value(0), "waveform frequency in Hz")
+ ;
+ po::variables_map vm;
+ po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::notify(vm);
+
+ //print the help message
+ if (vm.count("help")){
+ std::cout << boost::format("UHD TX Waveforms %s") % desc << std::endl;
+ return ~0;
+ }
+
+ //create a usrp device
+ std::cout << std::endl;
+ std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
+ uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(args);
+ uhd::device::sptr dev = sdev->get_device();
+ std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl;
+
+ //set the tx sample rate
+ std::cout << boost::format("Setting TX Rate: %f Msps...") % (rate/1e6) << std::endl;
+ sdev->set_tx_rate(rate);
+ std::cout << boost::format("Actual TX Rate: %f Msps...") % (sdev->get_tx_rate()/1e6) << std::endl << std::endl;
+
+ //set the tx center frequency
+ std::cout << boost::format("Setting TX Freq: %f Mhz...") % (freq/1e6) << std::endl;
+ sdev->set_tx_freq(freq);
+ std::cout << boost::format("Actual TX Freq: %f Mhz...") % (sdev->get_tx_freq()/1e6) << std::endl << std::endl;
+
+ //set the tx rf gain
+ std::cout << boost::format("Setting TX Gain: %f dB...") % gain << std::endl;
+ sdev->set_tx_gain(gain);
+ std::cout << boost::format("Actual TX Gain: %f dB...") % sdev->get_tx_gain() << std::endl << std::endl;
+
+ //for the const wave, set the wave freq for small samples per period
+ if (wave_freq == 0 and wave_type == "CONST"){
+ wave_freq = sdev->get_tx_rate()/2;
+ }
+
+ //error when the waveform is not possible to generate
+ if (std::abs(wave_freq)/sdev->get_tx_rate() < 0.5/amspb){
+ throw std::runtime_error("wave freq/tx rate too small");
+ }
+ if (std::abs(wave_freq) > sdev->get_tx_rate()/2){
+ throw std::runtime_error("wave freq out of Nyquist zone");
+ }
+
+ //fill a buffer with one period worth of samples
+ std::vector<float> period(size_t(sdev->get_tx_rate()/std::abs(wave_freq)));
+ std::cout << boost::format("Samples per waveform period: %d") % period.size() << std::endl;
+ for (size_t n = 0; n < period.size(); n++){
+ if (wave_type == "CONST") period[n] = ampl;
+ else if (wave_type == "SQUARE") period[n] = (n > period.size()/2)? ampl : 0;
+ else if (wave_type == "RAMP") period[n] = float((n/double(period.size()-1)) * 2*ampl - ampl);
+ else if (wave_type == "SINE") period[n] = ampl*float(std::sin(2*M_PI*n/double(period.size())));
+ else throw std::runtime_error("unknown waveform type: " + wave_type);
+ }
+
+ //allocate data to send (fill with several periods worth of IQ samples)
+ const size_t periods_per_buff = std::max<size_t>(1, amspb/period.size());
+ std::vector<std::complex<float> > buff(period.size()*periods_per_buff);
+ std::cout << boost::format("Samples per send buffer: %d") % buff.size() << std::endl;
+ const size_t i_ahead = (wave_freq > 0)? period.size()/4 : 0;
+ const size_t q_ahead = (wave_freq < 0)? period.size()/4 : 0;
+ for (size_t n = 0; n < buff.size(); n++) buff[n] = std::complex<float>(
+ period[(n+i_ahead)%period.size()], period[(n+q_ahead)%period.size()] //I,Q
+ );
+
+ //setup the metadata flags
+ uhd::tx_metadata_t md;
+ md.start_of_burst = true; //always SOB (good for continuous streaming)
+ md.end_of_burst = false;
+
+ //send the data in multiple packets
+ boost::system_time end_time(boost::get_system_time() + boost::posix_time::seconds(total_duration));
+ while(end_time > boost::get_system_time()) dev->send(
+ &buff.front(), buff.size(), md,
+ uhd::io_type_t::COMPLEX_FLOAT32,
+ uhd::device::SEND_MODE_FULL_BUFF
+ );
+
+ //send a mini EOB packet
+ md.start_of_burst = false;
+ md.end_of_burst = true;
+ dev->send(NULL, 0, md,
+ uhd::io_type_t::COMPLEX_FLOAT32,
+ uhd::device::SEND_MODE_FULL_BUFF
+ );
+
+ //finished
+ std::cout << std::endl << "Done!" << std::endl << std::endl;
+
+ return 0;
+}
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index ef8e64ce0..b39b6083c 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -23,6 +23,7 @@ INSTALL(FILES
byteswap.ipp
exception.hpp
gain_group.hpp
+ images.hpp
pimpl.hpp
props.hpp
safe_main.hpp
diff --git a/host/include/uhd/utils/images.hpp b/host/include/uhd/utils/images.hpp
new file mode 100644
index 000000000..8b5a1eedd
--- /dev/null
+++ b/host/include/uhd/utils/images.hpp
@@ -0,0 +1,38 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_IMAGES_HPP
+#define INCLUDED_UHD_UTILS_IMAGES_HPP
+
+#include <uhd/config.hpp>
+#include <string>
+
+namespace uhd{
+
+ /*!
+ * Search for an image in the system image paths:
+ * Search compiled-in paths and environment variable paths
+ * for a specific image file with the provided file name.
+ * \param image_name the name of the file
+ * \return the full system path to the file
+ * \throw exception if the image was not found
+ */
+ UHD_API std::string find_image_path(const std::string &image_name);
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_UTILS_IMAGES_HPP */
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index b117b99ce..81845de21 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -53,8 +53,16 @@ INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/utils/CMakeLists.txt)
########################################################################
# Append to the list of sources for lib uhd
########################################################################
-FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} FULL_PKG_DATA_DIR)
-MESSAGE(STATUS "Full package data directory: ${FULL_PKG_DATA_DIR}")
+FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} LOCAL_PKG_DATA_DIR)
+STRING(REPLACE "\\" "\\\\" LOCAL_PKG_DATA_DIR ${LOCAL_PKG_DATA_DIR})
+MESSAGE(STATUS "Local package data directory: ${LOCAL_PKG_DATA_DIR}")
+
+IF(UNIX)
+ #on unix systems, installers will use this directory for the package data
+ FILE(TO_NATIVE_PATH /usr/${PKG_DATA_DIR} INSTALLER_PKG_DATA_DIR)
+ STRING(REPLACE "\\" "\\\\" INSTALLER_PKG_DATA_DIR ${INSTALLER_PKG_DATA_DIR})
+ MESSAGE(STATUS "Installer package data directory: ${INSTALLER_PKG_DATA_DIR}")
+ENDIF(UNIX)
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/constants.hpp.in
diff --git a/host/lib/constants.hpp.in b/host/lib/constants.hpp.in
index 2ed4e302f..4aedb6d4a 100644
--- a/host/lib/constants.hpp.in
+++ b/host/lib/constants.hpp.in
@@ -18,11 +18,9 @@
#ifndef INCLUDED_LIBUHD_CONSTANTS_HPP
#define INCLUDED_LIBUHD_CONSTANTS_HPP
-#include <uhd/config.hpp>
-#include <string>
-
//these should be pre-processor macros to avoid static initialization issues
#define UHD_VERSION_STRING "@CPACK_PACKAGE_VERSION@"
-#define FULL_PKG_DATA_DIR "@FULL_PKG_DATA_DIR@"
+#define LOCAL_PKG_DATA_DIR "@LOCAL_PKG_DATA_DIR@"
+#define INSTALLER_PKG_DATA_DIR "@INSTALLER_PKG_DATA_DIR@"
#endif /* INCLUDED_LIBUHD_CONSTANTS_HPP */
diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp
index 46094ba32..a1664d810 100644
--- a/host/lib/usrp/misc_utils.cpp
+++ b/host/lib/usrp/misc_utils.cpp
@@ -25,6 +25,7 @@
#include <uhd/usrp/codec_props.hpp>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
+#include <boost/format.hpp>
using namespace uhd;
using namespace uhd::usrp;
@@ -132,43 +133,49 @@ static void verify_xx_subdev_spec(
wax::obj mboard,
std::string xx_type
){
- prop_names_t dboard_names = mboard[dboard_names_prop].as<prop_names_t>();
- UHD_ASSERT_THROW(dboard_names.size() > 0); //well i hope there is a dboard
+ try{
+ prop_names_t dboard_names = mboard[dboard_names_prop].as<prop_names_t>();
+ UHD_ASSERT_THROW(dboard_names.size() > 0); //well i hope there is a dboard
- //the subdevice specification is empty: handle automatic
- if (subdev_spec.empty()){
- BOOST_FOREACH(const std::string &db_name, dboard_names){
- wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
+ //the subdevice specification is empty: handle automatic
+ if (subdev_spec.empty()){
+ BOOST_FOREACH(const std::string &db_name, dboard_names){
+ wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
+
+ //if the dboard slot is populated, take the first subdevice
+ if (dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>() != dboard_id_t::none()){
+ std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
+ subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
+ break;
+ }
+ }
- //if the dboard slot is populated, take the first subdevice
- if (dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>() != dboard_id_t::none()){
+ //didnt find any populated dboards: add the first subdevice
+ if (subdev_spec.empty()){
+ std::string db_name = dboard_names.front();
+ wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
- break;
}
}
- //didnt find any populated dboards: add the first subdevice
- if (subdev_spec.empty()){
- std::string db_name = dboard_names.front();
- wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
- std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
- subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
- }
- }
-
- //sanity check that the dboard/subdevice names exist for this mboard
- BOOST_FOREACH(const subdev_spec_pair_t &pair, subdev_spec){
- //empty db name means select dboard automatically
- if (pair.db_name.empty()){
- if (dboard_names.size() != 1) throw std::runtime_error(
- "A daughterboard name must be provided for multi-slot boards: " + subdev_spec.to_string()
- );
- pair.db_name == dboard_names.front();
+ //sanity check that the dboard/subdevice names exist for this mboard
+ BOOST_FOREACH(const subdev_spec_pair_t &pair, subdev_spec){
+ //empty db name means select dboard automatically
+ if (pair.db_name.empty()){
+ if (dboard_names.size() != 1) throw std::runtime_error(
+ "A daughterboard name must be provided for multi-slot boards: " + subdev_spec.to_string()
+ );
+ pair.db_name == dboard_names.front();
+ }
+ uhd::assert_has(dboard_names, pair.db_name, xx_type + " dboard name");
+ wax::obj dboard = mboard[named_prop_t(dboard_prop, pair.db_name)];
+ uhd::assert_has(dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>(), pair.sd_name, xx_type + " subdev name");
}
- uhd::assert_has(dboard_names, pair.db_name, xx_type + " dboard name");
- wax::obj dboard = mboard[named_prop_t(dboard_prop, pair.db_name)];
- uhd::assert_has(dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>(), pair.sd_name, xx_type + " subdev name");
+ }catch(const std::exception &e){
+ throw std::runtime_error(str(boost::format(
+ "Validate %s subdev spec failed: %s\n %s"
+ ) % xx_type % subdev_spec.to_string() % e.what()));
}
}
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index a4effb907..a15d0a244 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -23,9 +23,11 @@
#include <uhd/usrp/device_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
+#include <uhd/utils/images.hpp>
#include <boost/format.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/filesystem.hpp>
+#include <boost/thread/thread.hpp>
#include <iostream>
using namespace uhd;
@@ -42,11 +44,16 @@ const std::vector<usrp1_impl::dboard_slot_t> usrp1_impl::_dboard_slots = boost::
static device_addrs_t usrp1_find(const device_addr_t &hint)
{
device_addrs_t usrp1_addrs;
- std::string filename = "/usr/local/share/usrp/rev4/std.ihx";
//return an empty list of addresses when type is set to non-usrp1
if (hint.has_key("type") and hint["type"] != "usrp1") return usrp1_addrs;
+ //extract the firmware path for the USRP1
+ std::string usrp1_fw_image = find_image_path(
+ hint.has_key("fw")? hint["fw"] : "usrp1_fw.ihx"
+ );
+ std::cout << "USRP1 firmware image: " << usrp1_fw_image << std::endl;
+
//see what we got on the USB bus
std::vector<usb_device_handle::sptr> device_list =
usb_device_handle::get_device_list();
@@ -58,12 +65,12 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
usb_control::sptr ctrl_transport = usb_control::make(handle);
usrp_ctrl::sptr usrp_ctrl = usrp_ctrl::make(ctrl_transport);
- usrp_ctrl->usrp_load_firmware(filename);
+ usrp_ctrl->usrp_load_firmware(usrp1_fw_image);
}
}
//wait for things to settle
- sleep(1);
+ boost::this_thread::sleep(boost::posix_time::milliseconds(500));
//get descriptors again with serial number
device_list = usb_device_handle::get_device_list();
@@ -87,14 +94,11 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
**********************************************************************/
static device::sptr usrp1_make(const device_addr_t &device_addr)
{
- std::string filename;
-
- if (device_addr.has_key("fpga"))
- filename = device_addr["fpga"];
- else
- filename = "/usr/local/share/usrp/rev4/std_2rxhb_2tx.rbf";
-
- std::cout << "Make usrp1 with " << filename << std::endl;
+ //extract the FPGA path for the USRP1
+ std::string usrp1_fpga_image = find_image_path(
+ device_addr.has_key("fpga")? device_addr["fpga"] : "usrp1_fpga.rbf"
+ );
+ std::cout << "USRP1 FPGA image: " << usrp1_fpga_image << std::endl;
//try to match the given device address with something on the USB bus
std::vector<usb_device_handle::sptr> device_list =
@@ -111,7 +115,7 @@ static device::sptr usrp1_make(const device_addr_t &device_addr)
usb_control::sptr ctrl_transport = usb_control::make(handle);
usrp_ctrl = usrp_ctrl::make(ctrl_transport);
- usrp_ctrl->usrp_load_fpga(filename);
+ usrp_ctrl->usrp_load_fpga(usrp1_fpga_image);
data_transport = usb_zero_copy::make(handle, // identifier
6, // IN endpoint
@@ -176,6 +180,12 @@ usrp1_impl::~usrp1_impl(void){
/* NOP */
}
+bool usrp1_impl::recv_async_msg(uhd::async_metadata_t &, size_t timeout_ms){
+ //dummy fill-in for the recv_async_msg
+ boost::this_thread::sleep(boost::posix_time::milliseconds(timeout_ms));
+ return false;
+}
+
/***********************************************************************
* Device Get
**********************************************************************/
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 5934d1779..4b4ac51dd 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -93,11 +93,7 @@ public:
size_t get_max_send_samps_per_packet(void) const { return 0; }
size_t get_max_recv_samps_per_packet(void) const { return 0; }
-
- bool recv_async_msg(uhd::async_metadata_t &, size_t) {
- //TODO sleep the number of ms supplied (dont want to hog CPU)
- return false;
- }
+ bool recv_async_msg(uhd::async_metadata_t &, size_t);
private:
/*!
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index 347ec38af..6422142ce 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -31,9 +31,10 @@ static const size_t default_interp = 16;
/***********************************************************************
* DDC Helper Methods
**********************************************************************/
-static unsigned pick_closest_rate(double exact_rate, const std::vector<unsigned> &rates){
+template <typename rate_type>
+static rate_type pick_closest_rate(double exact_rate, const std::vector<rate_type> &rates){
unsigned closest_match = rates.front();
- BOOST_FOREACH(unsigned possible_rate, rates){
+ BOOST_FOREACH(rate_type possible_rate, rates){
if(std::abs(exact_rate - possible_rate) < std::abs(exact_rate - closest_match))
closest_match = possible_rate;
}
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index a781c1a21..cc6c41ba7 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -34,7 +34,7 @@ extern "C" {
//fpga and firmware compatibility numbers
#define USRP2_FPGA_COMPAT_NUM 1
-#define USRP2_FW_COMPAT_NUM 5
+#define USRP2_FW_COMPAT_NUM 6
//used to differentiate control packets over data port
#define USRP2_INVALID_VRT_HEADER 0
@@ -104,12 +104,12 @@ typedef struct{
union{
__stdint(uint32_t) ip_addr;
struct {
- __stdint(uint8_t) dev;
+ __stdint(uint32_t) dev;
+ __stdint(uint32_t) data;
__stdint(uint8_t) miso_edge;
__stdint(uint8_t) mosi_edge;
- __stdint(uint8_t) readback;
- __stdint(uint32_t) data;
__stdint(uint8_t) num_bits;
+ __stdint(uint8_t) readback;
} spi_args;
struct {
__stdint(uint8_t) addr;
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 4124221ef..2d450bfc6 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -115,7 +115,7 @@ public:
//setup the out data
usrp2_ctrl_data_t out_data;
out_data.id = htonl(USRP2_CTRL_ID_TRANSACT_ME_SOME_SPI_BRO);
- out_data.data.spi_args.dev = which_slave;
+ out_data.data.spi_args.dev = htonl(which_slave);
out_data.data.spi_args.miso_edge = spi_edge_to_otw[config.miso_edge];
out_data.data.spi_args.mosi_edge = spi_edge_to_otw[config.mosi_edge];
out_data.data.spi_args.readback = (readback)? 1 : 0;
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt
index 68945545a..32b679d49 100644
--- a/host/lib/utils/CMakeLists.txt
+++ b/host/lib/utils/CMakeLists.txt
@@ -79,6 +79,7 @@ ENDIF(HAVE_DLFCN_H)
LIBUHD_APPEND_SOURCES(
${CMAKE_SOURCE_DIR}/lib/utils/assert.cpp
${CMAKE_SOURCE_DIR}/lib/utils/gain_group.cpp
+ ${CMAKE_SOURCE_DIR}/lib/utils/images.cpp
${CMAKE_SOURCE_DIR}/lib/utils/load_modules.cpp
${CMAKE_SOURCE_DIR}/lib/utils/paths.cpp
${CMAKE_SOURCE_DIR}/lib/utils/props.cpp
diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp
new file mode 100644
index 000000000..395e542c1
--- /dev/null
+++ b/host/lib/utils/images.cpp
@@ -0,0 +1,40 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include <uhd/utils/images.hpp>
+#include <boost/foreach.hpp>
+#include <boost/filesystem.hpp>
+#include <stdexcept>
+#include <vector>
+
+namespace fs = boost::filesystem;
+
+std::vector<fs::path> get_image_paths(void); //defined in paths.cpp
+
+/***********************************************************************
+ * Find a image in the image paths
+ **********************************************************************/
+std::string uhd::find_image_path(const std::string &image_name){
+ if (fs::exists(image_name)){
+ return fs::system_complete(image_name).file_string();
+ }
+ BOOST_FOREACH(const fs::path &path, get_image_paths()){
+ fs::path image_path = path / image_name;
+ if (fs::exists(image_path)) return image_path.file_string();
+ }
+ throw std::runtime_error("Could not find path for image: " + image_name);
+}
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 3f29945dd..9e9525caf 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -72,26 +72,16 @@ static std::vector<fs::path> get_env_paths(const std::string &var_name){
**********************************************************************/
std::vector<fs::path> get_image_paths(void){
std::vector<fs::path> paths = get_env_paths("UHD_IMAGE_PATH");
- paths.push_back(fs::path(FULL_PKG_DATA_DIR) / "images");
+ paths.push_back(fs::path(LOCAL_PKG_DATA_DIR) / "images");
+ if (not std::string(INSTALLER_PKG_DATA_DIR).empty())
+ paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "images");
return paths;
}
std::vector<fs::path> get_module_paths(void){
std::vector<fs::path> paths = get_env_paths("UHD_MODULE_PATH");
- paths.push_back(fs::path(FULL_PKG_DATA_DIR) / "modules");
+ paths.push_back(fs::path(LOCAL_PKG_DATA_DIR) / "modules");
+ if (not std::string(INSTALLER_PKG_DATA_DIR).empty())
+ paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "modules");
return paths;
}
-
-/***********************************************************************
- * Find a image in the image paths
- **********************************************************************/
-std::string find_image_path(const std::string &image_name){
- if (fs::exists(image_name)){
- return fs::system_complete(image_name).file_string();
- }
- BOOST_FOREACH(const fs::path &path, get_image_paths()){
- fs::path image_path = path / image_name;
- if (fs::exists(image_path)) return image_path.file_string();
- }
- throw std::runtime_error("Could not find path for image: " + image_name);
-}