diff options
Diffstat (limited to 'host/utils')
-rw-r--r-- | host/utils/CMakeLists.txt | 11 | ||||
-rw-r--r-- | host/utils/uhd_usrp_probe.cpp | 23 | ||||
-rw-r--r-- | host/utils/usrp1_init_eeprom.cpp | 6 | ||||
-rwxr-xr-x | host/utils/usrp2_card_burner.py | 22 | ||||
-rw-r--r-- | host/utils/usrp_burn_db_eeprom.cpp | 15 |
5 files changed, 59 insertions, 18 deletions
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 98b5d41fb..b2dd697fc 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -54,6 +54,17 @@ FOREACH(util_source ${util_share_sources}) ENDFOREACH(util_source) IF(ENABLE_USRP2) + IF(WIN32 AND UHD_RELEASE_MODE) #include dd.exe + FILE(DOWNLOAD + "http://www.ettus.com/downloads/dd.exe" + ${CMAKE_CURRENT_BINARY_DIR}/dd.exe + ) + INSTALL(FILES + ${CMAKE_CURRENT_BINARY_DIR}/dd.exe + DESTINATION ${PKG_DATA_DIR}/utils + COMPONENT utilities + ) + ENDIF(WIN32 AND UHD_RELEASE_MODE) INSTALL(PROGRAMS usrp2_recovery.py usrp2_card_burner.py diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp index b32131b2a..3ea63c4bb 100644 --- a/host/utils/uhd_usrp_probe.cpp +++ b/host/utils/uhd_usrp_probe.cpp @@ -27,6 +27,7 @@ #include <uhd/usrp/subdev_props.hpp> #include <uhd/usrp/dboard_id.hpp> #include <uhd/usrp/mboard_eeprom.hpp> +#include <uhd/usrp/dboard_eeprom.hpp> #include <boost/program_options.hpp> #include <boost/format.hpp> #include <boost/foreach.hpp> @@ -46,12 +47,12 @@ static std::string make_border(const std::string &text){ ss << boost::format(" _____________________________________________________") << std::endl; ss << boost::format(" /") << std::endl; std::vector<std::string> lines; boost::split(lines, text, boost::is_any_of("\n")); - while (lines.back() == "") lines.pop_back(); //strip trailing newlines + while (lines.back().empty()) lines.pop_back(); //strip trailing newlines if (lines.size()) lines[0] = " " + lines[0]; //indent the title line BOOST_FOREACH(const std::string &line, lines){ ss << boost::format("| %s") % line << std::endl; } - //ss << boost::format(" \\____________________________________________________") << std::endl; + //ss << boost::format(" \\_____________________________________________________") << std::endl; return ss.str(); } @@ -114,6 +115,14 @@ static std::string get_dboard_pp_string(const std::string &type, wax::obj dboard std::stringstream ss; ss << boost::format("%s Dboard: %s") % type % dboard[usrp::DBOARD_PROP_NAME].as<std::string>() << std::endl; //ss << std::endl; + usrp::dboard_eeprom_t db_eeprom = dboard[usrp::DBOARD_PROP_DBOARD_EEPROM].as<usrp::dboard_eeprom_t>(); + if (db_eeprom.id != usrp::dboard_id_t::none()) ss << boost::format("ID: %s") % db_eeprom.id.to_pp_string() << std::endl; + if (not db_eeprom.serial.empty()) ss << boost::format("Serial: %s") % db_eeprom.serial << std::endl; + if (type == "TX"){ + usrp::dboard_eeprom_t gdb_eeprom = dboard[usrp::DBOARD_PROP_GBOARD_EEPROM].as<usrp::dboard_eeprom_t>(); + if (gdb_eeprom.id != usrp::dboard_id_t::none()) ss << boost::format("GDB ID: %s") % gdb_eeprom.id.to_pp_string() << std::endl; + if (not gdb_eeprom.serial.empty()) ss << boost::format("GDB Serial: %s") % gdb_eeprom.serial << std::endl; + } BOOST_FOREACH(const std::string &subdev_name, dboard[usrp::DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>()){ ss << make_border(get_subdev_pp_string(type, dboard[named_prop_t(usrp::DBOARD_PROP_SUBDEV, subdev_name)])); } @@ -132,14 +141,14 @@ static std::string get_mboard_pp_string(wax::obj mboard){ 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)])); } + BOOST_FOREACH(const std::string &db_name, mboard[usrp::MBOARD_PROP_RX_DBOARD_NAMES].as<prop_names_t>()){ + ss << make_border(get_dboard_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DBOARD, db_name)])); + } BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_TX_DSP_NAMES].as<prop_names_t>()){ ss << make_border(get_dsp_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DSP, dsp_name)])); } - BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_RX_DBOARD_NAMES].as<prop_names_t>()){ - ss << make_border(get_dboard_pp_string("RX", mboard[named_prop_t(usrp::MBOARD_PROP_RX_DBOARD, dsp_name)])); - } - BOOST_FOREACH(const std::string &dsp_name, mboard[usrp::MBOARD_PROP_TX_DBOARD_NAMES].as<prop_names_t>()){ - ss << make_border(get_dboard_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DBOARD, dsp_name)])); + BOOST_FOREACH(const std::string &db_name, mboard[usrp::MBOARD_PROP_TX_DBOARD_NAMES].as<prop_names_t>()){ + ss << make_border(get_dboard_pp_string("TX", mboard[named_prop_t(usrp::MBOARD_PROP_TX_DBOARD, db_name)])); } return ss.str(); } diff --git a/host/utils/usrp1_init_eeprom.cpp b/host/utils/usrp1_init_eeprom.cpp index b05e400b1..39f091af4 100644 --- a/host/utils/usrp1_init_eeprom.cpp +++ b/host/utils/usrp1_init_eeprom.cpp @@ -21,6 +21,7 @@ #include <boost/program_options.hpp> #include <boost/format.hpp> #include <iostream> +#include <cstdlib> namespace po = boost::program_options; @@ -41,6 +42,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ return ~0; } + //cant find a uninitialized usrp with this mystery module in the way... + if (std::system("/sbin/rmmod usbtest") != 0){ + std::cerr << "Did not rmmod usbtest, this may be ok..." << std::endl; + } + //load the options into the address uhd::device_addr_t device_addr; device_addr["type"] = "usrp1"; diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py index 741c7e3e1..26adb91c7 100755 --- a/host/utils/usrp2_card_burner.py +++ b/host/utils/usrp2_card_burner.py @@ -56,6 +56,8 @@ def command(*args): def get_dd_path(): if platform.system() == 'Windows': + dd_path = os.path.join(os.path.dirname(__file__), 'dd.exe') + if os.path.exists(dd_path): return dd_path dd_path = os.path.join(tempfile.gettempdir(), 'dd.exe') if not os.path.exists(dd_path): print('Downloading dd.exe to %s'%dd_path) @@ -232,13 +234,9 @@ def get_options(): parser.add_option("--fw", type="string", help="firmware image path (optional)", default='') parser.add_option("--fpga", type="string", help="fpga image path (optional)", default='') parser.add_option("--list", action="store_true", help="list possible raw devices", default=False) + parser.add_option("--force", action="store_true", help="override safety check", default=False) (options, args) = parser.parse_args() - if options.list: - print('Possible raw devices:') - print(' ' + '\n '.join(get_raw_device_hints())) - exit() - return options ######################################################################## @@ -246,5 +244,19 @@ def get_options(): ######################################################################## if __name__=='__main__': options = get_options() + device_hints = get_raw_device_hints() + show_listing = options.list + + if not show_listing and not options.force and options.dev and options.dev not in device_hints: + print('The device "%s" was not in the list of possible raw devices.'%options.dev) + print('The card burner application will now exit without burning your card.') + print('To override this safety check, specify the --force option.\n') + show_listing = True + + if show_listing: + print('Possible raw devices:') + print(' ' + '\n '.join(device_hints)) + exit() + if not options.dev: raise Exception('no raw device path specified') print(burn_sd_card(dev=options.dev, fw=options.fw, fpga=options.fpga)) diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp index 617417e09..58417bd68 100644 --- a/host/utils/usrp_burn_db_eeprom.cpp +++ b/host/utils/usrp_burn_db_eeprom.cpp @@ -37,10 +37,13 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //command line variables std::string args, slot, unit; static const uhd::dict<std::string, mboard_prop_t> unit_to_db_prop = boost::assign::map_list_of - ("RX", MBOARD_PROP_RX_DBOARD) ("TX", MBOARD_PROP_TX_DBOARD) + ("RX", MBOARD_PROP_RX_DBOARD) ("TX", MBOARD_PROP_TX_DBOARD) ("GDB", MBOARD_PROP_TX_DBOARD) ; static const uhd::dict<std::string, mboard_prop_t> unit_to_db_names_prop = boost::assign::map_list_of - ("RX", MBOARD_PROP_RX_DBOARD_NAMES) ("TX", MBOARD_PROP_TX_DBOARD_NAMES) + ("RX", MBOARD_PROP_RX_DBOARD_NAMES) ("TX", MBOARD_PROP_TX_DBOARD_NAMES) ("GDB", MBOARD_PROP_TX_DBOARD_NAMES) + ; + static const uhd::dict<std::string, dboard_prop_t> unit_to_db_eeprom_prop = boost::assign::map_list_of + ("RX", DBOARD_PROP_DBOARD_EEPROM) ("TX", DBOARD_PROP_DBOARD_EEPROM) ("GDB", DBOARD_PROP_GBOARD_EEPROM) ; po::options_description desc("Allowed options"); @@ -48,7 +51,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("help", "help message") ("args", po::value<std::string>(&args)->default_value(""), "device address args [default = \"\"]") ("slot", po::value<std::string>(&slot)->default_value(""), "dboard slot name [default is blank for automatic]") - ("unit", po::value<std::string>(&unit)->default_value(""), "which unit [RX or TX]") + ("unit", po::value<std::string>(&unit)->default_value(""), "which unit [RX, TX, or GDB]") ("id", po::value<std::string>(), "dboard id to burn, omit for readback") ("ser", po::value<std::string>(), "serial to burn, omit for readback") ; @@ -82,19 +85,19 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string prefix = unit + ":" + slot; std::cout << boost::format("Reading EEPROM on %s dboard...") % prefix << std::endl; - dboard_eeprom_t db_eeprom = dboard[DBOARD_PROP_DBOARD_EEPROM].as<dboard_eeprom_t>(); + dboard_eeprom_t db_eeprom = dboard[unit_to_db_eeprom_prop[unit]].as<dboard_eeprom_t>(); //------------- handle the dboard ID -----------------------------// if (vm.count("id")){ db_eeprom.id = dboard_id_t::from_string(vm["id"].as<std::string>()); - dboard[DBOARD_PROP_DBOARD_EEPROM] = db_eeprom; + dboard[unit_to_db_eeprom_prop[unit]] = db_eeprom; } std::cout << boost::format(" Current ID: %s") % db_eeprom.id.to_pp_string() << std::endl; //------------- handle the dboard serial--------------------------// if (vm.count("ser")){ db_eeprom.serial = vm["ser"].as<std::string>(); - dboard[DBOARD_PROP_DBOARD_EEPROM] = db_eeprom; + dboard[unit_to_db_eeprom_prop[unit]] = db_eeprom; } std::cout << boost::format(" Current serial: \"%s\"") % db_eeprom.serial << std::endl; |