summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/lib/CMakeLists.txt17
-rw-r--r--host/lib/constants.hpp.in25
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp6
-rw-r--r--host/lib/usrp/usrp2/usrp2_iface.cpp31
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp42
-rw-r--r--host/lib/utils/CMakeLists.txt13
-rw-r--r--host/lib/utils/paths.cpp1
-rw-r--r--host/lib/version.cpp8
8 files changed, 72 insertions, 71 deletions
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 618e33608..fca4730d8 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -79,23 +79,18 @@ INCLUDE_SUBDIRECTORY(usrp)
INCLUDE_SUBDIRECTORY(utils)
########################################################################
-# Setup compiled-in constants for data directories
+# Setup UHD_VERSION_STRING for version.cpp
########################################################################
-FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH)
-STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH})
-MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}")
-
-CONFIGURE_FILE(
- ${CMAKE_CURRENT_SOURCE_DIR}/constants.hpp.in
- ${CMAKE_CURRENT_BINARY_DIR}/constants.hpp
-@ONLY)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+SET_SOURCE_FILES_PROPERTIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
+ PROPERTIES COMPILE_DEFINITIONS
+ "UHD_VERSION_STRING=\"${UHD_VERSION}-${UHD_BUILD_INFO}\""
+)
########################################################################
# Append to the list of sources for lib uhd
########################################################################
LIBUHD_APPEND_SOURCES(
- ${CMAKE_CURRENT_BINARY_DIR}/constants.hpp
${CMAKE_CURRENT_SOURCE_DIR}/device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/exception.cpp
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
diff --git a/host/lib/constants.hpp.in b/host/lib/constants.hpp.in
deleted file mode 100644
index 2e0495b12..000000000
--- a/host/lib/constants.hpp.in
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// Copyright 2010-2011 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_LIBUHD_CONSTANTS_HPP
-#define INCLUDED_LIBUHD_CONSTANTS_HPP
-
-//these should be pre-processor macros to avoid static initialization issues
-#define UHD_VERSION_STRING "@UHD_VERSION@-@UHD_BUILD_INFO@"
-#define UHD_PKG_DATA_PATH "@UHD_PKG_DATA_PATH@"
-
-#endif /* INCLUDED_LIBUHD_CONSTANTS_HPP */
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 7a6c596bc..29e0535f8 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -71,8 +71,10 @@ usrp2_mboard_impl::usrp2_mboard_impl(
const boost::uint32_t fpga_compat_num = _iface->peek32(_iface->regs.compat_num_rb);
if (fpga_compat_num != USRP2_FPGA_COMPAT_NUM){
throw uhd::runtime_error(str(boost::format(
- "Expected fpga compatibility number %d, but got %d:\n"
- "The fpga build is not compatible with the host code build."
+ "\nPlease update the firmware and FPGA images for your device.\n"
+ "See the application notes for USRP2/N-Series for instructions.\n"
+ "Expected FPGA compatibility number %d, but got %d:\n"
+ "The FPGA build is not compatible with the host code build."
) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num));
}
diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp
index 227233917..d88d31765 100644
--- a/host/lib/usrp/usrp2/usrp2_iface.cpp
+++ b/host/lib/usrp/usrp2/usrp2_iface.cpp
@@ -46,9 +46,20 @@ public:
/***********************************************************************
* Structors
**********************************************************************/
- usrp2_iface_impl(udp_simple::sptr ctrl_transport){
- _ctrl_transport = ctrl_transport;
- _ctrl_seq_num = 0;
+ usrp2_iface_impl(udp_simple::sptr ctrl_transport):
+ _ctrl_transport(ctrl_transport),
+ _ctrl_seq_num(0),
+ _protocol_compat(0) //initialized below...
+ {
+ //Obtain the firmware's compat number.
+ //Save the response compat number for communication.
+ //TODO can choose to reject certain older compat numbers
+ usrp2_ctrl_data_t ctrl_data;
+ ctrl_data.id = htonl(USRP2_CTRL_ID_WAZZUP_BRO);
+ ctrl_data = ctrl_send_and_recv(ctrl_data, 0, ~0);
+ if (ntohl(ctrl_data.id) != USRP2_CTRL_ID_WAZZUP_DUDE)
+ throw uhd::runtime_error("firmware not responding");
+ _protocol_compat = ntohl(ctrl_data.proto_ver);
mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_N100);
switch(this->get_rev()){
@@ -231,14 +242,9 @@ public:
){
boost::mutex::scoped_lock lock(_ctrl_mutex);
- std::string range = (lo == hi)?
- str(boost::format("%d") % hi) :
- str(boost::format("[%d to %d]") % lo % hi)
- ;
-
//fill in the seq number and send
usrp2_ctrl_data_t out_copy = out_data;
- out_copy.proto_ver = htonl(USRP2_FW_COMPAT_NUM);
+ out_copy.proto_ver = htonl(_protocol_compat);
out_copy.seq = htonl(++_ctrl_seq_num);
_ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t)));
@@ -248,11 +254,13 @@ public:
while(true){
size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CTRL_RECV_TIMEOUT);
boost::uint32_t compat = ntohl(ctrl_data_in->proto_ver);
- if(len >= sizeof(boost::uint32_t) and hi >= compat and lo <= compat){
+ if(len >= sizeof(boost::uint32_t) and (hi < compat or lo > compat)){
throw uhd::runtime_error(str(boost::format(
+ "\nPlease update the firmware and FPGA images for your device.\n"
+ "See the application notes for USRP2/N-Series for instructions.\n"
"Expected protocol compatibility number %s, but got %d:\n"
"The firmware build is not compatible with the host code build."
- ) % range % compat));
+ ) % ((lo == hi)? (boost::format("%d") % hi) : (boost::format("[%d to %d]") % lo % hi)) % compat));
}
if (len >= sizeof(usrp2_ctrl_data_t) and ntohl(ctrl_data_in->seq) == _ctrl_seq_num){
return *ctrl_data_in;
@@ -292,6 +300,7 @@ private:
//used in send/recv
boost::mutex _ctrl_mutex;
boost::uint32_t _ctrl_seq_num;
+ boost::uint32_t _protocol_compat;
/***********************************************************************
* Private Templated Peek and Poke
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index f42be321b..cb92b1921 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -171,6 +171,15 @@ static mtu_result_t determine_mtu(const std::string &addr){
usrp2_ctrl_data_t *ctrl_data = reinterpret_cast<usrp2_ctrl_data_t *>(buffer);
static const double echo_timeout = 0.020; //20 ms
+ //test holler - check if its supported in this fw version
+ ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO);
+ ctrl_data->proto_ver = htonl(USRP2_FW_COMPAT_NUM);
+ ctrl_data->data.echo_args.len = htonl(sizeof(usrp2_ctrl_data_t));
+ udp_sock->send(boost::asio::buffer(buffer, sizeof(usrp2_ctrl_data_t)));
+ udp_sock->recv(boost::asio::buffer(buffer), echo_timeout);
+ if (ntohl(ctrl_data->id) != USRP2_CTRL_ID_HOLLER_BACK_DUDE)
+ throw uhd::not_implemented_error("holler protocol not implemented");
+
size_t min_recv_mtu = sizeof(usrp2_ctrl_data_t), max_recv_mtu = sizeof(buffer);
size_t min_send_mtu = sizeof(usrp2_ctrl_data_t), max_send_mtu = sizeof(buffer);
@@ -233,23 +242,28 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){
device_addrs_t device_args = separate_device_addr(device_addr);
- //calculate the minimum send and recv mtu of all devices
- mtu_result_t mtu = determine_mtu(device_args[0]["addr"]);
- for (size_t i = 1; i < device_args.size(); i++){
- mtu_result_t mtu_i = determine_mtu(device_args[i]["addr"]);
- mtu.recv_mtu = std::min(mtu.recv_mtu, mtu_i.recv_mtu);
- mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu);
- }
+ try{
+ //calculate the minimum send and recv mtu of all devices
+ mtu_result_t mtu = determine_mtu(device_args[0]["addr"]);
+ for (size_t i = 1; i < device_args.size(); i++){
+ mtu_result_t mtu_i = determine_mtu(device_args[i]["addr"]);
+ mtu.recv_mtu = std::min(mtu.recv_mtu, mtu_i.recv_mtu);
+ mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu);
+ }
- //use the discovered mtu or clip the users requested mtu
- mtu.recv_mtu = std::min(size_t(device_addr.cast<double>("recv_frame_size", 9000)), mtu.recv_mtu);
- mtu.send_mtu = std::min(size_t(device_addr.cast<double>("send_frame_size", 9000)), mtu.send_mtu);
+ //use the discovered mtu or clip the users requested mtu
+ mtu.recv_mtu = std::min(size_t(device_addr.cast<double>("recv_frame_size", 9000)), mtu.recv_mtu);
+ mtu.send_mtu = std::min(size_t(device_addr.cast<double>("send_frame_size", 9000)), mtu.send_mtu);
- device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu);
- device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu);
+ device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu);
+ device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu);
- std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl;
- std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl;
+ std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl;
+ std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl;
+ }
+ catch(const uhd::not_implemented_error &){
+ //just ignore this error, makes older fw work...
+ }
device_args = separate_device_addr(device_addr); //update args for new frame sizes
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt
index 26c02b5b4..1314f7475 100644
--- a/host/lib/utils/CMakeLists.txt
+++ b/host/lib/utils/CMakeLists.txt
@@ -112,6 +112,19 @@ SET_SOURCE_FILES_PROPERTIES(
)
########################################################################
+# Define UHD_PKG_DATA_PATH for paths.cpp
+########################################################################
+FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH)
+STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH})
+MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}")
+
+SET_SOURCE_FILES_PROPERTIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp
+ PROPERTIES COMPILE_DEFINITIONS
+ "UHD_PKG_DATA_PATH=\"${UHD_PKG_DATA_PATH}\""
+)
+
+########################################################################
# Append sources
########################################################################
LIBUHD_APPEND_SOURCES(
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index a0e4da547..a3dd377e5 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include "constants.hpp"
#include <uhd/config.hpp>
#include <boost/tokenizer.hpp>
#include <boost/filesystem.hpp>
diff --git a/host/lib/version.cpp b/host/lib/version.cpp
index 93fdecb1a..d75cc8fda 100644
--- a/host/lib/version.cpp
+++ b/host/lib/version.cpp
@@ -15,13 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include "constants.hpp"
#include <uhd/version.hpp>
-
-std::string uhd::get_version_string(void){
- return UHD_VERSION_STRING;
-}
-
#include <uhd/utils/static.hpp>
#include <boost/version.hpp>
#include <iostream>
@@ -31,7 +25,7 @@ UHD_STATIC_BLOCK(print_system_info){
<< BOOST_PLATFORM << "; "
<< BOOST_COMPILER << "; "
<< "Boost_" << BOOST_VERSION << "; "
- << "UHD_" << uhd::get_version_string()
+ << "UHD_" << UHD_VERSION_STRING
<< std::endl << std::endl
;
}