summaryrefslogtreecommitdiffstats
path: root/host/utils
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-09 18:38:39 -0800
committerJosh Blum <josh@joshknows.com>2010-11-09 18:38:39 -0800
commit3bca8c492514564a065e34d3284cb468873fcc8c (patch)
tree73f11afc14eb62ac1c1ff5374dce9c3cb33c0278 /host/utils
parent073518083f2c7044d4b0c16948a192c5623d0752 (diff)
parentc0dfc2cf47b98734c4218427c7c6f5eb92025a9c (diff)
downloaduhd-3bca8c492514564a065e34d3284cb468873fcc8c.tar.gz
uhd-3bca8c492514564a065e34d3284cb468873fcc8c.tar.bz2
uhd-3bca8c492514564a065e34d3284cb468873fcc8c.zip
Merge branch 'master' into usrp_e_next
Diffstat (limited to 'host/utils')
-rw-r--r--host/utils/CMakeLists.txt12
-rw-r--r--host/utils/uhd_usrp_probe.cpp8
-rw-r--r--host/utils/usrp1_serial_burner.cpp75
-rw-r--r--host/utils/usrp2_addr_burner.cpp91
-rw-r--r--host/utils/usrp_burn_db_eeprom.cpp6
-rw-r--r--host/utils/usrp_burn_mb_eeprom.cpp81
6 files changed, 92 insertions, 181 deletions
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt
index 280c8dfaa..a9148de6d 100644
--- a/host/utils/CMakeLists.txt
+++ b/host/utils/CMakeLists.txt
@@ -57,23 +57,19 @@ INSTALL(TARGETS
########################################################################
# Utilities that get installed into the share path
########################################################################
-ADD_EXECUTABLE(usrp2_addr_burner usrp2_addr_burner.cpp)
-TARGET_LINK_LIBRARIES(usrp2_addr_burner uhd)
-
ADD_EXECUTABLE(usrp_burn_db_eeprom usrp_burn_db_eeprom.cpp)
TARGET_LINK_LIBRARIES(usrp_burn_db_eeprom uhd)
+ADD_EXECUTABLE(usrp_burn_mb_eeprom usrp_burn_mb_eeprom.cpp)
+TARGET_LINK_LIBRARIES(usrp_burn_mb_eeprom uhd)
+
ADD_EXECUTABLE(usrp1_init_eeprom usrp1_init_eeprom.cpp)
TARGET_LINK_LIBRARIES(usrp1_init_eeprom uhd)
-ADD_EXECUTABLE(usrp1_serial_burner usrp1_serial_burner.cpp)
-TARGET_LINK_LIBRARIES(usrp1_serial_burner uhd)
-
INSTALL(TARGETS
- usrp2_addr_burner
usrp_burn_db_eeprom
+ usrp_burn_mb_eeprom
usrp1_init_eeprom
- usrp1_serial_burner
RUNTIME DESTINATION ${PKG_DATA_DIR}/utils
)
diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp
index 8947034d7..8cea52fa6 100644
--- a/host/utils/uhd_usrp_probe.cpp
+++ b/host/utils/uhd_usrp_probe.cpp
@@ -26,6 +26,7 @@
#include <uhd/usrp/dsp_props.hpp>
#include <uhd/usrp/subdev_props.hpp>
#include <uhd/usrp/dboard_id.hpp>
+#include <uhd/usrp/mboard_eeprom.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <boost/foreach.hpp>
@@ -123,10 +124,9 @@ static std::string get_mboard_pp_string(wax::obj mboard){
std::stringstream ss;
ss << boost::format("Mboard: %s") % mboard[usrp::MBOARD_PROP_NAME].as<std::string>() << std::endl;
//ss << std::endl;
- BOOST_FOREACH(const std::string &other_name, mboard[usrp::MBOARD_PROP_OTHERS].as<prop_names_t>()){
- try{
- ss << boost::format("%s: %s") % other_name % mboard[other_name].as<std::string>() << std::endl;
- } catch(...){}
+ usrp::mboard_eeprom_t mb_eeprom = mboard[usrp::MBOARD_PROP_EEPROM_MAP].as<usrp::mboard_eeprom_t>();
+ BOOST_FOREACH(const std::string &key, mb_eeprom.keys()){
+ if (not mb_eeprom[key].empty()) ss << boost::format("%s: %s") % key % mb_eeprom[key] << std::endl;
}
BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_RX_DSP_NAMES].as<prop_names_t>()){
ss << make_border(get_dsp_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DSP, dsp_name)]));
diff --git a/host/utils/usrp1_serial_burner.cpp b/host/utils/usrp1_serial_burner.cpp
deleted file mode 100644
index bf7d3d3bb..000000000
--- a/host/utils/usrp1_serial_burner.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/utils/safe_main.hpp>
-#include <uhd/device.hpp>
-#include <uhd/usrp/device_props.hpp>
-#include <boost/program_options.hpp>
-#include <boost/format.hpp>
-#include <iostream>
-
-namespace po = boost::program_options;
-
-int UHD_SAFE_MAIN(int argc, char *argv[]){
- po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ("old", po::value<std::string>(), "old USRP serial number (optional)")
- ("new", po::value<std::string>(), "new USRP serial number")
- ;
-
- po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
-
- //print the help message
- if (vm.count("help")){
- std::cout << boost::format("USRP serial burner %s") % desc << std::endl;
- return ~0;
- }
-
- if(vm.count("new") == 0) {
- std::cout << "error: must input --new arg" << std::endl;
- return ~0;
- }
-
- //load the options into the address
- uhd::device_addr_t device_addr;
- device_addr["type"] = "usrp1";
- if(vm.count("old")) device_addr["serial"] = vm["old"].as<std::string>();
-
- //find and create a control transport to do the writing.
-
- uhd::device_addrs_t found_addrs = uhd::device::find(device_addr);
-
- if (found_addrs.size() == 0){
- std::cerr << "No USRP devices found" << std::endl;
- return ~0;
- }
-
- for (size_t i = 0; i < found_addrs.size(); i++){
- uhd::device::sptr dev = uhd::device::make(found_addrs[i]);
- wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD];
- std::cout << "Writing serial number..." << std::endl;
- mb[std::string("serial")] = vm["new"].as<std::string>();
- std::cout << "Reading back serial number: " << mb[std::string("serial")].as<std::string>() << std::endl;
- }
-
-
- std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl;
- return 0;
-}
diff --git a/host/utils/usrp2_addr_burner.cpp b/host/utils/usrp2_addr_burner.cpp
deleted file mode 100644
index f0e3434b7..000000000
--- a/host/utils/usrp2_addr_burner.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/utils/safe_main.hpp>
-#include <uhd/device.hpp>
-#include <uhd/usrp/device_props.hpp>
-#include <boost/program_options.hpp>
-#include <boost/format.hpp>
-#include <iostream>
-
-namespace po = boost::program_options;
-
-int UHD_SAFE_MAIN(int argc, char *argv[]){
- po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ("addr", po::value<std::string>(), "resolvable network address")
- ("new-ip", po::value<std::string>(), "new ip address (optional)")
- ("new-mac", po::value<std::string>(), "new mac address (optional)")
- ;
-
- po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
-
- //print the help message
- if (vm.count("help")){
- std::cout << boost::format("USRP2 Address Burner %s") % desc << std::endl;
- return ~0;
- }
-
- //load the options into the address
- uhd::device_addr_t device_addr;
- device_addr["type"] = "usrp2";
- if (vm.count("addr")){
- device_addr["addr"] = vm["addr"].as<std::string>();
- }
- else{
- std::cerr << "Error: missing addr option" << std::endl;
- return ~0;
- }
-
- //create a usrp2 device
- uhd::device::sptr u2_dev = uhd::device::make(device_addr);
- //FIXME usees the default mboard for now (until the mimo link is supported)
- wax::obj u2_mb = (*u2_dev)[uhd::usrp::DEVICE_PROP_MBOARD];
- std::cout << std::endl;
-
- //fetch and print current settings
- std::cout << "Fetching current settings from usrp2 eeprom:" << std::endl;
- std::string curr_ip = u2_mb[std::string("ip-addr")].as<std::string>();
- std::cout << boost::format(" Current IP Address: %s") % curr_ip << std::endl;
- std::string curr_mac = u2_mb[std::string("mac-addr")].as<std::string>();
- std::cout << boost::format(" Current MAC Address: %s") % curr_mac << std::endl;
- std::cout << " Done" << std::endl << std::endl;
-
- //try to set the new ip (if provided)
- if (vm.count("new-ip")){
- std::cout << "Burning a new ip address into the usrp2 eeprom:" << std::endl;
- std::string new_ip = vm["new-ip"].as<std::string>();
- std::cout << boost::format(" New IP Address: %s") % new_ip << std::endl;
- u2_mb[std::string("ip-addr")] = new_ip;
- std::cout << " Done" << std::endl << std::endl;
- }
-
- //try to set the new mac (if provided)
- if (vm.count("new-mac")){
- std::cout << "Burning a new mac address into the usrp2 eeprom:" << std::endl;
- std::string new_mac = vm["new-mac"].as<std::string>();
- std::cout << boost::format(" New MAC Address: %s") % new_mac << std::endl;
- u2_mb[std::string("mac-addr")] = new_mac;
- std::cout << " Done" << std::endl << std::endl;
- }
-
- std::cout << "Power-cycle the usrp2 for the changes to take effect." << std::endl;
- return 0;
-}
diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp
index 64ecf75d6..9afd71a22 100644
--- a/host/utils/usrp_burn_db_eeprom.cpp
+++ b/host/utils/usrp_burn_db_eeprom.cpp
@@ -58,10 +58,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//print the help message
if (vm.count("help")){
- std::cout << boost::format("USRP Burn DB EEPROM %s") % desc << std::endl;
+ std::cout << boost::format("USRP Burn Daughterboard EEPROM %s") % desc << std::endl;
std::cout << boost::format(
- "Omit the id argument to perform readback,\n"
- "Or specify a new id to burn into the eeprom.\n"
+ "Omit the ID argument to perform readback,\n"
+ "Or specify a new ID to burn into the EEPROM.\n"
) << std::endl;
return ~0;
}
diff --git a/host/utils/usrp_burn_mb_eeprom.cpp b/host/utils/usrp_burn_mb_eeprom.cpp
new file mode 100644
index 000000000..20e1b58b1
--- /dev/null
+++ b/host/utils/usrp_burn_mb_eeprom.cpp
@@ -0,0 +1,81 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include <uhd/utils/safe_main.hpp>
+#include <uhd/device.hpp>
+#include <uhd/usrp/device_props.hpp>
+#include <uhd/usrp/mboard_props.hpp>
+#include <uhd/usrp/mboard_eeprom.hpp>
+#include <boost/program_options.hpp>
+#include <boost/format.hpp>
+#include <iostream>
+
+namespace po = boost::program_options;
+
+int UHD_SAFE_MAIN(int argc, char *argv[]){
+ std::string args, key, val;
+
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "help message")
+ ("args", po::value<std::string>(&args)->default_value(""), "device address args [default = \"\"]")
+ ("key", po::value<std::string>(&key), "the indentifier for a value in EEPROM")
+ ("val", po::value<std::string>(&val), "the new value to set, omit for readback")
+ ;
+
+ po::variables_map vm;
+ po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::notify(vm);
+
+ //print the help message
+ if (vm.count("help") or not vm.count("key")){
+ std::cout << boost::format("USRP Burn Motherboard EEPROM %s") % desc << std::endl;
+ std::cout << boost::format(
+ "Omit the value argument to perform a readback,\n"
+ "Or specify a new value to burn into the EEPROM.\n"
+ ) << std::endl;
+ return ~0;
+ }
+
+ std::cout << "Creating USRP device from address: " + args << std::endl;
+ uhd::device::sptr dev = uhd::device::make(args);
+ //FIXME the default mboard for now (may be others)
+ wax::obj mboard = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD];
+ 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;
+ 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;
+ return 0;
+}