From b3df6a0ebfa288d032d917b48b69f036444e57b6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 23 Jan 2011 18:48:16 +0000 Subject: usrp-e100: created component for stand-alone usrp-e utils and added wb test util --- host/usrp_e_utils/CMakeLists.txt | 50 ++++++ host/usrp_e_utils/clkgen-config.cpp | 296 ++++++++++++++++++++++++++++++++++ host/usrp_e_utils/fpga-downloader.cpp | 267 ++++++++++++++++++++++++++++++ host/usrp_e_utils/usrp-e-debug-pins.c | 78 +++++++++ host/usrp_e_utils/usrp-e-i2c.c | 87 ++++++++++ host/usrp_e_utils/usrp-e-loopback.c | 231 ++++++++++++++++++++++++++ host/usrp_e_utils/usrp-e-spi.c | 54 +++++++ host/usrp_e_utils/usrp-e-wb-test.cpp | 111 +++++++++++++ 8 files changed, 1174 insertions(+) create mode 100644 host/usrp_e_utils/CMakeLists.txt create mode 100644 host/usrp_e_utils/clkgen-config.cpp create mode 100644 host/usrp_e_utils/fpga-downloader.cpp create mode 100644 host/usrp_e_utils/usrp-e-debug-pins.c create mode 100644 host/usrp_e_utils/usrp-e-i2c.c create mode 100644 host/usrp_e_utils/usrp-e-loopback.c create mode 100644 host/usrp_e_utils/usrp-e-spi.c create mode 100644 host/usrp_e_utils/usrp-e-wb-test.cpp (limited to 'host/usrp_e_utils') diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt new file mode 100644 index 000000000..1330aed75 --- /dev/null +++ b/host/usrp_e_utils/CMakeLists.txt @@ -0,0 +1,50 @@ +# +# Copyright 2011 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +######################################################################## +# USRP embedded utilities that get installed into the share path +######################################################################## +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(LINUX_TARGET TRUE) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + +LIBUHD_REGISTER_COMPONENT("USRP-E Utils" ENABLE_USRP_E_UTILS OFF "LINUX_TARGET" OFF) + +IF(ENABLE_USRP_E_UTILS) + ENABLE_LANGUAGE(C) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include) + + SET(usrp_e_utils_sources + fpga-downloader.cpp + clkgen-config.cpp + usrp-e-loopback.c + usrp-e-wb-test.cpp + usrp-e-debug-pins.c + usrp-e-i2c.c + usrp-e-spi.c + ) + + #for each source: build an executable and install + FOREACH(util_source ${usrp_e_utils_sources}) + GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE) + ADD_EXECUTABLE(${util_name} ${util_source}) + TARGET_LINK_LIBRARIES(${util_name} -lpthread) + INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/usrp_e_utils) + ENDFOREACH(util_source) + +ENDIF(ENABLE_USRP_E_UTILS) diff --git a/host/usrp_e_utils/clkgen-config.cpp b/host/usrp_e_utils/clkgen-config.cpp new file mode 100644 index 000000000..e8279b4ae --- /dev/null +++ b/host/usrp_e_utils/clkgen-config.cpp @@ -0,0 +1,296 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc. + * + * This file is part of UHD + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + + +// Programming data for clock gen chip +static const unsigned int config_data[] = { + 0x000024, + 0x023201, + 0x000081, + 0x000400, + 0x00104c, + 0x001101, + 0x001200, + 0x001300, + 0x001414, + 0x001500, + 0x001604, + 0x001704, + 0x001807, + 0x001900, + //0x001a00,//for debug + 0x001a32, + 0x001b12, + 0x001c44, + 0x001d00, + 0x001e00, + 0x00f062, + 0x00f162, + 0x00f262, + 0x00f362, + 0x00f462, + 0x00f562, + 0x00f662, + 0x00f762, + 0x00f862, + 0x00f962, + 0x00fa62, + 0x00fb62, + 0x00fc00, + 0x00fd00, + 0x019021, + 0x019100, + 0x019200, + 0x019333, + 0x019400, + 0x019500, + 0x019611, + 0x019700, + 0x019800, + 0x019900, + 0x019a00, + 0x019b00, + 0x01e003, + 0x01e102, + 0x023000, + 0x023201, + 0x0b0201, + 0x0b0300, + 0x001fff, + 0x0a0000, + 0x0a0100, + 0x0a0200, + 0x0a0302, + 0x0a0400, + 0x0a0504, + 0x0a060e, + 0x0a0700, + 0x0a0810, + 0x0a090e, + 0x0a0a00, + 0x0a0bf0, + 0x0a0c0b, + 0x0a0d01, + 0x0a0e90, + 0x0a0f01, + 0x0a1001, + 0x0a11e0, + 0x0a1201, + 0x0a1302, + 0x0a1430, + 0x0a1580, + 0x0a16ff, + 0x023201, + 0x0b0301, + 0x023201, +}; + + +const unsigned int CLKGEN_SELECT = 145; + + +enum gpio_direction {IN, OUT}; + +class gpio { + public: + + gpio(unsigned int gpio_num, gpio_direction pin_direction, bool close_action); + ~gpio(); + + bool get_value(); + void set_value(bool state); + + private: + + unsigned int gpio_num; + + std::stringstream base_path; + std::fstream value_file; + std::fstream direction_file; + bool close_action; // True set to input and release, false do nothing +}; + +class spidev { + public: + + spidev(std::string dev_name); + ~spidev(); + + void send(char *wbuf, char *rbuf, unsigned int nbytes); + + private: + + int fd; + +}; + +gpio::gpio(unsigned int _gpio_num, gpio_direction pin_direction, bool close_action) +{ + std::fstream export_file; + + gpio_num = _gpio_num; + + export_file.open("/sys/class/gpio/export", std::ios::out); + if (!export_file.is_open()) ///\todo Poor error handling + std::cout << "Failed to open gpio export file." << std::endl; + + export_file << gpio_num << std::endl; + + base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; + + std::string direction_file_name; + + direction_file_name = base_path.str() + "/direction"; + + direction_file.open(direction_file_name.c_str()); + if (!direction_file.is_open()) + std::cout << "Failed to open direction file." << std::endl; + if (pin_direction == OUT) + direction_file << "out" << std::endl; + else + direction_file << "in" << std::endl; + + std::string value_file_name; + + value_file_name = base_path.str() + "/value"; + + value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); + if (!value_file.is_open()) + std::cout << "Failed to open value file." << std::endl; +} + +bool gpio::get_value() +{ + + std::string val; + + std::getline(value_file, val); + value_file.seekg(0); + + if (val == "0") + return false; + else if (val == "1") + return true; + else + std::cout << "Data read from value file|" << val << "|" << std::endl; + + return false; +} + +void gpio::set_value(bool state) +{ + + if (state) + value_file << "1" << std::endl; + else + value_file << "0" << std::endl; +} + +gpio::~gpio() +{ + if (close_action) { + std::fstream unexport_file; + + direction_file << "in" << std::endl; + + unexport_file.open("/sys/class/gpio/unexport", std::ios::out); + if (!unexport_file.is_open()) ///\todo Poor error handling + std::cout << "Failed to open gpio export file." << std::endl; + + unexport_file << gpio_num << std::endl; + + } + +} + +spidev::spidev(std::string fname) +{ + int ret; + int mode = 0; + int speed = 12000; + int bits = 24; + + fd = open(fname.c_str(), O_RDWR); + + ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); + ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); +} + + +spidev::~spidev() +{ + close(fd); +} + +void spidev::send(char *buf, char *rbuf, unsigned int nbytes) +{ + int ret; + + struct spi_ioc_transfer tr; + tr.tx_buf = (unsigned long) buf; + tr.rx_buf = (unsigned long) rbuf; + tr.len = nbytes; + tr.delay_usecs = 0; + tr.speed_hz = 12000000; + tr.bits_per_word = 24; + + ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); + +} + +static void send_config_to_clkgen(gpio &chip_select, const unsigned int data[], unsigned int data_size) +{ + spidev spi("/dev/spidev1.0"); + unsigned int rbuf; + + for (unsigned int i = 0; i < data_size; i++) { + + std::cout << "sending " << std::hex << data[i] << std::endl; + chip_select.set_value(0); + spi.send((char *)&data[i], (char *)&rbuf, 4); + chip_select.set_value(1); + + }; +} + +int main(int argc, char *argv[]) +{ + + gpio clkgen_select(CLKGEN_SELECT, OUT, true); + + send_config_to_clkgen(clkgen_select, config_data, sizeof(config_data)/sizeof(unsigned int)); +} + diff --git a/host/usrp_e_utils/fpga-downloader.cpp b/host/usrp_e_utils/fpga-downloader.cpp new file mode 100644 index 000000000..80ee71600 --- /dev/null +++ b/host/usrp_e_utils/fpga-downloader.cpp @@ -0,0 +1,267 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +/* + * Configuration connections + * + * CCK - MCSPI1_CLK + * DIN - MCSPI1_MOSI + * PROG_B - GPIO_175 - output (change mux) + * DONE - GPIO_173 - input (change mux) + * INIT_B - GPIO_114 - input (change mux) + * +*/ + +const unsigned int PROG_B = 175; +const unsigned int DONE = 173; +const unsigned int INIT_B = 114; + +static std::string bit_file = "safe_u1e.bin"; + +const int BUF_SIZE = 4096; + +enum gpio_direction {IN, OUT}; + +class gpio { + public: + + gpio(unsigned int gpio_num, gpio_direction pin_direction); + + bool get_value(); + void set_value(bool state); + + private: + + std::stringstream base_path; + std::fstream value_file; +}; + +class spidev { + public: + + spidev(std::string dev_name); + ~spidev(); + + void send(char *wbuf, char *rbuf, unsigned int nbytes); + + private: + + int fd; + +}; + +gpio::gpio(unsigned int gpio_num, gpio_direction pin_direction) +{ + std::fstream export_file; + + export_file.open("/sys/class/gpio/export", std::ios::out); + if (!export_file.is_open()) ///\todo Poor error handling + std::cout << "Failed to open gpio export file." << std::endl; + + export_file << gpio_num << std::endl; + + base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; + + std::fstream direction_file; + std::string direction_file_name; + + direction_file_name = base_path.str() + "/direction"; + + direction_file.open(direction_file_name.c_str()); + if (!direction_file.is_open()) + std::cout << "Failed to open direction file." << std::endl; + if (pin_direction == OUT) + direction_file << "out" << std::endl; + else + direction_file << "in" << std::endl; + + std::string value_file_name; + + value_file_name = base_path.str() + "/value"; + + value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); + if (!value_file.is_open()) + std::cout << "Failed to open value file." << std::endl; +} + +bool gpio::get_value() +{ + + std::string val; + + std::getline(value_file, val); + value_file.seekg(0); + + if (val == "0") + return false; + else if (val == "1") + return true; + else + std::cout << "Data read from value file|" << val << "|" << std::endl; + + return false; +} + +void gpio::set_value(bool state) +{ + + if (state) + value_file << "1" << std::endl; + else + value_file << "0" << std::endl; +} + +static void prepare_fpga_for_configuration(gpio &prog, gpio &init) +{ + + prog.set_value(true); + prog.set_value(false); + prog.set_value(true); + +#if 0 + bool ready_to_program(false); + unsigned int count(0); + do { + ready_to_program = init.get_value(); + count++; + + sleep(1); + } while (count < 10 && !ready_to_program); + + if (count == 10) { + std::cout << "FPGA not ready for programming." << std::endl; + exit(-1); + } +#endif +} + +spidev::spidev(std::string fname) +{ + int ret; + int mode = 0; + int speed = 12000000; + int bits = 8; + + fd = open(fname.c_str(), O_RDWR); + + ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); + ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); +} + + +spidev::~spidev() +{ + close(fd); +} + +void spidev::send(char *buf, char *rbuf, unsigned int nbytes) +{ + int ret; + + struct spi_ioc_transfer tr; + tr.tx_buf = (unsigned long) buf; + tr.rx_buf = (unsigned long) rbuf; + tr.len = nbytes; + tr.delay_usecs = 0; + tr.speed_hz = 48000000; + tr.bits_per_word = 8; + + ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); + +} + +static void send_file_to_fpga(std::string &file_name, gpio &error, gpio &done) +{ + std::ifstream bitstream; + + std::cout << "File name - " << file_name.c_str() << std::endl; + + bitstream.open(file_name.c_str(), std::ios::binary); + if (!bitstream.is_open()) + std::cout << "File " << file_name << " not opened succesfully." << std::endl; + + spidev spi("/dev/spidev1.0"); + char buf[BUF_SIZE]; + char rbuf[BUF_SIZE]; + + do { + bitstream.read(buf, BUF_SIZE); + spi.send(buf, rbuf, bitstream.gcount()); + + if (error.get_value()) + std::cout << "INIT_B went high, error occured." << std::endl; + + if (!done.get_value()) + std::cout << "Configuration complete." << std::endl; + + } while (bitstream.gcount() == BUF_SIZE); +} + +int main(int argc, char *argv[]) +{ + + gpio gpio_prog_b(PROG_B, OUT); + gpio gpio_init_b(INIT_B, IN); + gpio gpio_done (DONE, IN); + + if (argc == 2) + bit_file = argv[1]; + + bool module_found(false); + std::ifstream mod_file("/proc/modules"); + while (!mod_file.eof()) { + std::string line; + getline(mod_file, line); + if (line.find("usrp_e") != std::string::npos) + module_found = true; + } + mod_file.close(); + + if (module_found) { + std::cout << "USRP Embedded kernel module loaded, not loading FPGA." << std::endl; + return -1; + } + + std::cout << "FPGA config file: " << bit_file << std::endl; + + prepare_fpga_for_configuration(gpio_prog_b, gpio_init_b); + + std::cout << "Done = " << gpio_done.get_value() << std::endl; + + send_file_to_fpga(bit_file, gpio_init_b, gpio_done); +} + diff --git a/host/usrp_e_utils/usrp-e-debug-pins.c b/host/usrp_e_utils/usrp-e-debug-pins.c new file mode 100644 index 000000000..94f898b67 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-debug-pins.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include "usrp_e100_regs.hpp" + +// Usage: usrp_e_gpio + +static int fp; + +static int read_reg(__u16 reg) +{ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + ret = ioctl(fp, USRP_E_READ_CTL16, &d); + return d.buf[0]; +} + +static void write_reg(__u16 reg, __u16 val) +{ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + d.buf[0] = val; + ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); +} + +int main(int argc, char *argv[]) +{ + int test; + + test = 0; + if (argc < 2) { + printf("%s 0|1|off\n", argv[0]); + return -1; + } + + fp = open("/dev/usrp_e0", O_RDWR); + printf("fp = %d\n", fp); + if (fp < 0) { + perror("Open failed"); + return -1; + } + + if (strcmp(argv[1], "0") == 0) { + printf("Selected 0 based on %s\n", argv[1]); + write_reg(UE_REG_GPIO_TX_DDR, 0xFFFF); + write_reg(UE_REG_GPIO_RX_DDR, 0xFFFF); + write_reg(UE_REG_GPIO_TX_SEL, 0x0); + write_reg(UE_REG_GPIO_RX_SEL, 0x0); + write_reg(UE_REG_GPIO_TX_DBG, 0xFFFF); + write_reg(UE_REG_GPIO_RX_DBG, 0xFFFF); + } else if (strcmp(argv[1], "1") == 0) { + printf("Selected 1 based on %s\n", argv[1]); + write_reg(UE_REG_GPIO_TX_DDR, 0xFFFF); + write_reg(UE_REG_GPIO_RX_DDR, 0xFFFF); + write_reg(UE_REG_GPIO_TX_SEL, 0xFFFF); + write_reg(UE_REG_GPIO_RX_SEL, 0xFFFF); + write_reg(UE_REG_GPIO_TX_DBG, 0xFFFF); + write_reg(UE_REG_GPIO_RX_DBG, 0xFFFF); + } else { + printf("Selected off based on %s\n", argv[1]); + write_reg(UE_REG_GPIO_TX_DDR, 0x0); + write_reg(UE_REG_GPIO_RX_DDR, 0x0); + } + + return 0; +} diff --git a/host/usrp_e_utils/usrp-e-i2c.c b/host/usrp_e_utils/usrp-e-i2c.c new file mode 100644 index 000000000..c6fd4c632 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-i2c.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +// Usage: usrp_e_i2c w address data0 data1 data 2 .... +// Usage: usrp_e_i2c r address count + +int main(int argc, char *argv[]) +{ + int fp, ret, i, tmp; + struct usrp_e_i2c *i2c_msg; + int direction, address, count; + + if (argc < 3) { + printf("Usage: usrp-e-i2c w address data0 data1 data2 ...\n"); + printf("Usage: usrp-e-i2c r address count\n"); + printf("All addresses and data in hex.\n"); + exit(-1); + } + + if (strcmp(argv[1], "r") == 0) { + direction = 0; + } else if (strcmp(argv[1], "w") == 0) { + direction = 1; + } else { + return -1; + } + + sscanf(argv[2], "%X", &address); + printf("Address = %X\n", address); + + fp = open("/dev/usrp_e0", O_RDWR); + printf("fp = %d\n", fp); + if (fp < 0) { + perror("Open failed"); + return -1; + } + +// sleep(1); + + if (direction) { + count = argc - 3; + } else { + sscanf(argv[3], "%X", &count); + } + printf("Count = %X\n", count); + + i2c_msg = malloc(sizeof(i2c_msg) + count * sizeof(char)); + + i2c_msg->addr = address; + i2c_msg->len = count; + + for (i = 0; i < count; i++) { + i2c_msg->data[i] = i; + } + + if (direction) { + // Write + + for (i=0; idata[i] = tmp; + } + + ret = ioctl(fp, USRP_E_I2C_WRITE, i2c_msg); + printf("Return value from i2c_write ioctl: %d\n", ret); + } else { + // Read + + ret = ioctl(fp, USRP_E_I2C_READ, i2c_msg); + printf("Return value from i2c_read ioctl: %d\n", ret); + + printf("Ioctl: %d Data read :", ret); + for (i=0; idata[i]); + } + printf("\n"); + + } + return 0; +} diff --git a/host/usrp_e_utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c new file mode 100644 index 000000000..454d81ba7 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-loopback.c @@ -0,0 +1,231 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_PACKET_SIZE 1016 +static int packet_data_length; +static int error; + +struct pkt { + int len; + int checksum; + int seq_num; + short data[]; +}; + +static int length_array[2048]; +static int length_array_tail = 0; +static int length_array_head = 0; + +pthread_mutex_t length_array_mutex; //gotta lock the index to keep it from getting hosed + +//yes this is a circular buffer that does not check empty +//no i don't want to hear about it +void push_length_array(int length) { + pthread_mutex_lock(&length_array_mutex); + if(length_array_tail > 2047) length_array_tail = 0; + length_array[length_array_tail++] = length; + pthread_mutex_unlock(&length_array_mutex); +} + +int pop_length_array(void) { + int retval; + pthread_mutex_lock(&length_array_mutex); + if(length_array_head > 2047) length_array_head = 0; + retval = length_array[length_array_head++]; + pthread_mutex_unlock(&length_array_mutex); + return retval; +} + +static int fp; + +static int calc_checksum(struct pkt *p) +{ + int i, sum; + + i = 0; + sum = 0; + + for (i=0; i < p->len; i++) + sum ^= p->data[i]; + + sum ^= p->seq_num; + sum ^= p->len; + + return sum; +} + +static void *read_thread(void *threadid) +{ + char *rx_data; + int cnt, prev_seq_num, pkt_count, seq_num_failure; + struct pkt *p; + unsigned long bytes_transfered, elapsed_seconds; + struct timeval start_time, finish_time; + int expected_count; + + printf("Greetings from the reading thread!\n"); + + bytes_transfered = 0; + gettimeofday(&start_time, NULL); + + // IMPORTANT: must assume max length packet from fpga + rx_data = malloc(2048); + p = (struct pkt *) ((void *)rx_data); + + prev_seq_num = 0; + pkt_count = 0; + seq_num_failure = 0; + + while (1) { + + cnt = read(fp, rx_data, 2048); + if (cnt < 0) + printf("Error returned from read: %d, sequence number = %d\n", cnt, p->seq_num); + +// printf("p->seq_num = %d\n", p->seq_num); + + + pkt_count++; + + if (p->seq_num != prev_seq_num + 1) { + printf("Sequence number fail, current = %d, previous = %d, pkt_count = %d\n", + p->seq_num, prev_seq_num, pkt_count); + + seq_num_failure ++; + if (seq_num_failure > 2) + error = 1; + } + + expected_count = pop_length_array()*2+12; + if(cnt != expected_count) { + printf("Received %d bytes, expected %d\n", cnt, expected_count); + } + + prev_seq_num = p->seq_num; + + if (calc_checksum(p) != p->checksum) { + printf("Checksum fail packet = %X, expected = %X, pkt_count = %d\n", + calc_checksum(p), p->checksum, pkt_count); + error = 1; + } + + bytes_transfered += cnt; + + if (bytes_transfered > (100 * 1000000)) { + gettimeofday(&finish_time, NULL); + elapsed_seconds = finish_time.tv_sec - start_time.tv_sec; + + printf("RX data transfer rate = %f K Samples/second\n", + (float) bytes_transfered / (float) elapsed_seconds / 4000); + + + start_time = finish_time; + bytes_transfered = 0; + } + + +// printf("."); +// fflush(stdout); +// printf("\n"); + } + +} + +static void *write_thread(void *threadid) +{ + int seq_number, i, cnt; + void *tx_data; + struct pkt *p; + + printf("Greetings from the write thread!\n"); + + tx_data = malloc(2048); + p = (struct pkt *) ((void *)tx_data); + + for (i=0; i < packet_data_length; i++) +// p->data[i] = random() >> 16; + p->data[i] = i; + + seq_number = 1; + + while (1) { + p->seq_num = seq_number++; + + if (packet_data_length > 0) + p->len = packet_data_length; + else + p->len = (random()<<1 & 0x1ff) + (1004 - 512); + + push_length_array(p->len); + + p->checksum = calc_checksum(p); + + cnt = write(fp, tx_data, p->len * 2 + 12); + if (cnt < 0) + printf("Error returned from write: %d\n", cnt); +// sleep(1); + } +} + + +int main(int argc, char *argv[]) +{ + pthread_t tx, rx; + pthread_mutex_init(&length_array_mutex, 0); + long int t; + struct sched_param s = { + .sched_priority = 1 + }; + void *rb; + struct usrp_transfer_frame *tx_rb, *rx_rb; + + if (argc < 2) { + printf("%s data_size\n", argv[0]); + return -1; + } + + packet_data_length = atoi(argv[1]); + if(packet_data_length > MAX_PACKET_SIZE) { + printf("Packet size must be smaller than %i\n", MAX_PACKET_SIZE); + exit(-1); + } + + fp = open("/dev/usrp_e0", O_RDWR); + printf("fp = %d\n", fp); + + rb = mmap(0, 202 * 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fp, 0); + if (!rb) { + printf("mmap failed\n"); + exit; + } + + + sched_setscheduler(0, SCHED_RR, &s); + error = 0; + +#if 1 + if (pthread_create(&rx, NULL, read_thread, (void *) t)) { + printf("Failed to create rx thread\n"); + exit(-1); + } + + sleep(1); +#endif + + if (pthread_create(&tx, NULL, write_thread, (void *) t)) { + printf("Failed to create tx thread\n"); + exit(-1); + } + +// while (!error) + sleep(1000000000); + + printf("Done sleeping\n"); +} diff --git a/host/usrp_e_utils/usrp-e-spi.c b/host/usrp_e_utils/usrp-e-spi.c new file mode 100644 index 000000000..5203f56a8 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-spi.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include +#include + +#include + +// Usage: usrp_e_spi w|rb slave data + +int main(int argc, char *argv[]) +{ + int fp, slave, length, ret; + unsigned int data; + struct usrp_e_spi spi_dat; + + if (argc < 5) { + printf("Usage: usrp_e_spi w|rb slave transfer_length data\n"); + exit(-1); + } + + slave = atoi(argv[2]); + length = atoi(argv[3]); + data = atoll(argv[4]); + + printf("Data = %X\n", data); + + fp = open("/dev/usrp_e0", O_RDWR); + printf("fp = %d\n", fp); + if (fp < 0) { + perror("Open failed"); + return -1; + } + +// sleep(1); + + + spi_dat.slave = slave; + spi_dat.data = data; + spi_dat.length = length; + spi_dat.flags = UE_SPI_PUSH_FALL | UE_SPI_LATCH_RISE; + + if (*argv[1] == 'r') { + spi_dat.readback = 1; + ret = ioctl(fp, USRP_E_SPI, &spi_dat); + printf("Ioctl returns: %d, Data returned = %d\n", ret, spi_dat.data); + } else { + spi_dat.readback = 0; + ioctl(fp, USRP_E_SPI, &spi_dat); + } + + return 0; +} diff --git a/host/usrp_e_utils/usrp-e-wb-test.cpp b/host/usrp_e_utils/usrp-e-wb-test.cpp new file mode 100644 index 000000000..871cc46cc --- /dev/null +++ b/host/usrp_e_utils/usrp-e-wb-test.cpp @@ -0,0 +1,111 @@ +// +// Copyright 2011 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include + +#include //ioctl +#include //open, close + +#include +#include "usrp_e100_regs.hpp" + +static const size_t num_test_iters = 432; + +static int fp; + +static int peek16(int reg){ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + ret = ioctl(fp, USRP_E_READ_CTL16, &d); + return d.buf[0]; +} + +static void poke16(int reg, int val){ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + d.buf[0] = val; + ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); +} + +static int peek32(int reg){ + int ret; + struct usrp_e_ctl32 d; + + d.offset = reg; + d.count = 1; + ret = ioctl(fp, USRP_E_READ_CTL32, &d); + return d.buf[0]; +} + +static void poke32(int reg, int val){ + int ret; + struct usrp_e_ctl32 d; + + d.offset = reg; + d.count = 1; + d.buf[0] = val; + ret = ioctl(fp, USRP_E_WRITE_CTL32, &d); +} + +int main(int, char *[]){ + + srandom(time(NULL)); //seed random() + + if ((fp = ::open("/dev/usrp_e0", O_RDWR)) < 0){ + std::cerr << "Open failed" << std::endl; + return -1; + } + + size_t num_pass = 0, num_fail = 0; + for (size_t i = 0; i < num_test_iters; i++){ + //make random values + int random_test32 = ::random(); + int random_test16 = ::random() & 0xffff; + int random_secs = ::random(); + + //set a bunch of registers + poke16(UE_REG_MISC_TEST, random_test16); + poke32(UE_REG_SR_MISC_TEST32, random_test32); + poke32(UE_REG_TIME64_TICKS, 0); + poke32(UE_REG_TIME64_IMM, 1); //immediate + poke32(UE_REG_TIME64_SECS, random_secs); + + //read a bunch of registers + if ( + (peek16(UE_REG_MISC_TEST) == random_test16) and + (peek32(UE_REG_RB_MISC_TEST32) == random_test32) and + (peek32(UE_REG_RB_TIME_NOW_SECS) == random_secs) and + (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and + true) num_pass++; + else num_fail++; + } + + std::cout << "num pass: " << num_pass << std::endl; + std::cout << "num fail: " << num_fail << std::endl; + + ::close(fp); + return 0; +} -- cgit v1.2.3 From c926cf77bb9b132172b0e900cea960abd6c5a43e Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 26 Jan 2011 15:55:44 -0800 Subject: Local changes for wishbone tests, PLease review carefully. --- host/usrp_e_utils/usrp-e-wb-test.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'host/usrp_e_utils') diff --git a/host/usrp_e_utils/usrp-e-wb-test.cpp b/host/usrp_e_utils/usrp-e-wb-test.cpp index 871cc46cc..3d6a8d101 100644 --- a/host/usrp_e_utils/usrp-e-wb-test.cpp +++ b/host/usrp_e_utils/usrp-e-wb-test.cpp @@ -26,7 +26,7 @@ #include #include "usrp_e100_regs.hpp" -static const size_t num_test_iters = 432; +static const size_t num_test_iters = 10000000; static int fp; @@ -81,6 +81,10 @@ int main(int, char *[]){ size_t num_pass = 0, num_fail = 0; for (size_t i = 0; i < num_test_iters; i++){ + if(i%1000000 == 0) { + std::cout << "num pass: " << num_pass; + std::cout << "\tnum fail: " << num_fail << std::endl; + } //make random values int random_test32 = ::random(); int random_test16 = ::random() & 0xffff; @@ -98,7 +102,7 @@ int main(int, char *[]){ (peek16(UE_REG_MISC_TEST) == random_test16) and (peek32(UE_REG_RB_MISC_TEST32) == random_test32) and (peek32(UE_REG_RB_TIME_NOW_SECS) == random_secs) and - (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and +// (peek32(UE_REG_RB_TIME_NOW_TICKS) < 1000000) and true) num_pass++; else num_fail++; } -- cgit v1.2.3 From 2cb6092ddfcf5f3881faa455566d4f332b01d0ac Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 31 Jan 2011 20:26:45 +0000 Subject: usrp-e100: combined clkconfig and fpga downloader into usrp-e-utility, simplified code --- host/examples/rx_timed_samples.cpp | 9 +- host/lib/usrp/usrp_e100/CMakeLists.txt | 4 +- host/lib/usrp/usrp_e100/fpga-downloader.cc | 274 ------------------------ host/lib/usrp/usrp_e100/fpga_downloader.cpp | 262 +++++++++++++++++++++++ host/usrp_e_utils/CMakeLists.txt | 6 +- host/usrp_e_utils/clkgen-config.cpp | 305 --------------------------- host/usrp_e_utils/clkgen_config.hpp | 310 ++++++++++++++++++++++++++++ host/usrp_e_utils/fpga-downloader.cpp | 267 ------------------------ host/usrp_e_utils/usrp-e-utility.cpp | 72 +++++++ 9 files changed, 657 insertions(+), 852 deletions(-) delete mode 100644 host/lib/usrp/usrp_e100/fpga-downloader.cc create mode 100644 host/lib/usrp/usrp_e100/fpga_downloader.cpp delete mode 100644 host/usrp_e_utils/clkgen-config.cpp create mode 100644 host/usrp_e_utils/clkgen_config.hpp delete mode 100644 host/usrp_e_utils/fpga-downloader.cpp create mode 100644 host/usrp_e_utils/usrp-e-utility.cpp (limited to 'host/usrp_e_utils') diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 9ebe36c5a..630b4a7a9 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -32,7 +32,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string args; double seconds_in_future; size_t total_num_samps; - double rate, freq; + double rate, freq, clock; //setup the program options po::options_description desc("Allowed options"); @@ -41,6 +41,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ ("args", po::value(&args)->default_value(""), "single uhd device address args") ("secs", po::value(&seconds_in_future)->default_value(3), "number of seconds in the future to receive") ("nsamps", po::value(&total_num_samps)->default_value(1000), "total number of samples to receive") + ("clock", po::value(&clock), "master clock frequency in Hz") ("rate", po::value(&rate)->default_value(100e6/16), "rate of incoming samples") ("freq", po::value(&freq)->default_value(0), "rf center frequency in Hz") ("dilv", "specify to disable inner-loop verbose") @@ -63,6 +64,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; + //optionally set the clock rate (do before setting anything else) + if (vm.count("clock")){ + std::cout << boost::format("Setting master clock rate: %f MHz...") % (clock/1e6) << std::endl; + usrp->set_master_clock_rate(clock); + } + //set the rx sample rate std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl; usrp->set_rx_rate(rate); diff --git a/host/lib/usrp/usrp_e100/CMakeLists.txt b/host/lib/usrp/usrp_e100/CMakeLists.txt index c32dd87f8..acbac177e 100644 --- a/host/lib/usrp/usrp_e100/CMakeLists.txt +++ b/host/lib/usrp/usrp_e100/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 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 @@ -40,7 +40,7 @@ IF(ENABLE_USRP_E100) ${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/fpga-downloader.cc + ${CMAKE_CURRENT_SOURCE_DIR}/fpga_downloader.cpp ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/usrp_e100_impl.cpp diff --git a/host/lib/usrp/usrp_e100/fpga-downloader.cc b/host/lib/usrp/usrp_e100/fpga-downloader.cc deleted file mode 100644 index 4a3d3b9af..000000000 --- a/host/lib/usrp/usrp_e100/fpga-downloader.cc +++ /dev/null @@ -1,274 +0,0 @@ -// -// Copyright 2010 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -/* - * Configuration connections - * - * CCK - MCSPI1_CLK - * DIN - MCSPI1_MOSI - * PROG_B - GPIO_175 - output (change mux) - * DONE - GPIO_173 - input (change mux) - * INIT_B - GPIO_114 - input (change mux) - * -*/ - -const unsigned int PROG_B = 175; -const unsigned int DONE = 173; -const unsigned int INIT_B = 114; - -//static std::string bit_file = "safe_u1e.bin"; - -const int BUF_SIZE = 4096; - -enum gpio_direction {IN, OUT}; - -class gpio { - public: - - gpio(unsigned int gpio_num, gpio_direction pin_direction); - - bool get_value(); - void set_value(bool state); - - private: - - std::stringstream base_path; - std::fstream value_file; -}; - -class spidev { - public: - - spidev(std::string dev_name); - ~spidev(); - - void send(char *wbuf, char *rbuf, unsigned int nbytes); - - private: - - int fd; - -}; - -gpio::gpio(unsigned int gpio_num, gpio_direction pin_direction) -{ - std::fstream export_file; - - export_file.open("/sys/class/gpio/export", std::ios::out); - if (not export_file.is_open()) throw std::runtime_error( - "Failed to open gpio export file." - ); - - export_file << gpio_num << std::endl; - - base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; - - std::fstream direction_file; - std::string direction_file_name; - - if (gpio_num != 114) { - direction_file_name = base_path.str() + "/direction"; - - direction_file.open(direction_file_name.c_str()); - if (!direction_file.is_open()) - std::cout << "Failed to open direction file." << std::endl; - if (pin_direction == OUT) - direction_file << "out" << std::endl; - else - direction_file << "in" << std::endl; - } - - std::string value_file_name; - - value_file_name = base_path.str() + "/value"; - - value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); - if (!value_file.is_open()) - std::cout << "Failed to open value file." << std::endl; -} - -bool gpio::get_value() -{ - - std::string val; - - std::getline(value_file, val); - value_file.seekg(0); - - if (val == "0") - return false; - else if (val == "1") - return true; - else - std::cout << "Data read from value file|" << val << "|" << std::endl; - - return false; -} - -void gpio::set_value(bool state) -{ - - if (state) - value_file << "1" << std::endl; - else - value_file << "0" << std::endl; -} - -static void prepare_fpga_for_configuration(gpio &prog, gpio &)//init) -{ - - prog.set_value(true); - prog.set_value(false); - prog.set_value(true); - -#if 0 - bool ready_to_program(false); - unsigned int count(0); - do { - ready_to_program = init.get_value(); - count++; - - sleep(1); - } while (count < 10 && !ready_to_program); - - if (count == 10) { - std::cout << "FPGA not ready for programming." << std::endl; - exit(-1); - } -#endif -} - -spidev::spidev(std::string fname) -{ - int ret; - int mode = 0; - int speed = 12000000; - int bits = 8; - - fd = open(fname.c_str(), O_RDWR); - - ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); - ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); -} - - -spidev::~spidev() -{ - close(fd); -} - -void spidev::send(char *buf, char *rbuf, unsigned int nbytes) -{ - int ret; - - struct spi_ioc_transfer tr; - tr.tx_buf = (unsigned long) buf; - tr.rx_buf = (unsigned long) rbuf; - tr.len = nbytes; - tr.delay_usecs = 0; - tr.speed_hz = 48000000; - tr.bits_per_word = 8; - - ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); - -} - -static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &done) -{ - std::ifstream bitstream; - - std::cout << "File name - " << file_name.c_str() << std::endl; - - bitstream.open(file_name.c_str(), std::ios::binary); - if (!bitstream.is_open()) - std::cout << "File " << file_name << " not opened succesfully." << std::endl; - - spidev spi("/dev/spidev1.0"); - char buf[BUF_SIZE]; - char rbuf[BUF_SIZE]; - - do { - bitstream.read(buf, BUF_SIZE); - spi.send(buf, rbuf, bitstream.gcount()); - - if (error.get_value()) - std::cout << "INIT_B went high, error occured." << std::endl; - - if (!done.get_value()) - std::cout << "Configuration complete." << std::endl; - - } while (bitstream.gcount() == BUF_SIZE); -} - -/* -int main(int argc, char *argv[]) -{ - - gpio gpio_prog_b(PROG_B, OUT); - gpio gpio_init_b(INIT_B, IN); - gpio gpio_done (DONE, IN); - - if (argc == 2) - bit_file = argv[1]; - - std::cout << "FPGA config file: " << bit_file << std::endl; - - prepare_fpga_for_configuration(gpio_prog_b, gpio_init_b); - - std::cout << "Done = " << gpio_done.get_value() << std::endl; - - send_file_to_fpga(bit_file, gpio_init_b, gpio_done); -} -*/ - -void usrp_e100_load_fpga(const std::string &bin_file){ - gpio gpio_prog_b(PROG_B, OUT); - gpio gpio_init_b(INIT_B, IN); - gpio gpio_done (DONE, IN); - - std::cout << "Loading FPGA image: " << bin_file << "... " << std::flush; - - UHD_ASSERT_THROW(std::system("/sbin/rmmod usrp_e") == 0); - - prepare_fpga_for_configuration(gpio_prog_b, gpio_init_b); - - std::cout << "done = " << gpio_done.get_value() << std::endl; - - send_file_to_fpga(bin_file, gpio_init_b, gpio_done); - - UHD_ASSERT_THROW(std::system("/sbin/modprobe usrp_e") == 0); - -} - diff --git a/host/lib/usrp/usrp_e100/fpga_downloader.cpp b/host/lib/usrp/usrp_e100/fpga_downloader.cpp new file mode 100644 index 000000000..926e6fcaf --- /dev/null +++ b/host/lib/usrp/usrp_e100/fpga_downloader.cpp @@ -0,0 +1,262 @@ +// +// Copyright 2010 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +/* + * Configuration connections + * + * CCK - MCSPI1_CLK + * DIN - MCSPI1_MOSI + * PROG_B - GPIO_175 - output (change mux) + * DONE - GPIO_173 - input (change mux) + * INIT_B - GPIO_114 - input (change mux) + * +*/ + +namespace usrp_e_fpga_downloader_utility{ + +const unsigned int PROG_B = 175; +const unsigned int DONE = 173; +const unsigned int INIT_B = 114; + +//static std::string bit_file = "safe_u1e.bin"; + +const int BUF_SIZE = 4096; + +enum gpio_direction {IN, OUT}; + +class gpio { + public: + + gpio(unsigned int gpio_num, gpio_direction pin_direction); + + bool get_value(); + void set_value(bool state); + + private: + + std::stringstream base_path; + std::fstream value_file; +}; + +class spidev { + public: + + spidev(std::string dev_name); + ~spidev(); + + void send(char *wbuf, char *rbuf, unsigned int nbytes); + + private: + + int fd; + +}; + +gpio::gpio(unsigned int gpio_num, gpio_direction pin_direction) +{ + std::fstream export_file; + + export_file.open("/sys/class/gpio/export", std::ios::out); + if (not export_file.is_open()) throw std::runtime_error( + "Failed to open gpio export file." + ); + + export_file << gpio_num << std::endl; + + base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; + + std::fstream direction_file; + std::string direction_file_name; + + if (gpio_num != 114) { + direction_file_name = base_path.str() + "/direction"; + + direction_file.open(direction_file_name.c_str()); + if (!direction_file.is_open()) + std::cout << "Failed to open direction file." << std::endl; + if (pin_direction == OUT) + direction_file << "out" << std::endl; + else + direction_file << "in" << std::endl; + } + + std::string value_file_name; + + value_file_name = base_path.str() + "/value"; + + value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); + if (!value_file.is_open()) + std::cout << "Failed to open value file." << std::endl; +} + +bool gpio::get_value() +{ + + std::string val; + + std::getline(value_file, val); + value_file.seekg(0); + + if (val == "0") + return false; + else if (val == "1") + return true; + else + std::cout << "Data read from value file|" << val << "|" << std::endl; + + return false; +} + +void gpio::set_value(bool state) +{ + + if (state) + value_file << "1" << std::endl; + else + value_file << "0" << std::endl; +} + +static void prepare_fpga_for_configuration(gpio &prog, gpio &)//init) +{ + + prog.set_value(true); + prog.set_value(false); + prog.set_value(true); + +#if 0 + bool ready_to_program(false); + unsigned int count(0); + do { + ready_to_program = init.get_value(); + count++; + + sleep(1); + } while (count < 10 && !ready_to_program); + + if (count == 10) { + std::cout << "FPGA not ready for programming." << std::endl; + exit(-1); + } +#endif +} + +spidev::spidev(std::string fname) +{ + int ret; + int mode = 0; + int speed = 12000000; + int bits = 8; + + fd = open(fname.c_str(), O_RDWR); + + ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); + ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); +} + + +spidev::~spidev() +{ + close(fd); +} + +void spidev::send(char *buf, char *rbuf, unsigned int nbytes) +{ + int ret; + + struct spi_ioc_transfer tr; + tr.tx_buf = (unsigned long) buf; + tr.rx_buf = (unsigned long) rbuf; + tr.len = nbytes; + tr.delay_usecs = 0; + tr.speed_hz = 48000000; + tr.bits_per_word = 8; + + ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); + +} + +static void send_file_to_fpga(const std::string &file_name, gpio &error, gpio &done) +{ + std::ifstream bitstream; + + bitstream.open(file_name.c_str(), std::ios::binary); + if (!bitstream.is_open()) throw std::runtime_error( + "Coult not open the file: " + file_name + ); + + spidev spi("/dev/spidev1.0"); + char buf[BUF_SIZE]; + char rbuf[BUF_SIZE]; + + do { + bitstream.read(buf, BUF_SIZE); + spi.send(buf, rbuf, bitstream.gcount()); + + if (error.get_value()) + std::cout << "INIT_B went high, error occured." << std::endl; + + if (!done.get_value()) + std::cout << "Configuration complete." << std::endl; + + } while (bitstream.gcount() == BUF_SIZE); +} + +}//namespace usrp_e_fpga_downloader_utility + +void usrp_e100_load_fpga(const std::string &bin_file){ + using namespace usrp_e_fpga_downloader_utility; + + gpio gpio_prog_b(PROG_B, OUT); + gpio gpio_init_b(INIT_B, IN); + gpio gpio_done (DONE, IN); + + std::cout << "Loading FPGA image: " << bin_file << "... " << std::flush; + + if(std::system("/sbin/rmmod usrp_e") != 0){ + std::cerr << "USRP-E100 FPGA downloader: could not unload usrp_e module" << std::endl; + } + + prepare_fpga_for_configuration(gpio_prog_b, gpio_init_b); + + std::cout << "done = " << gpio_done.get_value() << std::endl; + + send_file_to_fpga(bin_file, gpio_init_b, gpio_done); + + if(std::system("/sbin/modprobe usrp_e") != 0){ + std::cerr << "USRP-E100 FPGA downloader: could not load usrp_e module" << std::endl; + } + +} + diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt index 96842a684..5123af592 100644 --- a/host/usrp_e_utils/CMakeLists.txt +++ b/host/usrp_e_utils/CMakeLists.txt @@ -26,13 +26,13 @@ LIBUHD_REGISTER_COMPONENT("USRP-E Utils" ENABLE_USRP_E_UTILS OFF "LINUX_TARGET" IF(ENABLE_USRP_E_UTILS) ENABLE_LANGUAGE(C) + INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/usrp/usrp_e100/include) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/lib/ic_reg_maps) SET(usrp_e_utils_sources - fpga-downloader.cpp - clkgen-config.cpp + usrp-e-utility.cpp usrp-e-loopback.c usrp-e-wb-test.cpp usrp-e-debug-pins.c @@ -44,7 +44,7 @@ IF(ENABLE_USRP_E_UTILS) FOREACH(util_source ${usrp_e_utils_sources}) GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE) ADD_EXECUTABLE(${util_name} ${util_source}) - TARGET_LINK_LIBRARIES(${util_name} -lpthread) + TARGET_LINK_LIBRARIES(${util_name} ${Boost_LIBRARIES}) INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/usrp_e_utils) ENDFOREACH(util_source) diff --git a/host/usrp_e_utils/clkgen-config.cpp b/host/usrp_e_utils/clkgen-config.cpp deleted file mode 100644 index 8d29efff1..000000000 --- a/host/usrp_e_utils/clkgen-config.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc. - * - * This file is part of UHD - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "ad9522_regs.hpp" - -#include - - -const unsigned int CLKGEN_SELECT = 145; - -enum gpio_direction {IN, OUT}; - -class gpio { - public: - - gpio(unsigned int gpio_num, gpio_direction pin_direction, bool close_action); - ~gpio(); - - bool get_value(); - void set_value(bool state); - - private: - - unsigned int gpio_num; - - std::stringstream base_path; - std::fstream value_file; - std::fstream direction_file; - bool close_action; // True set to input and release, false do nothing -}; - -class spidev { - public: - - spidev(std::string dev_name); - ~spidev(); - - void send(char *wbuf, char *rbuf, unsigned int nbytes); - - private: - - int fd; - -}; - -gpio::gpio(unsigned int _gpio_num, gpio_direction pin_direction, bool close_action) -{ - std::fstream export_file; - - gpio_num = _gpio_num; - - export_file.open("/sys/class/gpio/export", std::ios::out); - if (!export_file.is_open()) ///\todo Poor error handling - std::cout << "Failed to open gpio export file." << std::endl; - - export_file << gpio_num << std::endl; - - base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; - - std::string direction_file_name; - - direction_file_name = base_path.str() + "/direction"; - - direction_file.open(direction_file_name.c_str()); - if (!direction_file.is_open()) - std::cout << "Failed to open direction file." << std::endl; - if (pin_direction == OUT) - direction_file << "out" << std::endl; - else - direction_file << "in" << std::endl; - - std::string value_file_name; - - value_file_name = base_path.str() + "/value"; - - value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); - if (!value_file.is_open()) - std::cout << "Failed to open value file." << std::endl; -} - -bool gpio::get_value() -{ - - std::string val; - - std::getline(value_file, val); - value_file.seekg(0); - - if (val == "0") - return false; - else if (val == "1") - return true; - else - std::cout << "Data read from value file|" << val << "|" << std::endl; - - return false; -} - -void gpio::set_value(bool state) -{ - - if (state) - value_file << "1" << std::endl; - else - value_file << "0" << std::endl; -} - -gpio::~gpio() -{ - if (close_action) { - std::fstream unexport_file; - - direction_file << "in" << std::endl; - - unexport_file.open("/sys/class/gpio/unexport", std::ios::out); - if (!unexport_file.is_open()) ///\todo Poor error handling - std::cout << "Failed to open gpio export file." << std::endl; - - unexport_file << gpio_num << std::endl; - - } - -} - -spidev::spidev(std::string fname) -{ - int ret; - int mode = 0; - int speed = 12000; - int bits = 24; - - fd = open(fname.c_str(), O_RDWR); - - ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); - ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); -} - - -spidev::~spidev() -{ - close(fd); -} - -void spidev::send(char *buf, char *rbuf, unsigned int nbytes) -{ - int ret; - - struct spi_ioc_transfer tr; - tr.tx_buf = (unsigned long) buf; - tr.rx_buf = (unsigned long) rbuf; - tr.len = nbytes; - tr.delay_usecs = 0; - tr.speed_hz = 12000000; - tr.bits_per_word = 24; - - ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); - -} - -static void spi_write_word(spidev spi, gpio &chip_select, const unsigned int addr, const unsigned char data) { - unsigned char out_data[3], in_data[3]; - unsigned char rw_w1_w0 = 0; //write one byte - out_data[0] = (rw_w1_w0 << 5) | (addr >> 8); - out_data[1] = addr & 0xff; - out_data[2] = data; - - chip_select.set_value(0); - spi.send((char *)out_data, (char *)in_data, 4); - chip_select.set_value(1); -} - -static void send_config_to_clkgen(gpio &chip_select) -{ - spidev spi("/dev/spidev1.0"); - - //do a soft reset - spi_write_word(spi, chip_select, 0x000, 1 << 5 | 1 << 2); - spi_write_word(spi, chip_select, 0x232, 0x1); - - // init some registers; - ad9522_regs_t ad9522_regs; - ad9522_regs.sdo_active = ad9522_regs_t::SDO_ACTIVE_SDO_SDIO; //use sdo and sdi - ad9522_regs.mirror = 1; //mirror sdo active - ad9522_regs.io_update = 1; //latch the registers - ad9522_regs.status_pin_control = 0x1; //n divider - ad9522_regs.ld_pin_control = 0x32; //show ref2 - ad9522_regs.refmon_pin_control = 0x12; //show ref2 - ad9522_regs.enb_stat_eeprom_at_stat_pin = 0; //use status pin as debug - - ad9522_regs.enable_ref2 = 0x1; - ad9522_regs.enable_ref1 = 0x0; - ad9522_regs.select_ref = ad9522_regs_t::SELECT_REF_REF2; - - ad9522_regs.set_r_counter(1); - ad9522_regs.a_counter = 0; - ad9522_regs.set_b_counter(20); - ad9522_regs.prescaler_p = ad9522_regs_t::PRESCALER_P_DIV8_9; - - ad9522_regs.pll_power_down = ad9522_regs_t::PLL_POWER_DOWN_NORMAL; //normal mode - ad9522_regs.cp_current = ad9522_regs_t::CP_CURRENT_1_2MA; - - ad9522_regs.vco_calibration_now = 1; //calibrate it! - ad9522_regs.vco_divider = ad9522_regs_t::VCO_DIVIDER_DIV5; - ad9522_regs.select_vco_or_clock = ad9522_regs_t::SELECT_VCO_OR_CLOCK_VCO; - - ad9522_regs.out0_format = ad9522_regs_t::OUT0_FORMAT_LVDS; - ad9522_regs.divider0_low_cycles = 2; //3 low - ad9522_regs.divider0_high_cycles = 1; //2 high - ad9522_regs.divider1_low_cycles = 2; //3 low - ad9522_regs.divider1_high_cycles = 1; //2 high - - ad9522_regs.enable_eeprom_write = 1; - - //write the registers - int reg_list[] = {0, 4, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 240, 241, 242, 243, - 244, 245, 246, 247, 248, 249, 250, 251, 252, - 253, 400, 401, 402, 403, 404, 405, 406, 407, - 408, 409, 410, 411, 480, 481, 560, 562, 2818, - 2819}; - - for(int i=0; i<49; i++) { //blame std::vector for this (no static initialization bs) - spi_write_word(spi, chip_select, reg_list[i], ad9522_regs.get_reg(reg_list[i])); - } - - sleep(1); - - if (1){//write settings to eeprom - - //load the register buffs - spi_write_word(spi, chip_select, 0xa00, 0x0); - spi_write_word(spi, chip_select, 0xa01, 0x0); - spi_write_word(spi, chip_select, 0xa02, 0x0); - spi_write_word(spi, chip_select, 0xa03, 0x2); - spi_write_word(spi, chip_select, 0xa04, 0x0); - spi_write_word(spi, chip_select, 0xa05, 0x4); - spi_write_word(spi, chip_select, 0xa06, 0xe); - spi_write_word(spi, chip_select, 0xa07, 0x0); - spi_write_word(spi, chip_select, 0xa08, 0x10); - spi_write_word(spi, chip_select, 0xa09, 0xe); - spi_write_word(spi, chip_select, 0xa0a, 0x0); - spi_write_word(spi, chip_select, 0xa0b, 0xf0); - spi_write_word(spi, chip_select, 0xa0c, 0xb); - spi_write_word(spi, chip_select, 0xa0d, 0x1); - spi_write_word(spi, chip_select, 0xa0e, 0x90); - spi_write_word(spi, chip_select, 0xa0f, 0x1); - spi_write_word(spi, chip_select, 0xa10, 0x1); - spi_write_word(spi, chip_select, 0xa11, 0xe0); - spi_write_word(spi, chip_select, 0xa12, 0x1); - spi_write_word(spi, chip_select, 0xa13, 0x2); - spi_write_word(spi, chip_select, 0xa14, 0x30); - spi_write_word(spi, chip_select, 0xa15, 0x80); - spi_write_word(spi, chip_select, 0xa16, 0xff); - - spi_write_word(spi, chip_select, 0x232, 0x01); //latch - sleep(1); - //////////////////////////////////////////////////////////////// - - ad9522_regs.reg2eeprom = 1; - //write to eeprom - spi_write_word(spi, chip_select, 0xB03, ad9522_regs.get_reg(0xB03)); - //io update - spi_write_word(spi, chip_select, 0x232, ad9522_regs.get_reg(0x232)); //latch - sleep(1); - } - -} - -int main(int argc, char *argv[]) -{ - gpio clkgen_select(CLKGEN_SELECT, OUT, true); - - send_config_to_clkgen(clkgen_select); -} - diff --git a/host/usrp_e_utils/clkgen_config.hpp b/host/usrp_e_utils/clkgen_config.hpp new file mode 100644 index 000000000..0c9dc8de2 --- /dev/null +++ b/host/usrp_e_utils/clkgen_config.hpp @@ -0,0 +1,310 @@ +// +// Copyright 2011 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef USRP_E_UTILS_CLKGEN_CONFIG_HPP +#define USRP_E_UTILS_CLKGEN_CONFIG_HPP + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "ad9522_regs.hpp" + +#include + +namespace usrp_e_clkgen_config_utility{ + +const unsigned int CLKGEN_SELECT = 145; + +enum gpio_direction {IN, OUT}; + +class gpio { + public: + + gpio(unsigned int gpio_num, gpio_direction pin_direction, bool close_action); + ~gpio(); + + bool get_value(); + void set_value(bool state); + + private: + + unsigned int gpio_num; + + std::stringstream base_path; + std::fstream value_file; + std::fstream direction_file; + bool close_action; // True set to input and release, false do nothing +}; + +class spidev { + public: + + spidev(std::string dev_name); + ~spidev(); + + void send(char *wbuf, char *rbuf, unsigned int nbytes); + + private: + + int fd; + +}; + +gpio::gpio(unsigned int _gpio_num, gpio_direction pin_direction, bool close_action) +:close_action(close_action) +{ + std::fstream export_file; + + gpio_num = _gpio_num; + + export_file.open("/sys/class/gpio/export", std::ios::out); + if (!export_file.is_open()) ///\todo Poor error handling + std::cout << "Failed to open gpio export file." << std::endl; + + export_file << gpio_num << std::endl; + + base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; + + std::string direction_file_name; + + direction_file_name = base_path.str() + "/direction"; + + direction_file.open(direction_file_name.c_str()); + if (!direction_file.is_open()) + std::cout << "Failed to open direction file." << std::endl; + if (pin_direction == OUT) + direction_file << "out" << std::endl; + else + direction_file << "in" << std::endl; + + std::string value_file_name; + + value_file_name = base_path.str() + "/value"; + + value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); + if (!value_file.is_open()) + std::cout << "Failed to open value file." << std::endl; +} + +bool gpio::get_value() +{ + + std::string val; + + std::getline(value_file, val); + value_file.seekg(0); + + if (val == "0") + return false; + else if (val == "1") + return true; + else + std::cout << "Data read from value file|" << val << "|" << std::endl; + + return false; +} + +void gpio::set_value(bool state) +{ + + if (state) + value_file << "1" << std::endl; + else + value_file << "0" << std::endl; +} + +gpio::~gpio() +{ + if (close_action) { + std::fstream unexport_file; + + direction_file << "in" << std::endl; + + unexport_file.open("/sys/class/gpio/unexport", std::ios::out); + if (!unexport_file.is_open()) ///\todo Poor error handling + std::cout << "Failed to open gpio export file." << std::endl; + + unexport_file << gpio_num << std::endl; + + } + +} + +spidev::spidev(std::string fname) +{ + int ret; + int mode = 0; + int speed = 12000; + int bits = 24; + + fd = open(fname.c_str(), O_RDWR); + + ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); + ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); + ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); +} + + +spidev::~spidev() +{ + close(fd); +} + +void spidev::send(char *buf, char *rbuf, unsigned int nbytes) +{ + int ret; + + struct spi_ioc_transfer tr; + tr.tx_buf = (unsigned long) buf; + tr.rx_buf = (unsigned long) rbuf; + tr.len = nbytes; + tr.delay_usecs = 0; + tr.speed_hz = 12000000; + tr.bits_per_word = 24; + + ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); + +} + +static void spi_write_word(spidev spi, gpio &chip_select, const unsigned int addr, const unsigned char data) { + unsigned char out_data[3], in_data[3]; + unsigned char rw_w1_w0 = 0; //write one byte + out_data[0] = (rw_w1_w0 << 5) | (addr >> 8); + out_data[1] = addr & 0xff; + out_data[2] = data; + + chip_select.set_value(0); + spi.send((char *)out_data, (char *)in_data, 4); + chip_select.set_value(1); +} + +static void send_config_to_clkgen(gpio &chip_select) +{ + spidev spi("/dev/spidev1.0"); + + //do a soft reset + spi_write_word(spi, chip_select, 0x000, 1 << 5 | 1 << 2); + spi_write_word(spi, chip_select, 0x232, 0x1); + + // init some registers; + ad9522_regs_t ad9522_regs; + ad9522_regs.sdo_active = ad9522_regs_t::SDO_ACTIVE_SDO_SDIO; //use sdo and sdi + ad9522_regs.mirror = 1; //mirror sdo active + ad9522_regs.io_update = 1; //latch the registers + ad9522_regs.status_pin_control = 0x1; //n divider + ad9522_regs.ld_pin_control = 0x32; //show ref2 + ad9522_regs.refmon_pin_control = 0x12; //show ref2 + ad9522_regs.enb_stat_eeprom_at_stat_pin = 0; //use status pin as debug + + ad9522_regs.enable_ref2 = 0x1; + ad9522_regs.enable_ref1 = 0x0; + ad9522_regs.select_ref = ad9522_regs_t::SELECT_REF_REF2; + + ad9522_regs.set_r_counter(1); + ad9522_regs.a_counter = 0; + ad9522_regs.set_b_counter(20); + ad9522_regs.prescaler_p = ad9522_regs_t::PRESCALER_P_DIV8_9; + + ad9522_regs.pll_power_down = ad9522_regs_t::PLL_POWER_DOWN_NORMAL; //normal mode + ad9522_regs.cp_current = ad9522_regs_t::CP_CURRENT_1_2MA; + + ad9522_regs.vco_calibration_now = 1; //calibrate it! + ad9522_regs.vco_divider = ad9522_regs_t::VCO_DIVIDER_DIV5; + ad9522_regs.select_vco_or_clock = ad9522_regs_t::SELECT_VCO_OR_CLOCK_VCO; + + ad9522_regs.out0_format = ad9522_regs_t::OUT0_FORMAT_LVDS; + ad9522_regs.divider0_low_cycles = 2; //3 low + ad9522_regs.divider0_high_cycles = 1; //2 high + ad9522_regs.divider1_low_cycles = 2; //3 low + ad9522_regs.divider1_high_cycles = 1; //2 high + + ad9522_regs.enable_eeprom_write = 1; + + //write the registers + int reg_list[] = {0, 4, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 240, 241, 242, 243, + 244, 245, 246, 247, 248, 249, 250, 251, 252, + 253, 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 480, 481, 560, 562, 2818, + 2819}; + + for(int i=0; i<49; i++) { //blame std::vector for this (no static initialization bs) + spi_write_word(spi, chip_select, reg_list[i], ad9522_regs.get_reg(reg_list[i])); + } + + sleep(1); + + if (1){//write settings to eeprom + + //load the register buffs + spi_write_word(spi, chip_select, 0xa00, 0x0); + spi_write_word(spi, chip_select, 0xa01, 0x0); + spi_write_word(spi, chip_select, 0xa02, 0x0); + spi_write_word(spi, chip_select, 0xa03, 0x2); + spi_write_word(spi, chip_select, 0xa04, 0x0); + spi_write_word(spi, chip_select, 0xa05, 0x4); + spi_write_word(spi, chip_select, 0xa06, 0xe); + spi_write_word(spi, chip_select, 0xa07, 0x0); + spi_write_word(spi, chip_select, 0xa08, 0x10); + spi_write_word(spi, chip_select, 0xa09, 0xe); + spi_write_word(spi, chip_select, 0xa0a, 0x0); + spi_write_word(spi, chip_select, 0xa0b, 0xf0); + spi_write_word(spi, chip_select, 0xa0c, 0xb); + spi_write_word(spi, chip_select, 0xa0d, 0x1); + spi_write_word(spi, chip_select, 0xa0e, 0x90); + spi_write_word(spi, chip_select, 0xa0f, 0x1); + spi_write_word(spi, chip_select, 0xa10, 0x1); + spi_write_word(spi, chip_select, 0xa11, 0xe0); + spi_write_word(spi, chip_select, 0xa12, 0x1); + spi_write_word(spi, chip_select, 0xa13, 0x2); + spi_write_word(spi, chip_select, 0xa14, 0x30); + spi_write_word(spi, chip_select, 0xa15, 0x80); + spi_write_word(spi, chip_select, 0xa16, 0xff); + + spi_write_word(spi, chip_select, 0x232, 0x01); //latch + sleep(1); + //////////////////////////////////////////////////////////////// + + ad9522_regs.reg2eeprom = 1; + //write to eeprom + spi_write_word(spi, chip_select, 0xB03, ad9522_regs.get_reg(0xB03)); + //io update + spi_write_word(spi, chip_select, 0x232, ad9522_regs.get_reg(0x232)); //latch + sleep(1); + } + +} + +}//namespace usrp_e_clkgen_config_utility + +//int main(int argc, char *argv[]) +static void clock_genconfig_main(void) +{ + using namespace usrp_e_clkgen_config_utility; + gpio clkgen_select(CLKGEN_SELECT, OUT, true); + + send_config_to_clkgen(clkgen_select); +} + +#endif /*USRP_E_UTILS_CLKGEN_CONFIG_HPP*/ diff --git a/host/usrp_e_utils/fpga-downloader.cpp b/host/usrp_e_utils/fpga-downloader.cpp deleted file mode 100644 index 80ee71600..000000000 --- a/host/usrp_e_utils/fpga-downloader.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2003,2004,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -/* - * Configuration connections - * - * CCK - MCSPI1_CLK - * DIN - MCSPI1_MOSI - * PROG_B - GPIO_175 - output (change mux) - * DONE - GPIO_173 - input (change mux) - * INIT_B - GPIO_114 - input (change mux) - * -*/ - -const unsigned int PROG_B = 175; -const unsigned int DONE = 173; -const unsigned int INIT_B = 114; - -static std::string bit_file = "safe_u1e.bin"; - -const int BUF_SIZE = 4096; - -enum gpio_direction {IN, OUT}; - -class gpio { - public: - - gpio(unsigned int gpio_num, gpio_direction pin_direction); - - bool get_value(); - void set_value(bool state); - - private: - - std::stringstream base_path; - std::fstream value_file; -}; - -class spidev { - public: - - spidev(std::string dev_name); - ~spidev(); - - void send(char *wbuf, char *rbuf, unsigned int nbytes); - - private: - - int fd; - -}; - -gpio::gpio(unsigned int gpio_num, gpio_direction pin_direction) -{ - std::fstream export_file; - - export_file.open("/sys/class/gpio/export", std::ios::out); - if (!export_file.is_open()) ///\todo Poor error handling - std::cout << "Failed to open gpio export file." << std::endl; - - export_file << gpio_num << std::endl; - - base_path << "/sys/class/gpio/gpio" << gpio_num << std::flush; - - std::fstream direction_file; - std::string direction_file_name; - - direction_file_name = base_path.str() + "/direction"; - - direction_file.open(direction_file_name.c_str()); - if (!direction_file.is_open()) - std::cout << "Failed to open direction file." << std::endl; - if (pin_direction == OUT) - direction_file << "out" << std::endl; - else - direction_file << "in" << std::endl; - - std::string value_file_name; - - value_file_name = base_path.str() + "/value"; - - value_file.open(value_file_name.c_str(), std::ios_base::in | std::ios_base::out); - if (!value_file.is_open()) - std::cout << "Failed to open value file." << std::endl; -} - -bool gpio::get_value() -{ - - std::string val; - - std::getline(value_file, val); - value_file.seekg(0); - - if (val == "0") - return false; - else if (val == "1") - return true; - else - std::cout << "Data read from value file|" << val << "|" << std::endl; - - return false; -} - -void gpio::set_value(bool state) -{ - - if (state) - value_file << "1" << std::endl; - else - value_file << "0" << std::endl; -} - -static void prepare_fpga_for_configuration(gpio &prog, gpio &init) -{ - - prog.set_value(true); - prog.set_value(false); - prog.set_value(true); - -#if 0 - bool ready_to_program(false); - unsigned int count(0); - do { - ready_to_program = init.get_value(); - count++; - - sleep(1); - } while (count < 10 && !ready_to_program); - - if (count == 10) { - std::cout << "FPGA not ready for programming." << std::endl; - exit(-1); - } -#endif -} - -spidev::spidev(std::string fname) -{ - int ret; - int mode = 0; - int speed = 12000000; - int bits = 8; - - fd = open(fname.c_str(), O_RDWR); - - ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); - ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); - ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); -} - - -spidev::~spidev() -{ - close(fd); -} - -void spidev::send(char *buf, char *rbuf, unsigned int nbytes) -{ - int ret; - - struct spi_ioc_transfer tr; - tr.tx_buf = (unsigned long) buf; - tr.rx_buf = (unsigned long) rbuf; - tr.len = nbytes; - tr.delay_usecs = 0; - tr.speed_hz = 48000000; - tr.bits_per_word = 8; - - ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); - -} - -static void send_file_to_fpga(std::string &file_name, gpio &error, gpio &done) -{ - std::ifstream bitstream; - - std::cout << "File name - " << file_name.c_str() << std::endl; - - bitstream.open(file_name.c_str(), std::ios::binary); - if (!bitstream.is_open()) - std::cout << "File " << file_name << " not opened succesfully." << std::endl; - - spidev spi("/dev/spidev1.0"); - char buf[BUF_SIZE]; - char rbuf[BUF_SIZE]; - - do { - bitstream.read(buf, BUF_SIZE); - spi.send(buf, rbuf, bitstream.gcount()); - - if (error.get_value()) - std::cout << "INIT_B went high, error occured." << std::endl; - - if (!done.get_value()) - std::cout << "Configuration complete." << std::endl; - - } while (bitstream.gcount() == BUF_SIZE); -} - -int main(int argc, char *argv[]) -{ - - gpio gpio_prog_b(PROG_B, OUT); - gpio gpio_init_b(INIT_B, IN); - gpio gpio_done (DONE, IN); - - if (argc == 2) - bit_file = argv[1]; - - bool module_found(false); - std::ifstream mod_file("/proc/modules"); - while (!mod_file.eof()) { - std::string line; - getline(mod_file, line); - if (line.find("usrp_e") != std::string::npos) - module_found = true; - } - mod_file.close(); - - if (module_found) { - std::cout << "USRP Embedded kernel module loaded, not loading FPGA." << std::endl; - return -1; - } - - std::cout << "FPGA config file: " << bit_file << std::endl; - - prepare_fpga_for_configuration(gpio_prog_b, gpio_init_b); - - std::cout << "Done = " << gpio_done.get_value() << std::endl; - - send_file_to_fpga(bit_file, gpio_init_b, gpio_done); -} - diff --git a/host/usrp_e_utils/usrp-e-utility.cpp b/host/usrp_e_utils/usrp-e-utility.cpp new file mode 100644 index 000000000..139aabc30 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-utility.cpp @@ -0,0 +1,72 @@ +// +// Copyright 2011 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include + +#include "fpga_downloader.cpp" +#include "clkgen_config.hpp" + +namespace po = boost::program_options; + +static const std::string default_passthrough_path = "/usr/share/uhd/images/usrp_e1xx_passthrough.bin"; + +int UHD_SAFE_MAIN(int argc, char *argv[]){ + + //variables to be set by po + std::string fpga_path; + + //setup the program options + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "help message") + ("fpga", po::value(&fpga_path)->default_value(""), "loads the specified FPGA file") + ("reclk", "runs the clock recovery") + ; + 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 << boost::format("UHD USRP-E Utility %s") % desc << std::endl; + return ~0; + } + + bool loaded_fpga_image = false; + if (vm.count("fpga")){ + std::cout << "USRP-E Utility loading the FPGA..." << std::endl << std::endl; + usrp_e100_load_fpga(fpga_path); + loaded_fpga_image = true; + sleep(1); + } + + if (vm.count("reclk")){ + std::cout << "USRP-E Utility running the clock recovery..." << std::endl << std::endl; + //if an image was not loaded or specified, we load pass-through + if (fpga_path.empty()) fpga_path = default_passthrough_path; + if (not loaded_fpga_image) usrp_e100_load_fpga(fpga_path); + clock_genconfig_main(); + std::system("rm /tmp/usrp*hash"); //clear hash so driver must reload + } + + std::cout << "Done!" << std::endl; + + return 0; +} -- cgit v1.2.3 From 5b4d90582d827d7ba2483d7916b2f0400a5bd9fa Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 3 Feb 2011 11:20:37 -0800 Subject: usrp-e100: added passthrough to images makefile, tweaks to usrp-e-utility --- host/lib/usrp/usrp_e100/fpga_downloader.cpp | 2 +- host/usrp_e_utils/usrp-e-utility.cpp | 21 ++++++++++++--------- images/Makefile | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) (limited to 'host/usrp_e_utils') diff --git a/host/lib/usrp/usrp_e100/fpga_downloader.cpp b/host/lib/usrp/usrp_e100/fpga_downloader.cpp index 926e6fcaf..c0013fcbd 100644 --- a/host/lib/usrp/usrp_e100/fpga_downloader.cpp +++ b/host/lib/usrp/usrp_e100/fpga_downloader.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 diff --git a/host/usrp_e_utils/usrp-e-utility.cpp b/host/usrp_e_utils/usrp-e-utility.cpp index 139aabc30..4b4fc0178 100644 --- a/host/usrp_e_utils/usrp-e-utility.cpp +++ b/host/usrp_e_utils/usrp-e-utility.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "fpga_downloader.cpp" @@ -25,8 +26,6 @@ namespace po = boost::program_options; -static const std::string default_passthrough_path = "/usr/share/uhd/images/usrp_e1xx_passthrough.bin"; - int UHD_SAFE_MAIN(int argc, char *argv[]){ //variables to be set by po @@ -36,8 +35,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") - ("fpga", po::value(&fpga_path)->default_value(""), "loads the specified FPGA file") - ("reclk", "runs the clock recovery") + ("fpga", po::value(&fpga_path), "loads the specified FPGA file") + ("reclk", "runs the clock recovery") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -50,20 +49,24 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } bool loaded_fpga_image = false; - if (vm.count("fpga")){ + if (vm.count("fpga") != 0){ std::cout << "USRP-E Utility loading the FPGA..." << std::endl << std::endl; usrp_e100_load_fpga(fpga_path); loaded_fpga_image = true; sleep(1); } - if (vm.count("reclk")){ + if (vm.count("reclk") != 0){ std::cout << "USRP-E Utility running the clock recovery..." << std::endl << std::endl; //if an image was not loaded or specified, we load pass-through - if (fpga_path.empty()) fpga_path = default_passthrough_path; - if (not loaded_fpga_image) usrp_e100_load_fpga(fpga_path); + if (fpga_path.empty()) throw std::runtime_error( + "Please specify the path to the pass-though FPGA image for your device.\n" + " usrp-e-utility --reclk --fpga=/usr/share/uhd/images/usrp_e1xx_pt_fpga.bin" + ); clock_genconfig_main(); - std::system("rm /tmp/usrp*hash"); //clear hash so driver must reload + if (std::system("rm /tmp/usrp*hash") != 0){ //clear hash so driver must reload + std::cerr << "No hash to remove! Don't worry, its not a problem." << std::endl; + } } std::cout << "Done!" << std::endl; diff --git a/images/Makefile b/images/Makefile index 34c18cdc2..cfc783ee4 100644 --- a/images/Makefile +++ b/images/Makefile @@ -151,6 +151,22 @@ $(_usrp_e100_fpga_bin): $(GLOBAL_DEPS) endif +######################################################################## +# USRP-E100 pass-through fpga +######################################################################## +ifdef HAS_XTCLSH + +_usrp_e100_pt_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u1e_passthru +_usrp_e100_pt_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_e100_pt_fpga.bin +IMAGES_LIST += $(_usrp_e100_pt_fpga_bin) + +$(_usrp_e100_pt_fpga_bin): $(GLOBAL_DEPS) + cd $(_usrp_e100_pt_fpga_dir) && make clean + cd $(_usrp_e100_pt_fpga_dir) && make bin + cp $(_usrp_e100_pt_fpga_dir)/build/passthru.bin $@ + +endif + ######################################################################## # Build rules ######################################################################## -- cgit v1.2.3 From c8eed953d74186049ba94432334771724d1a8070 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 27 Jan 2011 00:40:18 +0000 Subject: usrp-e100: reverted clockgen config + tweaks, its working --- host/usrp_e_utils/clkgen_config.hpp | 213 +++++++++++++++++------------------ host/usrp_e_utils/usrp-e-utility.cpp | 2 +- 2 files changed, 105 insertions(+), 110 deletions(-) (limited to 'host/usrp_e_utils') diff --git a/host/usrp_e_utils/clkgen_config.hpp b/host/usrp_e_utils/clkgen_config.hpp index 0c9dc8de2..f39f8bb19 100644 --- a/host/usrp_e_utils/clkgen_config.hpp +++ b/host/usrp_e_utils/clkgen_config.hpp @@ -28,14 +28,98 @@ #include #include #include -#include "ad9522_regs.hpp" #include namespace usrp_e_clkgen_config_utility{ +// Programming data for clock gen chip +static const unsigned int config_data[] = { + 0x000024, + 0x023201, + 0x000081, + 0x000400, + 0x00104c, + 0x001101, + 0x001200, + 0x001300, + 0x001414, + 0x001500, + 0x001604, + 0x001704, + 0x001807, + 0x001900, + //0x001a00,//for debug + 0x001a32, + 0x001b12, + 0x001c44, + 0x001d00, + 0x001e00, + 0x00f062, + 0x00f162, + 0x00f262, + 0x00f362, + 0x00f462, + 0x00f562, + 0x00f662, + 0x00f762, + 0x00f862, + 0x00f962, + 0x00fa62, + 0x00fb62, + 0x00fc00, + 0x00fd00, + 0x019021, + 0x019100, + 0x019200, + 0x019321, + 0x019400, + 0x019500, + 0x019611, + 0x019700, + 0x019800, + 0x019900, + 0x019a00, + 0x019b00, + 0x01e003, + 0x01e102, + 0x023000, + 0x023201, + 0x0b0201, + 0x0b0300, + 0x001fff, + 0x0a0000, + 0x0a0100, + 0x0a0200, + 0x0a0302, + 0x0a0400, + 0x0a0504, + 0x0a060e, + 0x0a0700, + 0x0a0810, + 0x0a090e, + 0x0a0a00, + 0x0a0bf0, + 0x0a0c0b, + 0x0a0d01, + 0x0a0e90, + 0x0a0f01, + 0x0a1001, + 0x0a11e0, + 0x0a1201, + 0x0a1302, + 0x0a1430, + 0x0a1580, + 0x0a16ff, + 0x023201, + 0x0b0301, + 0x023201, +}; + + const unsigned int CLKGEN_SELECT = 145; + enum gpio_direction {IN, OUT}; class gpio { @@ -180,120 +264,31 @@ void spidev::send(char *buf, char *rbuf, unsigned int nbytes) tr.rx_buf = (unsigned long) rbuf; tr.len = nbytes; tr.delay_usecs = 0; - tr.speed_hz = 12000000; + tr.speed_hz = 12000; tr.bits_per_word = 24; - ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); + ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); } -static void spi_write_word(spidev spi, gpio &chip_select, const unsigned int addr, const unsigned char data) { - unsigned char out_data[3], in_data[3]; - unsigned char rw_w1_w0 = 0; //write one byte - out_data[0] = (rw_w1_w0 << 5) | (addr >> 8); - out_data[1] = addr & 0xff; - out_data[2] = data; - - chip_select.set_value(0); - spi.send((char *)out_data, (char *)in_data, 4); - chip_select.set_value(1); -} - -static void send_config_to_clkgen(gpio &chip_select) +static void send_config_to_clkgen(gpio &chip_select, const unsigned int data[], unsigned int data_size) { spidev spi("/dev/spidev1.0"); - - //do a soft reset - spi_write_word(spi, chip_select, 0x000, 1 << 5 | 1 << 2); - spi_write_word(spi, chip_select, 0x232, 0x1); - - // init some registers; - ad9522_regs_t ad9522_regs; - ad9522_regs.sdo_active = ad9522_regs_t::SDO_ACTIVE_SDO_SDIO; //use sdo and sdi - ad9522_regs.mirror = 1; //mirror sdo active - ad9522_regs.io_update = 1; //latch the registers - ad9522_regs.status_pin_control = 0x1; //n divider - ad9522_regs.ld_pin_control = 0x32; //show ref2 - ad9522_regs.refmon_pin_control = 0x12; //show ref2 - ad9522_regs.enb_stat_eeprom_at_stat_pin = 0; //use status pin as debug - - ad9522_regs.enable_ref2 = 0x1; - ad9522_regs.enable_ref1 = 0x0; - ad9522_regs.select_ref = ad9522_regs_t::SELECT_REF_REF2; - - ad9522_regs.set_r_counter(1); - ad9522_regs.a_counter = 0; - ad9522_regs.set_b_counter(20); - ad9522_regs.prescaler_p = ad9522_regs_t::PRESCALER_P_DIV8_9; - - ad9522_regs.pll_power_down = ad9522_regs_t::PLL_POWER_DOWN_NORMAL; //normal mode - ad9522_regs.cp_current = ad9522_regs_t::CP_CURRENT_1_2MA; - - ad9522_regs.vco_calibration_now = 1; //calibrate it! - ad9522_regs.vco_divider = ad9522_regs_t::VCO_DIVIDER_DIV5; - ad9522_regs.select_vco_or_clock = ad9522_regs_t::SELECT_VCO_OR_CLOCK_VCO; - - ad9522_regs.out0_format = ad9522_regs_t::OUT0_FORMAT_LVDS; - ad9522_regs.divider0_low_cycles = 2; //3 low - ad9522_regs.divider0_high_cycles = 1; //2 high - ad9522_regs.divider1_low_cycles = 2; //3 low - ad9522_regs.divider1_high_cycles = 1; //2 high - - ad9522_regs.enable_eeprom_write = 1; - - //write the registers - int reg_list[] = {0, 4, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 240, 241, 242, 243, - 244, 245, 246, 247, 248, 249, 250, 251, 252, - 253, 400, 401, 402, 403, 404, 405, 406, 407, - 408, 409, 410, 411, 480, 481, 560, 562, 2818, - 2819}; - - for(int i=0; i<49; i++) { //blame std::vector for this (no static initialization bs) - spi_write_word(spi, chip_select, reg_list[i], ad9522_regs.get_reg(reg_list[i])); - } - - sleep(1); - - if (1){//write settings to eeprom - - //load the register buffs - spi_write_word(spi, chip_select, 0xa00, 0x0); - spi_write_word(spi, chip_select, 0xa01, 0x0); - spi_write_word(spi, chip_select, 0xa02, 0x0); - spi_write_word(spi, chip_select, 0xa03, 0x2); - spi_write_word(spi, chip_select, 0xa04, 0x0); - spi_write_word(spi, chip_select, 0xa05, 0x4); - spi_write_word(spi, chip_select, 0xa06, 0xe); - spi_write_word(spi, chip_select, 0xa07, 0x0); - spi_write_word(spi, chip_select, 0xa08, 0x10); - spi_write_word(spi, chip_select, 0xa09, 0xe); - spi_write_word(spi, chip_select, 0xa0a, 0x0); - spi_write_word(spi, chip_select, 0xa0b, 0xf0); - spi_write_word(spi, chip_select, 0xa0c, 0xb); - spi_write_word(spi, chip_select, 0xa0d, 0x1); - spi_write_word(spi, chip_select, 0xa0e, 0x90); - spi_write_word(spi, chip_select, 0xa0f, 0x1); - spi_write_word(spi, chip_select, 0xa10, 0x1); - spi_write_word(spi, chip_select, 0xa11, 0xe0); - spi_write_word(spi, chip_select, 0xa12, 0x1); - spi_write_word(spi, chip_select, 0xa13, 0x2); - spi_write_word(spi, chip_select, 0xa14, 0x30); - spi_write_word(spi, chip_select, 0xa15, 0x80); - spi_write_word(spi, chip_select, 0xa16, 0xff); - - spi_write_word(spi, chip_select, 0x232, 0x01); //latch - sleep(1); - //////////////////////////////////////////////////////////////// - - ad9522_regs.reg2eeprom = 1; - //write to eeprom - spi_write_word(spi, chip_select, 0xB03, ad9522_regs.get_reg(0xB03)); - //io update - spi_write_word(spi, chip_select, 0x232, ad9522_regs.get_reg(0x232)); //latch - sleep(1); - } - + unsigned int rbuf; + + for (unsigned int i = 0; i < data_size; i++) { + + //std::cout << "sending " << std::hex << data[i] << std::endl; + chip_select.set_value(0); + spi.send((char *)&data[i], (char *)&rbuf, 4); + chip_select.set_value(1); + unsigned int addr = (data[i] >> 8) & 0xfff; + if (addr == 0x232 || addr == 0x000){ + std::cout << "." << std::flush; + sleep(1); + } + }; + std::cout << std::endl; } }//namespace usrp_e_clkgen_config_utility @@ -304,7 +299,7 @@ static void clock_genconfig_main(void) using namespace usrp_e_clkgen_config_utility; gpio clkgen_select(CLKGEN_SELECT, OUT, true); - send_config_to_clkgen(clkgen_select); + send_config_to_clkgen(clkgen_select, config_data, sizeof(config_data)/sizeof(config_data[0])); } #endif /*USRP_E_UTILS_CLKGEN_CONFIG_HPP*/ diff --git a/host/usrp_e_utils/usrp-e-utility.cpp b/host/usrp_e_utils/usrp-e-utility.cpp index 4b4fc0178..b926cf49d 100644 --- a/host/usrp_e_utils/usrp-e-utility.cpp +++ b/host/usrp_e_utils/usrp-e-utility.cpp @@ -57,7 +57,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } if (vm.count("reclk") != 0){ - std::cout << "USRP-E Utility running the clock recovery..." << std::endl << std::endl; + std::cout << "USRP-E Utility running the clock recovery..." << std::flush; //if an image was not loaded or specified, we load pass-through if (fpga_path.empty()) throw std::runtime_error( "Please specify the path to the pass-though FPGA image for your device.\n" -- cgit v1.2.3