From 2a575bf9b5a4942f60e979161764b9e942699e1e Mon Sep 17 00:00:00 2001 From: Lars Amsel Date: Fri, 4 Jun 2021 08:27:50 +0200 Subject: uhd: Add support for the USRP X410 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lars Amsel Co-authored-by: Michael Auchter Co-authored-by: Martin Braun Co-authored-by: Paul Butler Co-authored-by: Cristina Fuentes Co-authored-by: Humberto Jimenez Co-authored-by: Virendra Kakade Co-authored-by: Lane Kolbly Co-authored-by: Max Köhler Co-authored-by: Andrew Lynch Co-authored-by: Grant Meyerhoff Co-authored-by: Ciro Nishiguchi Co-authored-by: Thomas Vogel --- host/utils/CMakeLists.txt | 1 + host/utils/rfnoc_image_builder.py | 4 +-- host/utils/uhd_adc_self_cal.cpp | 76 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 host/utils/uhd_adc_self_cal.cpp (limited to 'host/utils') diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index ab7d645f4..1ac0b1c99 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -16,6 +16,7 @@ set(util_runtime_sources uhd_cal_rx_iq_balance.cpp uhd_cal_tx_dc_offset.cpp uhd_cal_tx_iq_balance.cpp + uhd_adc_self_cal.cpp ) #for each source: build an executable and install diff --git a/host/utils/rfnoc_image_builder.py b/host/utils/rfnoc_image_builder.py index 285dfe3e9..07419cb90 100755 --- a/host/utils/rfnoc_image_builder.py +++ b/host/utils/rfnoc_image_builder.py @@ -46,7 +46,7 @@ def setup_parser(): help="Path to grc file to generate config from") parser.add_argument( "-F", "--fpga-dir", - help="Path to directory for the FPGA source tree." + help="Path to directory for the FPGA source tree. " "Defaults to the FPGA source tree of the current repo.", required=False, default=None) @@ -79,7 +79,7 @@ def setup_parser(): action="store_true") parser.add_argument( "-d", "--device", - help="Device to be programmed [x300, x310, e310, e320, n300, n310, n320]." + help="Device to be programmed [x300, x310, e310, e320, n300, n310, n320, x410]. " "Needs to be specified either here, or in the configuration file.", default=None) parser.add_argument( diff --git a/host/utils/uhd_adc_self_cal.cpp b/host/utils/uhd_adc_self_cal.cpp new file mode 100644 index 000000000..39dab3e15 --- /dev/null +++ b/host/utils/uhd_adc_self_cal.cpp @@ -0,0 +1,76 @@ +// +// Copyright 2020 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace po = boost::program_options; +using namespace uhd; + +/**************************************************************************** + * main + ***************************************************************************/ +int UHD_SAFE_MAIN(int argc, char* argv[]) +{ + po::options_description desc("Allowed options"); + // clang-format off + desc.add_options() + ("help", "help message") + ("version", "print the version string and exit") + ("args", po::value()->default_value(""), "device address args") + ; + // clang-format on + + 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 << "UHD ADC self calibration " << desc << std::endl; + return EXIT_FAILURE; + } + + if (vm.count("version")) { + std::cout << uhd::get_version_string() << std::endl; + return EXIT_SUCCESS; + } + + rfnoc::rfnoc_graph::sptr graph = + rfnoc::rfnoc_graph::make(vm["args"].as()); + + size_t num_calibrations = 0; + for (auto radio_id : graph->find_blocks("Radio")) { + auto radio_blk = graph->get_block(radio_id); + if (radio_blk->has_feature()) { + auto& feature = + radio_blk->get_feature(); + + // Run it on all channels + const size_t num_channels = radio_blk->get_num_output_ports(); + for (size_t i = 0; i < num_channels; i++) { + std::cout << "Calibrating on channel " << i << " of " << radio_id << "..." + << std::endl; + feature.run(i); + std::cout << "Finished!" << std::endl; + num_calibrations++; + } + } + } + if (num_calibrations > 0) { + std::cout << "Calibrated " << num_calibrations << " channels" << std::endl; + } else { + std::cerr << "WARNING: Did not find any channels to calibrate!" << std::endl; + } + + return EXIT_SUCCESS; +} -- cgit v1.2.3