From b96088b692a5c44974919ee36e253b6ea8c51972 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 31 Aug 2010 16:44:30 -0700 Subject: EEPROM burning in UHD. Changed some USB device handle stuff. Added usrp_init_eeprom.cpp. Hacked up the firmware makefile to behave and to generate .bin EEPROM images instead of IHX. --- host/utils/CMakeLists.txt | 4 +++ host/utils/usrp_init_eeprom.cpp | 69 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 host/utils/usrp_init_eeprom.cpp (limited to 'host/utils') diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index c349a9018..9d788b06c 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -39,9 +39,13 @@ 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_init_eeprom usrp_init_eeprom.cpp) +TARGET_LINK_LIBRARIES(usrp_init_eeprom uhd) + INSTALL(TARGETS usrp2_addr_burner usrp_burn_db_eeprom + usrp_init_eeprom RUNTIME DESTINATION ${PKG_DATA_DIR}/utils ) diff --git a/host/utils/usrp_init_eeprom.cpp b/host/utils/usrp_init_eeprom.cpp new file mode 100644 index 000000000..28c7c5745 --- /dev/null +++ b/host/utils/usrp_init_eeprom.cpp @@ -0,0 +1,69 @@ +// +// 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 . +// + +#include +#include +#include +#include +#include +#include + +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") + ("image", po::value(), "IHX image file") + ; + + 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 EEPROM initialization %s") % desc << std::endl; + return ~0; + } + + //load the options into the address + uhd::device_addr_t device_addr; + device_addr["type"] = "usrp1"; + device_addr["uninit"] = "yeah"; //tell find to look for an uninitialized FX2 + + //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 uninitialized USRP devices found" << std::endl; + return ~0; + } + + for (size_t i = 0; i < found_addrs.size(); i++){ + std::cout << "Writing EEPROM data..." << std::endl; + //uhd::device_addrs_t devs = uhd::device::find(found_addrs[i]); + uhd::device::sptr dev = uhd::device::make(found_addrs[i]); + wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; + mb[std::string("load_eeprom")] = vm["image"].as(); + } + + + std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; + return 0; +} -- cgit v1.2.3 From 7b066a4593646b6023f56283ff02cf0e4ee099a6 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 31 Aug 2010 17:32:55 -0700 Subject: Added usrp_serial_burner.cpp and capabilities for setting serial number in mboard_impl. Have not yet added read support. --- host/lib/usrp/usrp1/mboard_impl.cpp | 12 +++++- host/utils/CMakeLists.txt | 4 ++ host/utils/usrp_init_eeprom.cpp | 2 +- host/utils/usrp_serial_burner.cpp | 74 +++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 host/utils/usrp_serial_burner.cpp (limited to 'host/utils') diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 1409855cb..8555577f5 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -19,6 +19,7 @@ #include "usrp_commands.h" #include "fpga_regs_standard.h" #include "fpga_regs_common.h" +#include "usrp_i2c_addr.h" #include #include #include @@ -321,11 +322,18 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) { if(key.type() == typeid(std::string)) { if(key.as() == "load_eeprom") { - std::string usrp1_fpga_image = val.as(); - std::cout << "USRP1 EEPROM image: " << usrp1_fpga_image << std::endl; + std::string usrp1_eeprom_image = val.as(); + std::cout << "USRP1 EEPROM image: " << usrp1_eeprom_image << std::endl; _ctrl_transport->usrp_load_eeprom(val.as()); } + if(key.as() == "serial") { + std::string sernum = val.as(); + uhd::byte_vector_t buf(sernum.begin(), sernum.end()); + buf.insert(buf.begin(), 248); + _iface->write_i2c(I2C_DEV_EEPROM, buf); + } + return; } diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 9d788b06c..48f91aaa7 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -42,10 +42,14 @@ TARGET_LINK_LIBRARIES(usrp_burn_db_eeprom uhd) ADD_EXECUTABLE(usrp_init_eeprom usrp_init_eeprom.cpp) TARGET_LINK_LIBRARIES(usrp_init_eeprom uhd) +ADD_EXECUTABLE(usrp_serial_burner usrp_serial_burner.cpp) +TARGET_LINK_LIBRARIES(usrp_serial_burner uhd) + INSTALL(TARGETS usrp2_addr_burner usrp_burn_db_eeprom usrp_init_eeprom + usrp_serial_burner RUNTIME DESTINATION ${PKG_DATA_DIR}/utils ) diff --git a/host/utils/usrp_init_eeprom.cpp b/host/utils/usrp_init_eeprom.cpp index 28c7c5745..b05e400b1 100644 --- a/host/utils/usrp_init_eeprom.cpp +++ b/host/utils/usrp_init_eeprom.cpp @@ -28,7 +28,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") - ("image", po::value(), "IHX image file") + ("image", po::value(), "BIN image file") ; po::variables_map vm; diff --git a/host/utils/usrp_serial_burner.cpp b/host/utils/usrp_serial_burner.cpp new file mode 100644 index 000000000..cdb6eff65 --- /dev/null +++ b/host/utils/usrp_serial_burner.cpp @@ -0,0 +1,74 @@ +// +// 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 . +// + +#include +#include +#include +#include +#include +#include + +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(), "old USRP serial number (optional)") + ("new", po::value(), "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(); + + //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::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; + return 0; +} -- cgit v1.2.3 From 4c7a66cfa0b84955fcd34b0e356c1141b21a7e17 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Tue, 31 Aug 2010 17:52:10 -0700 Subject: Added serial number read. Renamed the usrp1-specific utilities. --- host/lib/usrp/usrp1/mboard_impl.cpp | 15 ++++++++ host/utils/CMakeLists.txt | 12 +++--- host/utils/usrp1_init_eeprom.cpp | 69 ++++++++++++++++++++++++++++++++++ host/utils/usrp1_serial_burner.cpp | 75 +++++++++++++++++++++++++++++++++++++ host/utils/usrp_init_eeprom.cpp | 69 ---------------------------------- host/utils/usrp_serial_burner.cpp | 74 ------------------------------------ 6 files changed, 165 insertions(+), 149 deletions(-) create mode 100644 host/utils/usrp1_init_eeprom.cpp create mode 100644 host/utils/usrp1_serial_burner.cpp delete mode 100644 host/utils/usrp_init_eeprom.cpp delete mode 100644 host/utils/usrp_serial_burner.cpp (limited to 'host/utils') diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 8555577f5..a90532cb8 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include using namespace uhd; @@ -251,6 +252,20 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val) { named_prop_t key = named_prop_t::extract(key_); + if(key_.type() == typeid(std::string)) { + if(key.as() == "serial") { + uhd::byte_vector_t buf; + buf.insert(buf.begin(), 248); + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + _iface->write_i2c(I2C_DEV_EEPROM, buf); + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + buf = _iface->read_i2c(I2C_DEV_EEPROM, 8); + val = std::string(buf.begin(), buf.end()); + } + + return; + } + //handle the get request conditioned on the key switch(key.as()){ case MBOARD_PROP_NAME: diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 48f91aaa7..a95864ca7 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -39,17 +39,17 @@ 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_init_eeprom usrp_init_eeprom.cpp) -TARGET_LINK_LIBRARIES(usrp_init_eeprom uhd) +ADD_EXECUTABLE(usrp1_init_eeprom usrp1_init_eeprom.cpp) +TARGET_LINK_LIBRARIES(usrp1_init_eeprom uhd) -ADD_EXECUTABLE(usrp_serial_burner usrp_serial_burner.cpp) -TARGET_LINK_LIBRARIES(usrp_serial_burner 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_init_eeprom - usrp_serial_burner + usrp1_init_eeprom + usrp1_serial_burner RUNTIME DESTINATION ${PKG_DATA_DIR}/utils ) diff --git a/host/utils/usrp1_init_eeprom.cpp b/host/utils/usrp1_init_eeprom.cpp new file mode 100644 index 000000000..b05e400b1 --- /dev/null +++ b/host/utils/usrp1_init_eeprom.cpp @@ -0,0 +1,69 @@ +// +// 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 . +// + +#include +#include +#include +#include +#include +#include + +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") + ("image", po::value(), "BIN image file") + ; + + 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 EEPROM initialization %s") % desc << std::endl; + return ~0; + } + + //load the options into the address + uhd::device_addr_t device_addr; + device_addr["type"] = "usrp1"; + device_addr["uninit"] = "yeah"; //tell find to look for an uninitialized FX2 + + //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 uninitialized USRP devices found" << std::endl; + return ~0; + } + + for (size_t i = 0; i < found_addrs.size(); i++){ + std::cout << "Writing EEPROM data..." << std::endl; + //uhd::device_addrs_t devs = uhd::device::find(found_addrs[i]); + uhd::device::sptr dev = uhd::device::make(found_addrs[i]); + wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; + mb[std::string("load_eeprom")] = vm["image"].as(); + } + + + std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; + return 0; +} diff --git a/host/utils/usrp1_serial_burner.cpp b/host/utils/usrp1_serial_burner.cpp new file mode 100644 index 000000000..bf7d3d3bb --- /dev/null +++ b/host/utils/usrp1_serial_burner.cpp @@ -0,0 +1,75 @@ +// +// 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 . +// + +#include +#include +#include +#include +#include +#include + +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(), "old USRP serial number (optional)") + ("new", po::value(), "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(); + + //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::cout << "Reading back serial number: " << mb[std::string("serial")].as() << std::endl; + } + + + std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; + return 0; +} diff --git a/host/utils/usrp_init_eeprom.cpp b/host/utils/usrp_init_eeprom.cpp deleted file mode 100644 index b05e400b1..000000000 --- a/host/utils/usrp_init_eeprom.cpp +++ /dev/null @@ -1,69 +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 . -// - -#include -#include -#include -#include -#include -#include - -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") - ("image", po::value(), "BIN image file") - ; - - 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 EEPROM initialization %s") % desc << std::endl; - return ~0; - } - - //load the options into the address - uhd::device_addr_t device_addr; - device_addr["type"] = "usrp1"; - device_addr["uninit"] = "yeah"; //tell find to look for an uninitialized FX2 - - //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 uninitialized USRP devices found" << std::endl; - return ~0; - } - - for (size_t i = 0; i < found_addrs.size(); i++){ - std::cout << "Writing EEPROM data..." << std::endl; - //uhd::device_addrs_t devs = uhd::device::find(found_addrs[i]); - uhd::device::sptr dev = uhd::device::make(found_addrs[i]); - wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; - mb[std::string("load_eeprom")] = vm["image"].as(); - } - - - std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; - return 0; -} diff --git a/host/utils/usrp_serial_burner.cpp b/host/utils/usrp_serial_burner.cpp deleted file mode 100644 index cdb6eff65..000000000 --- a/host/utils/usrp_serial_burner.cpp +++ /dev/null @@ -1,74 +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 . -// - -#include -#include -#include -#include -#include -#include - -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(), "old USRP serial number (optional)") - ("new", po::value(), "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(); - - //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::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; - return 0; -} -- cgit v1.2.3 From 6d315076ba2ef5aa7612ebe3cf39f72bc2bb76e5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 9 Sep 2010 11:07:59 -0700 Subject: usrp: dboard eeprom burner app takes slot param (fixed for automatic) --- host/docs/dboards.rst | 4 ++-- host/utils/usrp_burn_db_eeprom.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'host/utils') diff --git a/host/docs/dboards.rst b/host/docs/dboards.rst index 0f6d1cfeb..985fbc12b 100644 --- a/host/docs/dboards.rst +++ b/host/docs/dboards.rst @@ -141,7 +141,7 @@ With the daughterboard plugged-in, run the following commands: :: cd /share/uhd/utils - ./usrp_burn_db_eeprom --id=0x000d --unit=RX --args= --db= + ./usrp_burn_db_eeprom --id=0x000d --unit=RX --args= --slot= * are device address arguments (optional if only one USRP is on your machine) -* is the name of the daughterboard slot (optional if the USRP has only one slot) +* is the name of the daughterboard slot (optional if the USRP has only one slot) diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp index db2981e87..64ecf75d6 100644 --- a/host/utils/usrp_burn_db_eeprom.cpp +++ b/host/utils/usrp_burn_db_eeprom.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -34,16 +35,19 @@ namespace po = boost::program_options; int UHD_SAFE_MAIN(int argc, char *argv[]){ //command line variables - std::string args, db_name, unit; + std::string args, slot, unit; static const uhd::dict unit_to_db_prop = boost::assign::map_list_of ("RX", MBOARD_PROP_RX_DBOARD) ("TX", MBOARD_PROP_TX_DBOARD) ; + static const uhd::dict unit_to_db_names_prop = boost::assign::map_list_of + ("RX", MBOARD_PROP_RX_DBOARD_NAMES) ("TX", MBOARD_PROP_TX_DBOARD_NAMES) + ; po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "device address args [default = \"\"]") - ("db", po::value(&db_name)->default_value(""), "dboard name [default = \"\"]") + ("slot", po::value(&slot)->default_value(""), "dboard slot name [default is blank for automatic]") ("unit", po::value(&unit)->default_value(""), "which unit [RX or TX]") ("id", po::value(), "dboard id to burn, omit for readback") ; @@ -70,8 +74,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //make the device and extract the dboard w/ property device::sptr dev = device::make(args); - wax::obj dboard = (*dev)[DEVICE_PROP_MBOARD][named_prop_t(unit_to_db_prop[unit], db_name)]; - std::string prefix = (db_name == "")? unit : (unit + ":" + db_name); + uhd::prop_names_t dboard_names = (*dev)[DEVICE_PROP_MBOARD][unit_to_db_names_prop[unit]].as(); + if (dboard_names.size() == 1 and slot.empty()) slot = dboard_names.front(); + uhd::assert_has(dboard_names, slot, "dboard slot name"); + wax::obj dboard = (*dev)[DEVICE_PROP_MBOARD][named_prop_t(unit_to_db_prop[unit], slot)]; + std::string prefix = unit + ":" + slot; //read the current dboard id from eeprom if (vm.count("id") == 0){ -- cgit v1.2.3