summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-03-11 17:02:11 +0000
committerJosh Blum <josh@joshknows.com>2011-03-11 17:02:11 +0000
commit6fc9a384a7d9aef9457e7f7015431880f6bf91d8 (patch)
treeefc48dabcc2c15ced30c8f9189bf4dc9c0b7c542
parentuhd: try to be smart when setting up cpack when UHD_PACKAGE_MODE=AUTO (diff)
downloaduhd-6fc9a384a7d9aef9457e7f7015431880f6bf91d8.tar.xz
uhd-6fc9a384a7d9aef9457e7f7015431880f6bf91d8.zip
usrp-e100: added module compat num check, made fpga compat constant more obvious
-rw-r--r--host/lib/usrp/usrp_e100/usrp_e100_iface.cpp11
-rw-r--r--host/lib/usrp/usrp_e100/usrp_e100_impl.cpp8
-rw-r--r--host/lib/usrp/usrp_e100/usrp_e100_impl.hpp2
3 files changed, 15 insertions, 6 deletions
diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp
index ec0baf490..55446da63 100644
--- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp
+++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp
@@ -22,7 +22,7 @@
#include <fcntl.h> //open, close
#include <linux/usrp_e.h> //ioctl structures and constants
#include <boost/format.hpp>
-#include <boost/thread.hpp> //mutex
+#include <boost/thread/mutex.hpp>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <stdexcept>
@@ -109,6 +109,15 @@ public:
throw uhd::io_error("Failed to open " + node);
}
+ //check the module compatibility number
+ int module_compat_num = ::ioctl(_node_fd, USRP_E_GET_COMPAT_NUMBER, NULL);
+ if (module_compat_num != USRP_E_COMPAT_NUMBER){
+ throw uhd::runtime_error(str(boost::format(
+ "Expected module compatibility number 0x%x, but got 0x%x:\n"
+ "The module build is not compatible with the host code build."
+ ) % USRP_E_COMPAT_NUMBER % module_compat_num));
+ }
+
mb_eeprom = mboard_eeprom_t(get_i2c_dev_iface(), mboard_eeprom_t::MAP_E100);
}
diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp
index a120c3303..a8fbe5d69 100644
--- a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp
+++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp
@@ -120,10 +120,10 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){
try{std::ifstream(hash_file_path) >> loaded_hash;}catch(...){}
//if not loaded: load the fpga image and write the hash-file
- if (fpga_compat_num != USRP_E_COMPAT_NUM or loaded_hash != fpga_hash){
+ if (fpga_compat_num != USRP_E_FPGA_COMPAT_NUM or loaded_hash != fpga_hash){
iface.reset();
usrp_e100_load_fpga(usrp_e100_fpga_image);
- sleep(1); ///\todo do this better one day.
+ sleep(1); ///\todo do this better one day.
std::cout << boost::format("re-Opening USRP-E on %s") % node << std::endl;
iface = usrp_e100_iface::make(node);
try{std::ofstream(hash_file_path) << fpga_hash;}catch(...){}
@@ -131,11 +131,11 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){
//check that the compatibility is correct
fpga_compat_num = iface->peek16(UE_REG_MISC_COMPAT);
- if (fpga_compat_num != USRP_E_COMPAT_NUM){
+ if (fpga_compat_num != USRP_E_FPGA_COMPAT_NUM){
throw uhd::runtime_error(str(boost::format(
"Expected fpga compatibility number 0x%x, but got 0x%x:\n"
"The fpga build is not compatible with the host code build."
- ) % USRP_E_COMPAT_NUM % fpga_compat_num));
+ ) % USRP_E_FPGA_COMPAT_NUM % fpga_compat_num));
}
return device::sptr(new usrp_e100_impl(iface));
diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp
index 897616320..98117cf26 100644
--- a/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp
+++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp
@@ -30,7 +30,7 @@
#ifndef INCLUDED_USRP_E100_IMPL_HPP
#define INCLUDED_USRP_E100_IMPL_HPP
-static const boost::uint16_t USRP_E_COMPAT_NUM = 0x03;
+static const boost::uint16_t USRP_E_FPGA_COMPAT_NUM = 0x03;
//! load an fpga image from a bin file into the usrp-e fpga
extern void usrp_e100_load_fpga(const std::string &bin_file);