diff options
author | Paul David <paul.david@ettus.com> | 2016-05-13 12:02:49 -0700 |
---|---|---|
committer | Paul David <paul.david@ettus.com> | 2016-05-19 09:32:13 -0700 |
commit | 6842e836e17d782bb13e0958de543478298c73d7 (patch) | |
tree | 7b22f510127fe87c5e775d708f5e32682fba33ca /host/lib/usrp/x300 | |
parent | 4e8aaaeb8c767ad444a7afa67993e74d3fef0d90 (diff) | |
download | uhd-6842e836e17d782bb13e0958de543478298c73d7.tar.gz uhd-6842e836e17d782bb13e0958de543478298c73d7.tar.bz2 uhd-6842e836e17d782bb13e0958de543478298c73d7.zip |
x300: Fixed an issue where the wrong XB port was being selected
- If there were duplicate IPs in the mboard eeprom, the last one would be selected instead of the first
- The default IP addresses (used for the case where the mboard eeprom can't be read) would overwrite the previous settings
- Added a warning for duplicate IP entries in the mboard eeprom
Diffstat (limited to 'host/lib/usrp/x300')
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 5930d873c..85deaee90 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -402,10 +402,19 @@ void x300_impl::mboard_members_t::discover_eth( // Index the MB EEPROM addresses std::vector<std::string> mb_eeprom_addrs; - mb_eeprom_addrs.push_back(mb_eeprom["ip-addr0"]); - mb_eeprom_addrs.push_back(mb_eeprom["ip-addr1"]); - mb_eeprom_addrs.push_back(mb_eeprom["ip-addr2"]); - mb_eeprom_addrs.push_back(mb_eeprom["ip-addr3"]); + const size_t num_mb_eeprom_addrs = 4; + for (size_t i = 0; i < num_mb_eeprom_addrs; i++) { + const std::string key = "ip-addr" + boost::to_string(i); + + // Show a warning if there exists duplicate addresses in the mboard eeprom + if (std::find(mb_eeprom_addrs.begin(), mb_eeprom_addrs.end(), mb_eeprom[key]) != mb_eeprom_addrs.end()) { + UHD_MSG(warning) << str(boost::format( + "Duplicate IP address %s found in mboard EEPROM. " + "Device may not function properly.\nView and reprogram the values " + "using the usrp_burn_mb_eeprom utility.\n") % mb_eeprom[key]); + } + mb_eeprom_addrs.push_back(mb_eeprom[key]); + } BOOST_FOREACH(const std::string& addr, ip_addrs) { x300_eth_conn_t conn_iface; @@ -422,22 +431,38 @@ void x300_impl::mboard_members_t::discover_eth( } else { conn_iface.type = X300_IFACE_ETH1; } + break; } } - // Check default IP addresses - if (addr == boost::asio::ip::address_v4( - boost::uint32_t(X300_DEFAULT_IP_ETH0_1G)).to_string()) { - conn_iface.type = X300_IFACE_ETH0; - } else if (addr == boost::asio::ip::address_v4( - boost::uint32_t(X300_DEFAULT_IP_ETH1_1G)).to_string()) { - conn_iface.type = X300_IFACE_ETH1; - } else if (addr == boost::asio::ip::address_v4( - boost::uint32_t(X300_DEFAULT_IP_ETH0_10G)).to_string()) { - conn_iface.type = X300_IFACE_ETH0; - } else if (addr == boost::asio::ip::address_v4( - boost::uint32_t(X300_DEFAULT_IP_ETH1_10G)).to_string()) { - conn_iface.type = X300_IFACE_ETH1; + // Check default IP addresses if we couldn't + // determine the IP from the mboard eeprom + if (conn_iface.type == X300_IFACE_NONE) { + UHD_MSG(warning) << str(boost::format( + "Address %s not found in mboard EEPROM. Address may be wrong or " + "the EEPROM may be corrupt.\n Attempting to continue with default " + "IP addresses.\n") % conn_iface.addr + ); + + if (addr == boost::asio::ip::address_v4( + boost::uint32_t(X300_DEFAULT_IP_ETH0_1G)).to_string()) { + conn_iface.type = X300_IFACE_ETH0; + } else if (addr == boost::asio::ip::address_v4( + boost::uint32_t(X300_DEFAULT_IP_ETH1_1G)).to_string()) { + conn_iface.type = X300_IFACE_ETH1; + } else if (addr == boost::asio::ip::address_v4( + boost::uint32_t(X300_DEFAULT_IP_ETH0_10G)).to_string()) { + conn_iface.type = X300_IFACE_ETH0; + } else if (addr == boost::asio::ip::address_v4( + boost::uint32_t(X300_DEFAULT_IP_ETH1_10G)).to_string()) { + conn_iface.type = X300_IFACE_ETH1; + } else { + throw uhd::assertion_error(str(boost::format( + "X300 Initialization Error: Failed to match address %s with " + "any addresses for the device. Please check the address.") + % conn_iface.addr + )); + } } // Save to a vector of connections @@ -459,7 +484,7 @@ void x300_impl::mboard_members_t::discover_eth( catch(std::exception &) { throw uhd::io_error(str(boost::format( - "X300 Initialization: Invalid address %s") + "X300 Initialization Error: Invalid address %s") % conn_iface.addr)); } eth_conns.push_back(conn_iface); |