root / host / utils / usrp_init_eeprom.cpp @ 7b066a45
History | View | Annotate | Download (2.3 kB)
| 1 |
//
|
|---|---|
| 2 |
// Copyright 2010 Ettus Research LLC
|
| 3 |
//
|
| 4 |
// This program is free software: you can redistribute it and/or modify
|
| 5 |
// it under the terms of the GNU General Public License as published by
|
| 6 |
// the Free Software Foundation, either version 3 of the License, or
|
| 7 |
// (at your option) any later version.
|
| 8 |
//
|
| 9 |
// This program is distributed in the hope that it will be useful,
|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
| 13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
//
|
| 17 |
|
| 18 |
#include <uhd/utils/safe_main.hpp> |
| 19 |
#include <uhd/device.hpp> |
| 20 |
#include <uhd/usrp/device_props.hpp> |
| 21 |
#include <boost/program_options.hpp> |
| 22 |
#include <boost/format.hpp> |
| 23 |
#include <iostream> |
| 24 |
|
| 25 |
namespace po = boost::program_options;
|
| 26 |
|
| 27 |
int UHD_SAFE_MAIN(int argc, char *argv[]){ |
| 28 |
po::options_description desc("Allowed options");
|
| 29 |
desc.add_options() |
| 30 |
("help", "help message") |
| 31 |
("image", po::value<std::string>(), "BIN image file") |
| 32 |
; |
| 33 |
|
| 34 |
po::variables_map vm; |
| 35 |
po::store(po::parse_command_line(argc, argv, desc), vm); |
| 36 |
po::notify(vm); |
| 37 |
|
| 38 |
//print the help message
|
| 39 |
if (vm.count("help")){ |
| 40 |
std::cout << boost::format("USRP EEPROM initialization %s") % desc << std::endl;
|
| 41 |
return ~0; |
| 42 |
} |
| 43 |
|
| 44 |
//load the options into the address
|
| 45 |
uhd::device_addr_t device_addr; |
| 46 |
device_addr["type"] = "usrp1"; |
| 47 |
device_addr["uninit"] = "yeah"; //tell find to look for an uninitialized FX2 |
| 48 |
|
| 49 |
//find and create a control transport to do the writing.
|
| 50 |
|
| 51 |
uhd::device_addrs_t found_addrs = uhd::device::find(device_addr); |
| 52 |
|
| 53 |
if (found_addrs.size() == 0){ |
| 54 |
std::cerr << "No uninitialized USRP devices found" << std::endl;
|
| 55 |
return ~0; |
| 56 |
} |
| 57 |
|
| 58 |
for (size_t i = 0; i < found_addrs.size(); i++){ |
| 59 |
std::cout << "Writing EEPROM data..." << std::endl;
|
| 60 |
//uhd::device_addrs_t devs = uhd::device::find(found_addrs[i]);
|
| 61 |
uhd::device::sptr dev = uhd::device::make(found_addrs[i]); |
| 62 |
wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; |
| 63 |
mb[std::string("load_eeprom")] = vm["image"].as<std::string>(); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl;
|
| 68 |
return 0; |
| 69 |
} |