aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/usrp/mboard_eeprom.hpp23
-rw-r--r--host/include/uhd/usrp/mboard_props.hpp3
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp93
-rw-r--r--host/lib/usrp/usrp2/fw_common.h4
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp66
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp15
6 files changed, 87 insertions, 117 deletions
diff --git a/host/include/uhd/usrp/mboard_eeprom.hpp b/host/include/uhd/usrp/mboard_eeprom.hpp
index 0d57105b9..3bb05c0a8 100644
--- a/host/include/uhd/usrp/mboard_eeprom.hpp
+++ b/host/include/uhd/usrp/mboard_eeprom.hpp
@@ -21,24 +21,18 @@
#include <uhd/config.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/serial.hpp>
-#include <boost/utility.hpp>
-#include <boost/shared_ptr.hpp>
#include <string>
namespace uhd{ namespace usrp{
/*!
- * The motherboard EEPROM class:
+ * The motherboard EEPROM object:
* Knows how to read and write the EEPROM for various USRPs.
* The class inherits from a string, string dictionary.
* Use the dictionary interface to get and set values.
* Commit to the EEPROM to save changed settings.
*/
- class UHD_API mboard_eeprom_t: boost::noncopyable,
- public uhd::dict<std::string, std::string>
- {
- public:
- typedef boost::shared_ptr<mboard_eeprom_t> sptr;
+ struct UHD_API mboard_eeprom_t : uhd::dict<std::string, std::string>{
//! Possible EEPROM maps types
enum map_type{
@@ -48,14 +42,17 @@ namespace uhd{ namespace usrp{
/*!
* Make a new mboard EEPROM handler.
- * \param map the map type enum
* \param iface the interface to i2c
- * \return a new mboard EEPROM object
+ * \param map the map type enum
*/
- static sptr make(map_type map, i2c_iface &iface);
+ mboard_eeprom_t(i2c_iface &iface, map_type map);
- //! Write the contents of this object to the EEPROM.
- virtual void commit(void) = 0;
+ /*!
+ * Write the contents of this object to the EEPROM.
+ * \param iface the interface to i2c
+ * \param map the map type enum
+ */
+ void commit(i2c_iface &iface, map_type map);
};
diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp
index 0f250f439..df94d1678 100644
--- a/host/include/uhd/usrp/mboard_props.hpp
+++ b/host/include/uhd/usrp/mboard_props.hpp
@@ -44,7 +44,8 @@ namespace uhd{ namespace usrp{
MBOARD_PROP_CLOCK_CONFIG = 'C', //rw, clock_config_t
MBOARD_PROP_TIME_NOW = 't', //rw, time_spec_t
MBOARD_PROP_TIME_NEXT_PPS = 'T', //wo, time_spec_t
- MBOARD_PROP_STREAM_CMD = 's' //wo, stream_cmd_t
+ MBOARD_PROP_STREAM_CMD = 's', //wo, stream_cmd_t
+ MBOARD_PROP_EEPROM_MAP = 'M' //wr, mboard_eeprom_t::sptr
};
}} //namespace
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index d05be11e6..78b4122bb 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -67,8 +67,8 @@ static const uhd::dict<std::string, boost::uint8_t> USRP_NXXX_OFFSETS = boost::a
("mac-addr", 0x02)
("ip-addr", 0x02 + sizeof(mac_addr_t))
//leave space here for other addresses (perhaps)
- ("name", 0x18)
- ("serial", 0x18 + NAME_MAX_LEN)
+ ("serial", 0x18)
+ ("name", 0x18 + SERIAL_LEN)
;
static void load_nxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
@@ -86,15 +86,15 @@ static void load_nxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
std::copy(iface.read_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["ip-addr"], 4), ip_addr_bytes);
mb_eeprom["ip-addr"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
- //extract the name
- mb_eeprom["name"] = bytes_to_string(iface.read_eeprom(
- NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"], NAME_MAX_LEN
- ));
-
//extract the serial
mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["serial"], SERIAL_LEN
));
+
+ //extract the name
+ mb_eeprom["name"] = bytes_to_string(iface.read_eeprom(
+ NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"], NAME_MAX_LEN
+ ));
}
static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
@@ -116,61 +116,68 @@ static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
std::copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"]).to_bytes(), ip_addr_bytes);
iface.write_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["ip-addr"], ip_addr_bytes);
- //store the name
- iface.write_eeprom(
- NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"],
- string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
- );
-
//store the serial
iface.write_eeprom(
NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["serial"],
string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
);
+
+ //store the name
+ iface.write_eeprom(
+ NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"],
+ string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
+ );
}
/***********************************************************************
* Implementation of BXXX load/store
**********************************************************************/
-//TODO
+static const boost::uint8_t BXXX_EEPROM_ADDR = 0x50;
-static void load_bxxx(mboard_eeprom_t &, i2c_iface &){
-
+static const uhd::dict<std::string, boost::uint8_t> USRP_BXXX_OFFSETS = boost::assign::map_list_of
+ ("serial", 0xf8)
+ ("name", 0xf8 + SERIAL_LEN)
+;
+
+static void load_bxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
+ //extract the serial
+ mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
+ BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["serial"], SERIAL_LEN
+ ));
+
+ //extract the name
+ mb_eeprom["name"] = bytes_to_string(iface.read_eeprom(
+ BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["name"], NAME_MAX_LEN
+ ));
}
-static void store_bxxx(const mboard_eeprom_t &, i2c_iface &){
-
+static void store_bxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
+ //store the serial
+ iface.write_eeprom(
+ BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["serial"],
+ string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
+ );
+
+ //store the name
+ iface.write_eeprom(
+ BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["name"],
+ string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
+ );
}
/***********************************************************************
* Implementation of mboard eeprom
**********************************************************************/
-class mboard_eeprom_impl : public mboard_eeprom_t{
-public:
- mboard_eeprom_impl(map_type map, i2c_iface &iface):
- _map(map), _iface(iface)
- {
- switch(_map){
- case MAP_NXXX: load_nxxx(*this, _iface); break;
- case MAP_BXXX: load_bxxx(*this, _iface); break;
- }
+mboard_eeprom_t::mboard_eeprom_t(i2c_iface &iface, map_type map){
+ switch(map){
+ case MAP_NXXX: load_nxxx(*this, iface); break;
+ case MAP_BXXX: load_bxxx(*this, iface); break;
}
+}
- void commit(void){
- switch(_map){
- case MAP_NXXX: store_nxxx(*this, _iface); break;
- case MAP_BXXX: store_bxxx(*this, _iface); break;
- }
+void mboard_eeprom_t::commit(i2c_iface &iface, map_type map){
+ switch(map){
+ case MAP_NXXX: store_nxxx(*this, iface); break;
+ case MAP_BXXX: store_bxxx(*this, iface); break;
}
-
-private:
- map_type _map;
- i2c_iface &_iface;
-};
-
-/***********************************************************************
- * Factory function for mboard eeprom
- **********************************************************************/
-mboard_eeprom_t::sptr mboard_eeprom_t::make(map_type map, i2c_iface &iface){
- return sptr(new mboard_eeprom_impl(map, iface));
}
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index e812e1221..4c46bbb1d 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -55,8 +55,8 @@ extern "C" {
////////////////////////////////////////////////////////////////////////
// EEPROM Layout
////////////////////////////////////////////////////////////////////////
-#define USRP2_EE_MBOARD_REV_LSB 0x00 //1 byte
-#define USRP2_EE_MBOARD_REV_MSB 0x01 //1 byte
+//#define USRP2_EE_MBOARD_REV_LSB 0x00 //1 byte
+//#define USRP2_EE_MBOARD_REV_MSB 0x01 //1 byte
#define USRP2_EE_MBOARD_MAC_ADDR 0x02 //6 bytes
#define USRP2_EE_MBOARD_IP_ADDR 0x0C //uint32, big-endian
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index a0e6adfad..e7d8aeef6 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -22,11 +22,7 @@
#include <uhd/usrp/mboard_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/algorithm.hpp>
-#include <uhd/types/mac_addr.hpp>
-#include <uhd/types/dict.hpp>
#include <boost/bind.hpp>
-#include <boost/assign/list_of.hpp>
-#include <boost/asio/ip/address_v4.hpp>
#include <iostream>
using namespace uhd;
@@ -41,15 +37,10 @@ usrp2_mboard_impl::usrp2_mboard_impl(
size_t recv_frame_size
):
_index(index),
- _recv_frame_size(recv_frame_size)
+ _recv_frame_size(recv_frame_size),
+ _iface(usrp2_iface::make(ctrl_transport)),
+ _mboard_eeprom(mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_NXXX))
{
- //make a new interface for usrp2 stuff
- _iface = usrp2_iface::make(ctrl_transport);
-
- //extract the mboard rev numbers
- _rev_lo = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV_LSB, 1).at(0);
- _rev_hi = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV_MSB, 1).at(0);
-
//contruct the interfaces to mboard perifs
_clock_ctrl = usrp2_clock_ctrl::make(_iface);
_codec_ctrl = usrp2_codec_ctrl::make(_iface);
@@ -192,35 +183,14 @@ static const std::string dboard_name = "0";
void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
named_prop_t key = named_prop_t::extract(key_);
- //handle the other props
- if (key_.type() == typeid(std::string)){
- if (key.as<std::string>() == "mac-addr"){
- byte_vector_t bytes = _iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, 6);
- val = mac_addr_t::from_bytes(bytes).to_string();
- return;
- }
-
- if (key.as<std::string>() == "ip-addr"){
- boost::asio::ip::address_v4::bytes_type bytes;
- std::copy(_iface->read_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_IP_ADDR, 4), bytes);
- val = boost::asio::ip::address_v4(bytes).to_string();
- return;
- }
- }
-
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
case MBOARD_PROP_NAME:
- val = str(boost::format("usrp2 mboard%d - rev %d:%d") % _index % _rev_hi % _rev_lo);
+ val = str(boost::format("usrp2 mboard%d - rev %s") % _index % _mboard_eeprom["rev"]);
return;
- case MBOARD_PROP_OTHERS:{
- prop_names_t others = boost::assign::list_of
- ("mac-addr")
- ("ip-addr")
- ;
- val = others;
- }
+ case MBOARD_PROP_OTHERS:
+ val = prop_names_t();
return;
case MBOARD_PROP_RX_DBOARD:
@@ -281,6 +251,10 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
val = _tx_subdev_spec;
return;
+ case MBOARD_PROP_EEPROM_MAP:
+ val = _mboard_eeprom;
+ return;
+
default: UHD_THROW_PROP_GET_ERROR();
}
}
@@ -289,21 +263,6 @@ void usrp2_mboard_impl::get(const wax::obj &key_, wax::obj &val){
* MBoard Set Properties
**********************************************************************/
void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
- //handle the other props
- if (key.type() == typeid(std::string)){
- if (key.as<std::string>() == "mac-addr"){
- byte_vector_t bytes = mac_addr_t::from_string(val.as<std::string>()).to_bytes();
- _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_MAC_ADDR, bytes);
- return;
- }
-
- if (key.as<std::string>() == "ip-addr"){
- byte_vector_t bytes(4);
- std::copy(boost::asio::ip::address_v4::from_string(val.as<std::string>()).to_bytes(), bytes);
- _iface->write_eeprom(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_IP_ADDR, bytes);
- return;
- }
- }
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
@@ -347,6 +306,11 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
));
return;
+ case MBOARD_PROP_EEPROM_MAP:
+ _mboard_eeprom = val.as<mboard_eeprom_t>();
+ _mboard_eeprom.commit(*_iface, mboard_eeprom_t::MAP_NXXX);
+ return;
+
default: UHD_THROW_PROP_SET_ERROR();
}
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 558726a2b..7b1a2b1eb 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -29,10 +29,11 @@
#include <uhd/types/stream_cmd.hpp>
#include <uhd/types/clock_config.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
+#include <uhd/usrp/mboard_eeprom.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
-#include <uhd/transport/udp_simple.hpp> //mtu
+#include <uhd/transport/udp_simple.hpp>
#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <uhd/usrp/subdev_spec.hpp>
@@ -94,20 +95,20 @@ public:
private:
size_t _index;
- int _rev_hi, _rev_lo;
const size_t _recv_frame_size;
- //properties for this mboard
- void get(const wax::obj &, wax::obj &);
- void set(const wax::obj &, const wax::obj &);
- uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec;
-
//interfaces
usrp2_iface::sptr _iface;
usrp2_clock_ctrl::sptr _clock_ctrl;
usrp2_codec_ctrl::sptr _codec_ctrl;
usrp2_serdes_ctrl::sptr _serdes_ctrl;
+ //properties for this mboard
+ void get(const wax::obj &, wax::obj &);
+ void set(const wax::obj &, const wax::obj &);
+ uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec;
+ uhd::usrp::mboard_eeprom_t _mboard_eeprom;
+
//rx and tx dboard methods and objects
uhd::usrp::dboard_manager::sptr _dboard_manager;
uhd::usrp::dboard_iface::sptr _dboard_iface;