Revision 7b066a45
| b/host/lib/usrp/usrp1/mboard_impl.cpp | ||
|---|---|---|
| 19 | 19 |
#include "usrp_commands.h" |
| 20 | 20 |
#include "fpga_regs_standard.h" |
| 21 | 21 |
#include "fpga_regs_common.h" |
| 22 |
#include "usrp_i2c_addr.h" |
|
| 22 | 23 |
#include <uhd/usrp/misc_utils.hpp> |
| 23 | 24 |
#include <uhd/usrp/mboard_props.hpp> |
| 24 | 25 |
#include <uhd/usrp/dboard_props.hpp> |
| ... | ... | |
| 321 | 322 |
{
|
| 322 | 323 |
if(key.type() == typeid(std::string)) {
|
| 323 | 324 |
if(key.as<std::string>() == "load_eeprom") {
|
| 324 |
std::string usrp1_fpga_image = val.as<std::string>();
|
|
| 325 |
std::cout << "USRP1 EEPROM image: " << usrp1_fpga_image << std::endl;
|
|
| 325 |
std::string usrp1_eeprom_image = val.as<std::string>();
|
|
| 326 |
std::cout << "USRP1 EEPROM image: " << usrp1_eeprom_image << std::endl;
|
|
| 326 | 327 |
_ctrl_transport->usrp_load_eeprom(val.as<std::string>()); |
| 327 | 328 |
} |
| 328 | 329 |
|
| 330 |
if(key.as<std::string>() == "serial") {
|
|
| 331 |
std::string sernum = val.as<std::string>(); |
|
| 332 |
uhd::byte_vector_t buf(sernum.begin(), sernum.end()); |
|
| 333 |
buf.insert(buf.begin(), 248); |
|
| 334 |
_iface->write_i2c(I2C_DEV_EEPROM, buf); |
|
| 335 |
} |
|
| 336 |
|
|
| 329 | 337 |
return; |
| 330 | 338 |
} |
| 331 | 339 |
|
| b/host/utils/CMakeLists.txt | ||
|---|---|---|
| 42 | 42 |
ADD_EXECUTABLE(usrp_init_eeprom usrp_init_eeprom.cpp) |
| 43 | 43 |
TARGET_LINK_LIBRARIES(usrp_init_eeprom uhd) |
| 44 | 44 |
|
| 45 |
ADD_EXECUTABLE(usrp_serial_burner usrp_serial_burner.cpp) |
|
| 46 |
TARGET_LINK_LIBRARIES(usrp_serial_burner uhd) |
|
| 47 |
|
|
| 45 | 48 |
INSTALL(TARGETS |
| 46 | 49 |
usrp2_addr_burner |
| 47 | 50 |
usrp_burn_db_eeprom |
| 48 | 51 |
usrp_init_eeprom |
| 52 |
usrp_serial_burner |
|
| 49 | 53 |
RUNTIME DESTINATION ${PKG_DATA_DIR}/utils
|
| 50 | 54 |
) |
| 51 | 55 |
|
| b/host/utils/usrp_init_eeprom.cpp | ||
|---|---|---|
| 28 | 28 |
po::options_description desc("Allowed options");
|
| 29 | 29 |
desc.add_options() |
| 30 | 30 |
("help", "help message")
|
| 31 |
("image", po::value<std::string>(), "IHX image file")
|
|
| 31 |
("image", po::value<std::string>(), "BIN image file")
|
|
| 32 | 32 |
; |
| 33 | 33 |
|
| 34 | 34 |
po::variables_map vm; |
| b/host/utils/usrp_serial_burner.cpp | ||
|---|---|---|
| 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 |
("old", po::value<std::string>(), "old USRP serial number (optional)")
|
|
| 32 |
("new", po::value<std::string>(), "new USRP serial number")
|
|
| 33 |
; |
|
| 34 |
|
|
| 35 |
po::variables_map vm; |
|
| 36 |
po::store(po::parse_command_line(argc, argv, desc), vm); |
|
| 37 |
po::notify(vm); |
|
| 38 |
|
|
| 39 |
//print the help message |
|
| 40 |
if (vm.count("help")){
|
|
| 41 |
std::cout << boost::format("USRP serial burner %s") % desc << std::endl;
|
|
| 42 |
return ~0; |
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
if(vm.count("new") == 0) {
|
|
| 46 |
std::cout << "error: must input --new arg" << std::endl; |
|
| 47 |
return ~0; |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
//load the options into the address |
|
| 51 |
uhd::device_addr_t device_addr; |
|
| 52 |
device_addr["type"] = "usrp1"; |
|
| 53 |
if(vm.count("old")) device_addr["serial"] = vm["old"].as<std::string>();
|
|
| 54 |
|
|
| 55 |
//find and create a control transport to do the writing. |
|
| 56 |
|
|
| 57 |
uhd::device_addrs_t found_addrs = uhd::device::find(device_addr); |
|
| 58 |
|
|
| 59 |
if (found_addrs.size() == 0){
|
|
| 60 |
std::cerr << "No USRP devices found" << std::endl; |
|
| 61 |
return ~0; |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
for (size_t i = 0; i < found_addrs.size(); i++){
|
|
| 65 |
uhd::device::sptr dev = uhd::device::make(found_addrs[i]); |
|
| 66 |
wax::obj mb = (*dev)[uhd::usrp::DEVICE_PROP_MBOARD]; |
|
| 67 |
std::cout << "Writing serial number..." << std::endl; |
|
| 68 |
mb[std::string("serial")] = vm["new"].as<std::string>();
|
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
|
|
| 72 |
std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; |
|
| 73 |
return 0; |
|
| 74 |
} |
|
Also available in: Unified diff