diff options
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 32 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/mboard_impl.cpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/mboard_impl.cpp | 6 |
3 files changed, 26 insertions, 18 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(); |