From 307cd0915038429cdf2ac713ae5546bf7acd50c9 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Mon, 10 Oct 2011 12:27:20 -0700 Subject: Renaming 'usrp1_init_eeprom' to 'fx2_init_eeprom', and making it enable based on ENABLE_USB rather than ENABLE_USRP1 since we also need it for B100. --- host/utils/CMakeLists.txt | 6 +-- host/utils/fx2_init_eeprom.cpp | 93 ++++++++++++++++++++++++++++++++++++++++ host/utils/usrp1_init_eeprom.cpp | 93 ---------------------------------------- 3 files changed, 96 insertions(+), 96 deletions(-) create mode 100644 host/utils/fx2_init_eeprom.cpp delete mode 100644 host/utils/usrp1_init_eeprom.cpp (limited to 'host/utils') diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 1b70be7a4..1a0396ad3 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -39,11 +39,11 @@ SET(util_share_sources usrp_burn_mb_eeprom.cpp ) -IF(ENABLE_USRP1) +IF(ENABLE_USB) LIST(APPEND util_share_sources - usrp1_init_eeprom.cpp + fx2_init_eeprom.cpp ) -ENDIF(ENABLE_USRP1) +ENDIF(ENABLE_USB) IF(LINUX AND ENABLE_USB) INSTALL(FILES diff --git a/host/utils/fx2_init_eeprom.cpp b/host/utils/fx2_init_eeprom.cpp new file mode 100644 index 000000000..c210ae575 --- /dev/null +++ b/host/utils/fx2_init_eeprom.cpp @@ -0,0 +1,93 @@ +// +// 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 +#include + +const std::string FX2_VENDOR_ID("0x04b4"); +const std::string FX2_PRODUCT_ID("0x8613"); + +namespace po = boost::program_options; + +int UHD_SAFE_MAIN(int argc, char *argv[]){ + std::string type; + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "help message") + ("image", po::value(), "BIN image file") + ("vid", po::value(), "VID of device to program") + ("pid", po::value(), "PID of device to program") + ("type", po::value(), "device type (usrp1 or b100)") + ; + + 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; + } + + //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"] = type; + if(vm.count("vid") or vm.count("pid") or vm.count("type")) { + if(not (vm.count("vid") and vm.count("pid") and vm.count("type"))) { + std::cerr << "ERROR: Must specify vid, pid, and type if specifying any of the three args" << std::endl; + } else { + device_addr["vid"] = vm["vid"].as(); + device_addr["pid"] = vm["pid"].as(); + device_addr["type"] = vm["type"].as(); + } + } else { + device_addr["vid"] = FX2_VENDOR_ID; + device_addr["pid"] = FX2_PRODUCT_ID; + } + + //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++){ + 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]); + uhd::property_tree::sptr tree = dev->get_tree(); + tree->access("/mboards/0/load_eeprom").set(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_init_eeprom.cpp b/host/utils/usrp1_init_eeprom.cpp deleted file mode 100644 index c210ae575..000000000 --- a/host/utils/usrp1_init_eeprom.cpp +++ /dev/null @@ -1,93 +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 -#include - -const std::string FX2_VENDOR_ID("0x04b4"); -const std::string FX2_PRODUCT_ID("0x8613"); - -namespace po = boost::program_options; - -int UHD_SAFE_MAIN(int argc, char *argv[]){ - std::string type; - po::options_description desc("Allowed options"); - desc.add_options() - ("help", "help message") - ("image", po::value(), "BIN image file") - ("vid", po::value(), "VID of device to program") - ("pid", po::value(), "PID of device to program") - ("type", po::value(), "device type (usrp1 or b100)") - ; - - 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; - } - - //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"] = type; - if(vm.count("vid") or vm.count("pid") or vm.count("type")) { - if(not (vm.count("vid") and vm.count("pid") and vm.count("type"))) { - std::cerr << "ERROR: Must specify vid, pid, and type if specifying any of the three args" << std::endl; - } else { - device_addr["vid"] = vm["vid"].as(); - device_addr["pid"] = vm["pid"].as(); - device_addr["type"] = vm["type"].as(); - } - } else { - device_addr["vid"] = FX2_VENDOR_ID; - device_addr["pid"] = FX2_PRODUCT_ID; - } - - //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++){ - 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]); - uhd::property_tree::sptr tree = dev->get_tree(); - tree->access("/mboards/0/load_eeprom").set(vm["image"].as()); - } - - - std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; - return 0; -} -- cgit v1.2.3