Revision 4c7a66cf

b/host/lib/usrp/usrp1/mboard_impl.cpp
30 30
#include <boost/assign/list_of.hpp>
31 31
#include <boost/foreach.hpp>
32 32
#include <boost/bind.hpp>
33
#include <boost/thread/thread.hpp>
33 34
#include <iostream>
34 35

  
35 36
using namespace uhd;
......
251 252
{
252 253
    named_prop_t key = named_prop_t::extract(key_);
253 254

  
255
    if(key_.type() == typeid(std::string)) {
256
      if(key.as<std::string>() == "serial") {
257
        uhd::byte_vector_t buf;
258
        buf.insert(buf.begin(), 248);
259
        boost::this_thread::sleep(boost::posix_time::milliseconds(100));
260
        _iface->write_i2c(I2C_DEV_EEPROM, buf);
261
        boost::this_thread::sleep(boost::posix_time::milliseconds(100));
262
        buf = _iface->read_i2c(I2C_DEV_EEPROM, 8);
263
        val = std::string(buf.begin(), buf.end());
264
      }
265

  
266
      return;
267
   	}
268

  
254 269
    //handle the get request conditioned on the key
255 270
    switch(key.as<mboard_prop_t>()){
256 271
    case MBOARD_PROP_NAME:
b/host/utils/CMakeLists.txt
39 39
ADD_EXECUTABLE(usrp_burn_db_eeprom usrp_burn_db_eeprom.cpp)
40 40
TARGET_LINK_LIBRARIES(usrp_burn_db_eeprom uhd)
41 41

  
42
ADD_EXECUTABLE(usrp_init_eeprom usrp_init_eeprom.cpp)
43
TARGET_LINK_LIBRARIES(usrp_init_eeprom uhd)
42
ADD_EXECUTABLE(usrp1_init_eeprom usrp1_init_eeprom.cpp)
43
TARGET_LINK_LIBRARIES(usrp1_init_eeprom uhd)
44 44

  
45
ADD_EXECUTABLE(usrp_serial_burner usrp_serial_burner.cpp)
46
TARGET_LINK_LIBRARIES(usrp_serial_burner uhd)
45
ADD_EXECUTABLE(usrp1_serial_burner usrp1_serial_burner.cpp)
46
TARGET_LINK_LIBRARIES(usrp1_serial_burner uhd)
47 47

  
48 48
INSTALL(TARGETS
49 49
    usrp2_addr_burner
50 50
    usrp_burn_db_eeprom
51
    usrp_init_eeprom
52
    usrp_serial_burner
51
    usrp1_init_eeprom
52
    usrp1_serial_burner
53 53
    RUNTIME DESTINATION ${PKG_DATA_DIR}/utils
54 54
)
55 55

  
b/host/utils/usrp1_init_eeprom.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
        ("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
}
b/host/utils/usrp1_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
        std::cout << "Reading back serial number: " << mb[std::string("serial")].as<std::string>() << std::endl;
70
    }
71

  
72

  
73
    std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl;
74
    return 0;
75
}
/dev/null
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
}
/dev/null
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