aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp32
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp6
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp6
-rw-r--r--host/utils/usrp_burn_mb_eeprom.cpp24
4 files changed, 39 insertions, 29 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index 49d429674..076d0b279 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -101,31 +101,35 @@ static void load_nxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
//parse the revision number
- boost::uint16_t rev = boost::lexical_cast<boost::uint16_t>(mb_eeprom["rev"]);
- byte_vector_t rev_lsb_msb = boost::assign::list_of
- (boost::uint8_t(rev >> 0))
- (boost::uint8_t(rev >> 8))
- ;
- iface.write_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["rev-lsb-msb"], rev_lsb_msb);
+ if (mb_eeprom.has_key("rev")){
+ boost::uint16_t rev = boost::lexical_cast<boost::uint16_t>(mb_eeprom["rev"]);
+ byte_vector_t rev_lsb_msb = boost::assign::list_of
+ (boost::uint8_t(rev >> 0))
+ (boost::uint8_t(rev >> 8))
+ ;
+ iface.write_eeprom(NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["rev-lsb-msb"], rev_lsb_msb);
+ }
//store the addresses
- iface.write_eeprom(
+ if (mb_eeprom.has_key("mac-addr")) iface.write_eeprom(
NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["mac-addr"],
mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes()
);
- byte_vector_t ip_addr_bytes(4);
- 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);
+ if (mb_eeprom.has_key("ip-addr")){
+ byte_vector_t ip_addr_bytes(4);
+ 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 serial
- iface.write_eeprom(
+ if (mb_eeprom.has_key("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(
+ if (mb_eeprom.has_key("name")) iface.write_eeprom(
NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"],
string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
);
@@ -156,13 +160,13 @@ static void load_b1xx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
static void store_b1xx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
//store the serial
- iface.write_eeprom(
+ if (mb_eeprom.has_key("serial")) iface.write_eeprom(
B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["serial"],
string_to_bytes(mb_eeprom["serial"], B1XXX_SERIAL_LEN)
);
//store the name
- iface.write_eeprom(
+ if (mb_eeprom.has_key("name")) iface.write_eeprom(
B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["name"],
string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
);
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index 952da8dce..c1f0f1d38 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -378,8 +378,10 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
return;
case MBOARD_PROP_EEPROM_MAP:
- _iface->mb_eeprom = val.as<mboard_eeprom_t>();
- _iface->mb_eeprom.commit(*_iface, mboard_eeprom_t::MAP_B1XX);
+ // Step1: commit the map, writing only those values set.
+ // Step2: readback the entire eeprom map into the iface.
+ val.as<mboard_eeprom_t>().commit(*_iface, mboard_eeprom_t::MAP_B1XX);
+ _iface->mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_B1XX);
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 079f096cb..df98ba275 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -314,8 +314,10 @@ void usrp2_mboard_impl::set(const wax::obj &key, const wax::obj &val){
return;
case MBOARD_PROP_EEPROM_MAP:
- _iface->mb_eeprom = val.as<mboard_eeprom_t>();
- _iface->mb_eeprom.commit(*_iface, mboard_eeprom_t::MAP_NXXX);
+ // Step1: commit the map, writing only those values set.
+ // Step2: readback the entire eeprom map into the iface.
+ val.as<mboard_eeprom_t>().commit(*_iface, mboard_eeprom_t::MAP_NXXX);
+ _iface->mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_NXXX);
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/utils/usrp_burn_mb_eeprom.cpp b/host/utils/usrp_burn_mb_eeprom.cpp
index 8d0835222..20e1b58b1 100644
--- a/host/utils/usrp_burn_mb_eeprom.cpp
+++ b/host/utils/usrp_burn_mb_eeprom.cpp
@@ -53,25 +53,27 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << "Creating USRP device from address: " + args << std::endl;
uhd::device::sptr dev = uhd::device::make(args);
- std::cout << std::endl;
-
- std::cout << "Fetching current settings from EEPROM..." << std::endl;
//FIXME the default mboard for now (may be others)
wax::obj mboard = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD];
- uhd::usrp::mboard_eeprom_t mb_eeprom = \
- mboard[uhd::usrp::MBOARD_PROP_EEPROM_MAP].as<uhd::usrp::mboard_eeprom_t>();
- if (not mb_eeprom.has_key(key)){
- std::cerr << boost::format("Cannot find value for EEPROM[%s]") % key << std::endl;
- return ~0;
- }
- std::cout << boost::format(" EEPROM [\"%s\"] is \"%s\"") % key % mb_eeprom[key] << std::endl;
std::cout << std::endl;
+ if (true /*always readback*/){
+ std::cout << "Fetching current settings from EEPROM..." << std::endl;
+ uhd::usrp::mboard_eeprom_t mb_eeprom = \
+ mboard[uhd::usrp::MBOARD_PROP_EEPROM_MAP].as<uhd::usrp::mboard_eeprom_t>();
+ if (not mb_eeprom.has_key(key)){
+ std::cerr << boost::format("Cannot find value for EEPROM[%s]") % key << std::endl;
+ return ~0;
+ }
+ std::cout << boost::format(" EEPROM [\"%s\"] is \"%s\"") % key % mb_eeprom[key] << std::endl;
+ std::cout << std::endl;
+ }
if (vm.count("val")){
+ uhd::usrp::mboard_eeprom_t mb_eeprom; mb_eeprom[key] = val;
std::cout << boost::format("Setting EEPROM [\"%s\"] to \"%s\"...") % key % val << std::endl;
- mb_eeprom[key] = val;
mboard[uhd::usrp::MBOARD_PROP_EEPROM_MAP] = mb_eeprom;
std::cout << "Power-cycle the USRP device for the changes to take effect." << std::endl;
+ std::cout << std::endl;
}
std::cout << "Done" << std::endl;