aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/mboard_eeprom.cpp
diff options
context:
space:
mode:
authormichael-west <michael.west@ettus.com>2017-01-04 16:57:53 -0800
committerMartin Braun <martin.braun@ettus.com>2017-01-10 13:51:53 -0800
commit64b4c1f5d7554c272884d67d0bf3d0d3d48c77ba (patch)
treed66fa051ce101e11bf30b5fb6217d195723df1bf /host/lib/usrp/mboard_eeprom.cpp
parent29b0fa17382c3dd9c27c556d1c5aa88f0863cb33 (diff)
downloaduhd-64b4c1f5d7554c272884d67d0bf3d0d3d48c77ba.tar.gz
uhd-64b4c1f5d7554c272884d67d0bf3d0d3d48c77ba.tar.bz2
uhd-64b4c1f5d7554c272884d67d0bf3d0d3d48c77ba.zip
X300: Prevent MB EEPROM Corruption
- Load EEPROM data into firmware memory to access from there instead of driving the I2C bus directly - Fixed firmware performance issues by removing the popcntll() function and reducing frequency of background tasks to once every 10ms - Added x300_mb_eeprom_iface to handle cases of devices with older and newer firmware - Added checks for claim to device before driving the I2C bus
Diffstat (limited to 'host/lib/usrp/mboard_eeprom.cpp')
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp72
1 files changed, 54 insertions, 18 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index f10e0319a..4cf58cd05 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -235,52 +235,88 @@ struct x300_eeprom_map
static void load_x300(mboard_eeprom_t &mb_eeprom, i2c_iface &iface)
{
+ byte_vector_t bytes = iface.read_eeprom(X300_EEPROM_ADDR, 0, sizeof (struct x300_eeprom_map));
+
+ if (bytes.size() == 0)
+ {
+ return;
+ }
+
//extract the revision number
mb_eeprom["revision"] = uint16_bytes_to_string(
- iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision), 2)
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, revision),
+ bytes.begin() + (offsetof(x300_eeprom_map, revision)+2))
);
//extract the revision compat number
mb_eeprom["revision_compat"] = uint16_bytes_to_string(
- iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision_compat), 2)
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, revision_compat),
+ bytes.begin() + (offsetof(x300_eeprom_map, revision_compat)+2))
);
//extract the product code
mb_eeprom["product"] = uint16_bytes_to_string(
- iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, product), 2)
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, product),
+ bytes.begin() + (offsetof(x300_eeprom_map, product)+2))
);
//extract the mac addresses
- mb_eeprom["mac-addr0"] = mac_addr_t::from_bytes(iface.read_eeprom(
- X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr0), 6
- )).to_string();
- mb_eeprom["mac-addr1"] = mac_addr_t::from_bytes(iface.read_eeprom(
- X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr1), 6
- )).to_string();
+ mb_eeprom["mac-addr0"] = mac_addr_t::from_bytes(
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, mac_addr0),
+ bytes.begin() + (offsetof(x300_eeprom_map, mac_addr0)+6))
+ ).to_string();
+ mb_eeprom["mac-addr1"] = mac_addr_t::from_bytes(
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, mac_addr1),
+ bytes.begin() + (offsetof(x300_eeprom_map, mac_addr1)+6))
+ ).to_string();
//extract the ip addresses
boost::asio::ip::address_v4::bytes_type ip_addr_bytes;
- byte_copy(iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, gateway), 4), ip_addr_bytes);
+ byte_copy(
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, gateway),
+ bytes.begin() + (offsetof(x300_eeprom_map, gateway)+4)),
+ ip_addr_bytes
+ );
mb_eeprom["gateway"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
for (size_t i = 0; i < 4; i++)
{
const std::string n(1, i+'0');
- byte_copy(iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, ip_addr)+(i*4), 4), ip_addr_bytes);
+ byte_copy(
+ byte_vector_t(
+ bytes.begin() + (offsetof(x300_eeprom_map, ip_addr)+(i*4)),
+ bytes.begin() + (offsetof(x300_eeprom_map, ip_addr)+(i*4)+4)),
+ ip_addr_bytes
+ );
mb_eeprom["ip-addr"+n] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
- byte_copy(iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, subnet)+(i*4), 4), ip_addr_bytes);
+ byte_copy(
+ byte_vector_t(
+ bytes.begin() + (offsetof(x300_eeprom_map, subnet)+(i*4)),
+ bytes.begin() + (offsetof(x300_eeprom_map, subnet)+(i*4)+4)),
+ ip_addr_bytes
+ );
mb_eeprom["subnet"+n] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
}
//extract the serial
- mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
- X300_EEPROM_ADDR, offsetof(x300_eeprom_map, serial), SERIAL_LEN
- ));
+ mb_eeprom["serial"] = bytes_to_string(
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, serial),
+ bytes.begin() + (offsetof(x300_eeprom_map, serial)+SERIAL_LEN))
+ );
//extract the name
- mb_eeprom["name"] = bytes_to_string(iface.read_eeprom(
- X300_EEPROM_ADDR, offsetof(x300_eeprom_map, name), NAME_MAX_LEN
- ));
+ mb_eeprom["name"] = bytes_to_string(
+ byte_vector_t(
+ bytes.begin() + offsetof(x300_eeprom_map, name),
+ bytes.begin() + (offsetof(x300_eeprom_map, name)+NAME_MAX_LEN))
+ );
}
static void store_x300(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface)