diff options
Diffstat (limited to 'host/utils')
-rw-r--r-- | host/utils/CMakeLists.txt | 17 | ||||
-rw-r--r-- | host/utils/b2xx_fx3_utils.cpp | 90 | ||||
-rw-r--r-- | host/utils/nirio_programmer.cpp | 6 | ||||
-rw-r--r-- | host/utils/octoclock_firmware_burner.cpp | 2 | ||||
-rw-r--r-- | host/utils/query_gpsdo_sensors.cpp | 2 | ||||
-rw-r--r-- | host/utils/uhd_images_downloader.py.in | 7 | ||||
-rw-r--r-- | host/utils/uhd_usrp_probe.cpp | 11 | ||||
-rw-r--r-- | host/utils/usrp_cal_utils.hpp | 2 | ||||
-rw-r--r-- | host/utils/usrp_n2xx_simple_net_burner.cpp | 4 | ||||
-rw-r--r-- | host/utils/usrp_x3xx_fpga_burner.cpp | 2 |
10 files changed, 91 insertions, 52 deletions
diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 3db28fa3c..ed8640187 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -65,14 +65,19 @@ SET(util_share_sources IF(ENABLE_USB) LIST(APPEND util_share_sources fx2_init_eeprom.cpp - b2xx_fx3_utils.cpp ) INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIRS}) - # Additional include directories for b2xx_fx3_utils - INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR}/../lib/usrp/b200 - ${CMAKE_CURRENT_SOURCE_DIR}/../lib/usrp/common - ${CMAKE_CURRENT_SOURCE_DIR}/../lib/usrp/common/ad9361_driver) + IF(ENABLE_B200) + LIST(APPEND util_share_sources + b2xx_fx3_utils.cpp + ) + # Additional include directories for b2xx_fx3_utils + INCLUDE_DIRECTORIES( + ${CMAKE_CURRENT_SOURCE_DIR}/../lib/usrp/b200 + ${CMAKE_CURRENT_SOURCE_DIR}/../lib/usrp/common + ${CMAKE_CURRENT_SOURCE_DIR}/../lib/usrp/common/ad9361_driver + ) + ENDIF(ENABLE_B200) ENDIF(ENABLE_USB) IF(ENABLE_OCTOCLOCK) LIST(APPEND util_share_sources diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index 8b64be63e..bc14932f1 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -51,20 +51,26 @@ struct vid_pid_t { const static vid_pid_t known_vid_pids[] = { {FX3_VID, FX3_DEFAULT_PID}, {FX3_VID, FX3_REENUM_PID}, - {B200_VENDOR_ID, B200_PRODUCT_ID} + {B200_VENDOR_ID, B200_PRODUCT_ID}, + {B200_VENDOR_NI_ID, B200_PRODUCT_NI_ID}, + {B200_VENDOR_NI_ID, B210_PRODUCT_NI_ID} }; const static std::vector<vid_pid_t> known_vid_pid_vector(known_vid_pids, known_vid_pids + (sizeof(known_vid_pids) / sizeof(known_vid_pids[0]))); -const static boost::uint8_t eeprom_init_values[] = { - 0x43, - 0x59, - 0x14, - 0xB2, - (B200_PRODUCT_ID & 0xff), - (B200_PRODUCT_ID >> 8), - (B200_VENDOR_ID & 0xff), - (B200_VENDOR_ID >> 8) - }; -const static uhd::byte_vector_t eeprom_init_value_vector(eeprom_init_values, eeprom_init_values + (sizeof(eeprom_init_values) / sizeof(eeprom_init_values[0]))); + +static const size_t EEPROM_INIT_VALUE_VECTOR_SIZE = 8; +static uhd::byte_vector_t construct_eeprom_init_value_vector(boost::uint16_t vid, boost::uint16_t pid) +{ + uhd::byte_vector_t init_values(EEPROM_INIT_VALUE_VECTOR_SIZE); + init_values.at(0) = 0x43; + init_values.at(1) = 0x59; + init_values.at(2) = 0x14; + init_values.at(3) = 0xB2; + init_values.at(4) = static_cast<boost::uint8_t>(pid & 0xff); + init_values.at(5) = static_cast<boost::uint8_t>(pid >> 8); + init_values.at(6) = static_cast<boost::uint8_t>(vid & 0xff); + init_values.at(7) = static_cast<boost::uint8_t>(vid >> 8); + return init_values; +} //!used with lexical cast to parse a hex string template <class T> struct to_hex{ @@ -153,15 +159,22 @@ uhd::transport::usb_device_handle::sptr open_device(const boost::uint16_t vid, c try { // try caller's VID/PID first - handles = uhd::transport::usb_device_handle::get_device_list(vp.vid,vp.pid); - if (user_supplied && handles.size() == 0) - std::cerr << (boost::format("Failed to open device with VID 0x%04x and PID 0x%04x - trying other known VID/PIDs") % vid % pid).str() << std::endl; - - // try known VID/PIDs next - for (size_t i = 0; handles.size() == 0 && i < known_vid_pid_vector.size(); i++) + std::vector<uhd::transport::usb_device_handle::vid_pid_pair_t> vid_pid_pair_list(1,uhd::transport::usb_device_handle::vid_pid_pair_t(vid,pid)); + handles = uhd::transport::usb_device_handle::get_device_list(vid_pid_pair_list); + if (handles.size() == 0) { - vp = known_vid_pid_vector[i]; - handles = uhd::transport::usb_device_handle::get_device_list(vp.vid,vp.pid); + if (user_supplied) + { + std::cerr << (boost::format("Failed to open device with VID 0x%04x and PID 0x%04x - trying other known VID/PIDs") % vid % pid).str() << std::endl; + } + + // try known VID/PIDs next + for (size_t i = 0; handles.size() == 0 && i < known_vid_pid_vector.size(); i++) + { + vp = known_vid_pid_vector[i]; + handles = uhd::transport::usb_device_handle::get_device_list(vp.vid, vp.pid); + } + } if (handles.size() > 0) @@ -173,7 +186,7 @@ uhd::transport::usb_device_handle::sptr open_device(const boost::uint16_t vid, c if (!handle) std::cerr << "Cannot open device" << std::endl; } - catch(const std::exception &e) { + catch(const std::exception &) { std::cerr << "Failed to communicate with the device!" << std::endl; #ifdef UHD_PLATFORM_WIN32 std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details:\nhttp://files.ettus.com/manual/page_transport.html" << std::endl; @@ -195,7 +208,7 @@ b200_iface::sptr make_b200_iface(const uhd::transport::usb_device_handle::sptr & if (!b200) std::cerr << "Cannot create device interface" << std::endl; } - catch(const std::exception &e) { + catch(const std::exception &) { std::cerr << "Failed to communicate with the device!" << std::endl; #ifdef UHD_PLATFORM_WIN32 std::cerr << "The necessary drivers are not installed. Read the UHD Transport Application Notes for details:\nhttp://files.ettus.com/manual/page_transport.html" << std::endl; @@ -221,7 +234,7 @@ int read_eeprom(b200_iface::sptr& b200, uhd::byte_vector_t& data) int write_eeprom(b200_iface::sptr& b200, const uhd::byte_vector_t& data) { try { - b200->write_eeprom(0x0, 0x0, data); + b200->write_eeprom(0x0, 0x0, data); } catch (std::exception &e) { std::cerr << "Exception while writing EEPROM: " << e.what() << std::endl; return -1; @@ -281,7 +294,7 @@ int erase_eeprom(b200_iface::sptr& b200) boost::int32_t main(boost::int32_t argc, char *argv[]) { boost::uint16_t vid, pid; - std::string pid_str, vid_str, fw_file, fpga_file; + std::string pid_str, vid_str, fw_file, fpga_file, writevid_str, writepid_str; bool user_supplied_vid_pid = false; po::options_description visible("Allowed options"); @@ -295,7 +308,6 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { ("reset-device,D", "Reset the B2xx Device.") ("reset-fpga,F", "Reset the FPGA (does not require re-programming.") ("reset-usb,U", "Reset the USB subsystem on your host computer.") - ("init-device,I", "Initialize a B2xx device.") ("load-fw,W", po::value<std::string>(&fw_file), "Load a firmware (hex) file into the FX3.") ("load-fpga,L", po::value<std::string>(&fpga_file), @@ -305,9 +317,14 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { // Hidden options provided for testing - use at your own risk! po::options_description hidden("Hidden options"); hidden.add_options() - ("uninit-device,U", "Uninitialize a B2xx device.") + ("init-device,I", "Initialize a B2xx device.") + ("uninit-device", "Uninitialize a B2xx device.") ("read-eeprom,R", "Read first 8 bytes of EEPROM") - ("erase-eeprom,E", "Erase first 8 bytes of EEPROM"); + ("erase-eeprom,E", "Erase first 8 bytes of EEPROM") + ("write-vid", po::value<std::string>(&writevid_str), + "Write VID field of EEPROM") + ("write-pid", po::value<std::string>(&writepid_str), + "Write PID field of EEPROM"); po::options_description desc; desc.add(visible); @@ -486,9 +503,24 @@ boost::int32_t main(boost::int32_t argc, char *argv[]) { * Cypress VID/PID for the initial FW load, but we can initialize from any state. */ if (vm.count("init-device")) { + uint16_t writevid = B200_VENDOR_ID; + uint16_t writepid = B200_PRODUCT_ID; + /* Now, initialize the device. */ - if (write_and_verify_eeprom(b200, eeprom_init_value_vector)) - return -1; + // Added for testing purposes - not exposed + if (vm.count("write-vid") && vm.count("write-pid")) + { + try { + writevid = atoh(writevid_str); + writepid = atoh(writepid_str); + } catch (std::exception &e) { + std::cerr << "Exception while parsing write VID and PID: " << e.what() << std:: endl; + return ~0; + } + } + + std::cout << "Writing VID and PID to EEPROM..." << std::endl << std::endl; + if (write_and_verify_eeprom(b200, construct_eeprom_init_value_vector(writevid, writepid))) return -1; std::cout << "EEPROM initialized, resetting device..." << std::endl << std::endl; diff --git a/host/utils/nirio_programmer.cpp b/host/utils/nirio_programmer.cpp index 43ec1ff43..c8c5e72d3 100644 --- a/host/utils/nirio_programmer.cpp +++ b/host/utils/nirio_programmer.cpp @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) ss >> peek_addr; niriok_scoped_addr_space(dev_proxy, peek_tokens[0]=="c"?BUS_INTERFACE:FPGA, status); - uint32_t reg_val; + uint32_t reg_val = 0; if (peek_tokens[0]=="z") { nirio_status_chain(dev_proxy->poke((uint32_t)0x60000 + peek_addr, (uint32_t)0), status); do { @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) //Display attributes if (vm.count("stats")){ printf("[Interface %u]\n", interface_num); - uint32_t attr_val; + uint32_t attr_val = 0; nirio_status_chain(dev_proxy->get_attribute(RIO_IS_FPGA_PROGRAMMED, attr_val), status); printf("* Is FPGA Programmed? = %s\n", (attr_val==1)?"YES":"NO"); @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) } printf("* FPGA Bitstream Checksum = %s\n", checksum.c_str()); - uint32_t reg_val; + uint32_t reg_val = 0; nirio_status_chain(dev_proxy->set_attribute(RIO_ADDRESS_SPACE, BUS_INTERFACE), status); nirio_status_chain(dev_proxy->peek(0, reg_val), status); printf("* Chinch Signature = %x\n", reg_val); diff --git a/host/utils/octoclock_firmware_burner.cpp b/host/utils/octoclock_firmware_burner.cpp index 0a48caabd..d624095e6 100644 --- a/host/utils/octoclock_firmware_burner.cpp +++ b/host/utils/octoclock_firmware_burner.cpp @@ -123,7 +123,7 @@ device_addrs_t bootloader_find(const std::string &ip_addr){ void read_firmware(){ std::ifstream firmware_file(firmware_path.c_str(), std::ios::binary); firmware_file.seekg(0, std::ios::end); - firmware_size = firmware_file.tellg(); + firmware_size = size_t(firmware_file.tellg()); if(firmware_size > MAX_FIRMWARE_SIZE){ firmware_file.close(); throw uhd::runtime_error(str(boost::format("Firmware file too large: %d > %d") diff --git a/host/utils/query_gpsdo_sensors.cpp b/host/utils/query_gpsdo_sensors.cpp index 05f918eb4..9a40d2b42 100644 --- a/host/utils/query_gpsdo_sensors.cpp +++ b/host/utils/query_gpsdo_sensors.cpp @@ -118,7 +118,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::sensor_value_t rmc_string = usrp->get_mboard_sensor("gps_gprmc"); std::cout << boost::format("Printing available NMEA strings:\n"); std::cout << boost::format("%s\n%s\n%s\n") % gga_string.to_pp_string() % rmc_string.to_pp_string() % gps_time.to_pp_string(); - } catch (std::exception &e) { + } catch (std::exception &) { std::cout << "NMEA strings not implemented for this device." << std::endl; } std::cout << boost::format("UHD Device time: %.0f seconds\n") % (last_pps_time.get_real_secs()); diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in index 5b16c7bb5..3903edc8c 100644 --- a/host/utils/uhd_images_downloader.py.in +++ b/host/utils/uhd_images_downloader.py.in @@ -308,11 +308,12 @@ def main(): if options.verbose: print "Downloaded %d of %d bytes" % (downloaded_size, reported_size) else: - temp_images_dest = os.path.join(options.base_url, options.filename) - print "Copying images from: {0}".format(temp_images_dest) - if not os.path.isfile(temp_images_dest): + local_images_pkg = os.path.join(options.base_url, options.filename) + print "Copying images from: {0}".format(local_images_pkg) + if not os.path.isfile(local_images_pkg): print "[ERROR] No such file." return 1 + shutil.copyfile(local_images_pkg, temp_images_dest) (checksum_match, calculated_checksum) = downloader.validate_checksum( checksum_fn, temp_images_dest, diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp index 656cdf45a..a03646cc0 100644 --- a/host/utils/uhd_usrp_probe.cpp +++ b/host/utils/uhd_usrp_probe.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2011 Ettus Research LLC +// Copyright 2010-2011,2015 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 @@ -35,10 +35,6 @@ namespace po = boost::program_options; using namespace uhd; -static std::string indent(size_t level){ - return (level)? (indent(level-1) + " ") : ""; -} - static std::string make_border(const std::string &text){ std::stringstream ss; ss << boost::format(" _____________________________________________________") << std::endl; @@ -88,6 +84,11 @@ static std::string get_frontend_pp_string(const std::string &type, property_tree meta_range_t gain_range = tree->access<meta_range_t>(path / "gains" / name / "range").get(); ss << boost::format("Gain range %s: %.1f to %.1f step %.1f dB") % name % gain_range.start() % gain_range.stop() % gain_range.step() << std::endl; } + if (tree->exists(path / "bandwidth" / "range")) + { + meta_range_t bw_range = tree->access<meta_range_t>(path / "bandwidth" / "range").get(); + ss << boost::format("Bandwidth range: %.1f to %.1f step %.1f Hz") % bw_range.start() % bw_range.stop() % bw_range.step() << std::endl; + } ss << boost::format("Connection Type: %s") % (tree->access<std::string>(path / "connection").get()) << std::endl; ss << boost::format("Uses LO offset: %s") % ((tree->access<bool>(path / "use_lo_offset").get())? "Yes" : "No") << std::endl; diff --git a/host/utils/usrp_cal_utils.hpp b/host/utils/usrp_cal_utils.hpp index c027a4785..ccdb0a61d 100644 --- a/host/utils/usrp_cal_utils.hpp +++ b/host/utils/usrp_cal_utils.hpp @@ -249,7 +249,7 @@ static void capture_samples( // Right after the stream is started, there will be transient data. // That transient data is discarded and only "good" samples are returned. - size_t nsamps_to_discard = usrp->get_rx_rate() * 0.001; // 1ms to be discarded + size_t nsamps_to_discard = size_t(usrp->get_rx_rate() * 0.001); // 1ms to be discarded std::vector<samp_type> discard_buff(nsamps_to_discard); uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); diff --git a/host/utils/usrp_n2xx_simple_net_burner.cpp b/host/utils/usrp_n2xx_simple_net_burner.cpp index b06e67bb2..642e9a407 100644 --- a/host/utils/usrp_n2xx_simple_net_burner.cpp +++ b/host/utils/usrp_n2xx_simple_net_burner.cpp @@ -262,7 +262,7 @@ int read_fpga_image(std::string& fpga_path){ //Check size of given image std::ifstream fpga_file(fpga_path.c_str(), std::ios::binary); fpga_file.seekg(0, std::ios::end); - int fpga_image_size = fpga_file.tellg(); + size_t fpga_image_size = size_t(fpga_file.tellg()); if(fpga_image_size > FPGA_IMAGE_SIZE_BYTES){ throw std::runtime_error(str(boost::format("FPGA image is too large. %d > %d") % fpga_image_size % FPGA_IMAGE_SIZE_BYTES)); @@ -297,7 +297,7 @@ int read_fw_image(std::string& fw_path){ //Check size of given image std::ifstream fw_file(fw_path.c_str(), std::ios::binary); fw_file.seekg(0, std::ios::end); - int fw_image_size = fw_file.tellg(); + size_t fw_image_size = size_t(fw_file.tellg()); if(fw_image_size > FW_IMAGE_SIZE_BYTES){ throw std::runtime_error(str(boost::format("Firmware image is too large. %d > %d") % fw_image_size % FW_IMAGE_SIZE_BYTES)); diff --git a/host/utils/usrp_x3xx_fpga_burner.cpp b/host/utils/usrp_x3xx_fpga_burner.cpp index abd5815e8..e32e4d636 100644 --- a/host/utils/usrp_x3xx_fpga_burner.cpp +++ b/host/utils/usrp_x3xx_fpga_burner.cpp @@ -487,7 +487,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if(vm.count("addr")){ udp_simple::sptr udp_transport = udp_simple::make_connected(ip_addr, BOOST_STRINGIZE(X300_FPGA_PROG_UDP_PORT)); - ethernet_burn(udp_transport, fpga_path, vm.count("verify")); + ethernet_burn(udp_transport, fpga_path, (vm.count("verify") > 0)); if(vm.count("configure")){ if(configure_fpga(udp_transport, ip_addr)) std::cout << "Successfully configured FPGA!" << std::endl; |