aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/n230/n230_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/n230/n230_impl.cpp')
-rw-r--r--host/lib/usrp/n230/n230_impl.cpp76
1 files changed, 39 insertions, 37 deletions
diff --git a/host/lib/usrp/n230/n230_impl.cpp b/host/lib/usrp/n230/n230_impl.cpp
index b3cc4ab59..ab7fa6fe6 100644
--- a/host/lib/usrp/n230/n230_impl.cpp
+++ b/host/lib/usrp/n230/n230_impl.cpp
@@ -17,9 +17,6 @@
#include "n230_impl.hpp"
-#include "../../../firmware/usrp3/n230/n230_fw_host_iface.h"
-#include "../../../firmware/usrp3/n230/n230_fw_defs.h"
-#include "../../../firmware/usrp3/include/fw_comm_protocol.h"
#include "usrp3_fw_ctrl_iface.hpp"
#include "validate_subdev_spec.hpp"
#include <uhd/utils/static.hpp>
@@ -31,6 +28,7 @@
#include <uhd/utils/msg.hpp>
#include <uhd/types/sensors.hpp>
#include <uhd/types/ranges.hpp>
+#include <uhd/types/direction.hpp>
#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/usrp/gps_ctrl.hpp>
@@ -43,8 +41,12 @@
#include <boost/asio/ip/address_v4.hpp>
#include <boost/asio.hpp> //used for htonl and ntohl
#include <boost/make_shared.hpp>
+
+#include "../common/fw_comm_protocol.h"
#include "n230_defaults.h"
#include "n230_fpga_defs.h"
+#include "n230_fw_defs.h"
+#include "n230_fw_host_iface.h"
namespace uhd { namespace usrp { namespace n230 {
@@ -180,13 +182,37 @@ n230_impl::n230_impl(const uhd::device_addr_t& dev_addr)
//TODO: Only supports one motherboard per device class.
const fs_path mb_path = "/mboards/0";
- //Initialize subsystems
+ //Initialize addresses
std::vector<std::string> ip_addrs(1, dev_addr["addr"]);
if (dev_addr.has_key("secondary-addr")) {
ip_addrs.push_back(dev_addr["secondary-addr"]);
}
- _resource_mgr = boost::make_shared<n230_resource_manager>(ip_addrs, _dev_args.get_safe_mode());
+
+ //Read EEPROM and perform version checks before talking to HW
_eeprom_mgr = boost::make_shared<n230_eeprom_manager>(ip_addrs[0]);
+ const mboard_eeprom_t& mb_eeprom = _eeprom_mgr->get_mb_eeprom();
+ bool recover_mb_eeprom = dev_addr.has_key("recover_mb_eeprom");
+ if (recover_mb_eeprom) {
+ UHD_MSG(warning) << "UHD is operating in EEPROM Recovery Mode which disables hardware version "
+ "checks.\nOperating in this mode may cause hardware damage and unstable "
+ "radio performance!"<< std::endl;
+ }
+ boost::uint16_t hw_rev = boost::lexical_cast<boost::uint16_t>(mb_eeprom["revision"]);
+ boost::uint16_t hw_rev_compat = boost::lexical_cast<boost::uint16_t>(mb_eeprom["revision_compat"]);
+ if (not recover_mb_eeprom) {
+ if (hw_rev_compat > N230_HW_REVISION_COMPAT) {
+ throw uhd::runtime_error(str(boost::format(
+ "Hardware is too new for this software. Please upgrade to a driver that supports hardware revision %d.")
+ % hw_rev));
+ } else if (hw_rev < N230_HW_REVISION_MIN) { //Compare min against the revision (and not compat) to give us more leeway for partial support for a compat
+ throw uhd::runtime_error(str(boost::format(
+ "Software is too new for this hardware. Please downgrade to a driver that supports hardware revision %d.")
+ % hw_rev));
+ }
+ }
+
+ //Initialize all subsystems
+ _resource_mgr = boost::make_shared<n230_resource_manager>(ip_addrs, _dev_args.get_safe_mode());
_stream_mgr = boost::make_shared<n230_stream_manager>(_dev_args, _resource_mgr, _tree);
//Build property tree
@@ -459,38 +485,14 @@ void n230_impl::_initialize_radio_properties(const fs_path& mb_path, size_t inst
.publish(boost::bind(&tx_dsp_core_3000::get_freq_range, perif.duc));
//RF Frontend Interfacing
- static const std::vector<std::string> data_directions = boost::assign::list_of("tx")("rx");
- BOOST_FOREACH(const std::string& direction, data_directions) {
- const std::string key = boost::to_upper_copy(direction) + str(boost::format("%u") % (instance + 1));
- const fs_path rf_fe_path = mb_path / "dboards" / "A" / (direction + "_frontends") / ((instance==0)?"A":"B");
-
- _tree->create<std::string>(rf_fe_path / "name")
- .set("FE-" + key);
- _tree->create<int>(rf_fe_path / "sensors"); //empty TODO
- BOOST_FOREACH(const std::string &name, ad9361_ctrl::get_gain_names(key)) {
- _tree->create<meta_range_t>(rf_fe_path / "gains" / name / "range")
- .set(ad9361_ctrl::get_gain_range(key));
- _tree->create<double>(rf_fe_path / "gains" / name / "value")
- .coerce(boost::bind(&ad9361_ctrl::set_gain, _resource_mgr->get_codec_ctrl_sptr(), key, _1))
- .set(n230::DEFAULT_FE_GAIN);
- }
- _tree->create<std::string>(rf_fe_path / "connection")
- .set("IQ");
- _tree->create<bool>(rf_fe_path / "enabled")
- .set(true);
- _tree->create<bool>(rf_fe_path / "use_lo_offset")
- .set(false);
- _tree->create<double>(rf_fe_path / "bandwidth" / "value")
- .coerce(boost::bind(&ad9361_ctrl::set_bw_filter, _resource_mgr->get_codec_ctrl_sptr(), key, _1))
- .set(n230::DEFAULT_FE_BW);
- _tree->create<meta_range_t>(rf_fe_path / "bandwidth" / "range")
- .publish(boost::bind(&ad9361_ctrl::get_bw_filter_range, key));
- _tree->create<double>(rf_fe_path / "freq" / "value")
- .set(n230::DEFAULT_FE_FREQ)
- .coerce(boost::bind(&ad9361_ctrl::tune, _resource_mgr->get_codec_ctrl_sptr(), key, _1))
- .subscribe(boost::bind(&n230_frontend_ctrl::set_bandsel, _resource_mgr->get_frontend_ctrl_sptr(), key, _1));
- _tree->create<meta_range_t>(rf_fe_path / "freq" / "range")
- .publish(boost::bind(&ad9361_ctrl::get_rf_freq_range));
+ static const std::vector<direction_t> data_directions = boost::assign::list_of(RX_DIRECTION)(TX_DIRECTION);
+ BOOST_FOREACH(direction_t direction, data_directions) {
+ const std::string dir_str = (direction == RX_DIRECTION) ? "rx" : "tx";
+ const std::string key = boost::to_upper_copy(dir_str) + str(boost::format("%u") % (instance + 1));
+ const fs_path rf_fe_path = mb_path / "dboards" / "A" / (dir_str + "_frontends") / ((instance==0)?"A":"B");
+
+ //CODEC subtree
+ _resource_mgr->get_codec_mgr().populate_frontend_subtree(_tree->subtree(rf_fe_path), key, direction);
//User settings
_tree->create<uhd::wb_iface::sptr>(rf_fe_path / "user_settings" / "iface")