diff options
-rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 11 | ||||
-rw-r--r-- | fpga/usrp2/top/Makefile.common | 2 | ||||
-rw-r--r-- | fpga/usrp2/top/u2_rev3/u2_core_udp.v | 7 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/fw_common.h | 6 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 24 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_regs.hpp | 1 | ||||
-rwxr-xr-x | host/utils/usrp2_card_burner.py | 40 | ||||
-rwxr-xr-x | host/utils/usrp2_card_burner_gui.py | 4 | ||||
-rw-r--r-- | images/.gitignore | 2 | ||||
-rw-r--r-- | images/CMakeLists.txt | 42 | ||||
-rw-r--r-- | images/Makefile | 86 | ||||
-rw-r--r-- | images/README | 20 |
13 files changed, 216 insertions, 31 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 092d216aa..f0a9702be 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -181,9 +181,9 @@ void handle_udp_ctrl_packet( uint32_t ctrl_data_in_id = ctrl_data_in->id; //ensure that the protocol versions match - if (payload_len >= sizeof(uint32_t) && ctrl_data_in->proto_ver != USRP2_PROTO_VERSION){ - printf("!Error in control packet handler: Expected protocol version %d, but got %d\n", - USRP2_PROTO_VERSION, ctrl_data_in->proto_ver + if (payload_len >= sizeof(uint32_t) && ctrl_data_in->proto_ver != USRP2_FW_COMPAT_NUM){ + printf("!Error in control packet handler: Expected compatibility number %d, but got %d\n", + USRP2_FW_COMPAT_NUM, ctrl_data_in->proto_ver ); ctrl_data_in_id = USRP2_CTRL_ID_WAZZUP_BRO; } @@ -198,7 +198,7 @@ void handle_udp_ctrl_packet( //setup the output data usrp2_ctrl_data_t ctrl_data_out = { - .proto_ver = USRP2_PROTO_VERSION, + .proto_ver = USRP2_FW_COMPAT_NUM, .id=USRP2_CTRL_ID_HUH_WHAT, .seq=ctrl_data_in->seq }; @@ -441,7 +441,8 @@ main(void) print_mac_addr(ethernet_mac_addr()->addr); newline(); print_ip_addr(get_ip_addr()); newline(); - printf("Control protocol version: %d\n", USRP2_PROTO_VERSION); + printf("FPGA compatibility number: %d\n", USRP2_FPGA_COMPAT_NUM); + printf("Firmware compatibility number: %d\n", USRP2_FW_COMPAT_NUM); ethernet_register_link_changed_callback(link_changed_callback); ethernet_init(); diff --git a/fpga/usrp2/top/Makefile.common b/fpga/usrp2/top/Makefile.common index d0435fa1e..4da64ac28 100644 --- a/fpga/usrp2/top/Makefile.common +++ b/fpga/usrp2/top/Makefile.common @@ -47,7 +47,7 @@ $(ISE_FILE): $$(SOURCES) $$(MAKEFILE_LIST) @echo $@ $(ISE_HELPER) "" -$(BIN_FILE): $(ISE_FILE) +$(BIN_FILE): $(ISE_FILE) $$(SOURCES) $$(MAKEFILE_LIST) @echo $@ $(ISE_HELPER) "Generate Programming File" touch $@ diff --git a/fpga/usrp2/top/u2_rev3/u2_core_udp.v b/fpga/usrp2/top/u2_rev3/u2_core_udp.v index b79cab5fb..124930c23 100644 --- a/fpga/usrp2/top/u2_rev3/u2_core_udp.v +++ b/fpga/usrp2/top/u2_rev3/u2_core_udp.v @@ -423,7 +423,10 @@ module u2_core cycle_count <= 0; else cycle_count <= cycle_count + 1; - + + //compatibility number -> increment when the fpga has been sufficiently altered + localparam compat_num = 32'd1; + wb_readback_mux buff_pool_status (.wb_clk_i(wb_clk), .wb_rst_i(wb_rst), .wb_stb_i(s5_stb), .wb_adr_i(s5_adr), .wb_dat_o(s5_dat_i), .wb_ack_o(s5_ack), @@ -431,7 +434,7 @@ module u2_core .word00(status_b0),.word01(status_b1),.word02(status_b2),.word03(status_b3), .word04(status_b4),.word05(status_b5),.word06(status_b6),.word07(status_b7), .word08(status),.word09({sim_mode,27'b0,clock_divider[3:0]}),.word10(vita_time[63:32]), - .word11(vita_time[31:0]),.word12(32'b0),.word13(irq),.word14(status_enc),.word15(cycle_count) + .word11(vita_time[31:0]),.word12(compat_num),.word13(irq),.word14(status_enc),.word15(cycle_count) ); // ///////////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h index c4dabf5bc..a781c1a21 100644 --- a/host/lib/usrp/usrp2/fw_common.h +++ b/host/lib/usrp/usrp2/fw_common.h @@ -32,9 +32,9 @@ extern "C" { #define __stdint(type) type #endif -//defines the protocol version in this shared header -//increment this value when the protocol is changed -#define USRP2_PROTO_VERSION 5 +//fpga and firmware compatibility numbers +#define USRP2_FPGA_COMPAT_NUM 1 +#define USRP2_FW_COMPAT_NUM 5 //used to differentiate control packets over data port #define USRP2_INVALID_VRT_HEADER 0 diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index a21157d76..4124221ef 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // +#include "usrp2_regs.hpp" #include "usrp2_iface.hpp" #include <uhd/utils/assert.hpp> #include <uhd/types/dict.hpp> @@ -22,6 +23,7 @@ #include <boost/foreach.hpp> #include <boost/asio.hpp> //used for htonl and ntohl #include <boost/assign/list_of.hpp> +#include <boost/format.hpp> #include <stdexcept> #include <algorithm> @@ -47,6 +49,15 @@ public: **********************************************************************/ usrp2_iface_impl(udp_simple::sptr ctrl_transport){ _ctrl_transport = ctrl_transport; + + //check the fpga compatibility number + const boost::uint32_t fpga_compat_num = this->peek32(U2_REG_COMPAT_NUM_RB); + if (fpga_compat_num != USRP2_FPGA_COMPAT_NUM){ + throw std::runtime_error(str(boost::format( + "Expected fpga compatibility number %d, but got %d:\n" + "The fpga build is not compatible with the host code build." + ) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num)); + } } ~usrp2_iface_impl(void){ @@ -168,7 +179,7 @@ public: //fill in the seq number and send usrp2_ctrl_data_t out_copy = out_data; - out_copy.proto_ver = htonl(USRP2_PROTO_VERSION); + out_copy.proto_ver = htonl(USRP2_FW_COMPAT_NUM); out_copy.seq = htonl(++_ctrl_seq_num); _ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t))); @@ -177,12 +188,11 @@ public: const usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<const usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem); while(true){ size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CONTROL_TIMEOUT_MS); - if(len >= sizeof(boost::uint32_t) and ntohl(ctrl_data_in->proto_ver) != USRP2_PROTO_VERSION){ - throw std::runtime_error(str( - boost::format("Expected protocol version %d, but got %d\n" - "The firmware build does not match the host code build." - ) % int(USRP2_PROTO_VERSION) % ntohl(ctrl_data_in->proto_ver) - )); + if(len >= sizeof(boost::uint32_t) and ntohl(ctrl_data_in->proto_ver) != USRP2_FW_COMPAT_NUM){ + throw std::runtime_error(str(boost::format( + "Expected protocol compatibility number %d, but got %d:\n" + "The firmware build is not compatible with the host code build." + ) % int(USRP2_FW_COMPAT_NUM) % ntohl(ctrl_data_in->proto_ver))); } if (len >= sizeof(usrp2_ctrl_data_t) and ntohl(ctrl_data_in->seq) == _ctrl_seq_num){ return *ctrl_data_in; diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 2c314c085..21f411afe 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -97,7 +97,7 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){ //send a hello control packet usrp2_ctrl_data_t ctrl_data_out; - ctrl_data_out.proto_ver = htonl(USRP2_PROTO_VERSION); + ctrl_data_out.proto_ver = htonl(USRP2_FW_COMPAT_NUM); ctrl_data_out.id = htonl(USRP2_CTRL_ID_WAZZUP_BRO); udp_transport->send(boost::asio::buffer(&ctrl_data_out, sizeof(ctrl_data_out))); diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp index cc9094ae7..9d306090b 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_regs.hpp @@ -107,6 +107,7 @@ #define U2_REG_TIME64_SECS_RB (0xCC00 + 4*10) #define U2_REG_TIME64_TICKS_RB (0xCC00 + 4*11) +#define U2_REG_COMPAT_NUM_RB (0xCC00 + 4*12) //pps flags (see above) #define U2_FLAG_TIME64_PPS_NEGEDGE (0 << 0) diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py index d47a4f5f4..1db5e59ce 100755 --- a/host/utils/usrp2_card_burner.py +++ b/host/utils/usrp2_card_burner.py @@ -21,6 +21,7 @@ import tempfile import subprocess import urllib import optparse +import math import os import re @@ -59,6 +60,14 @@ def get_dd_path(): return dd_path return 'dd' +def int_ceil_div(num, den): + return int(math.ceil(float(num)/float(den))) + +def get_tmp_file(): + tmp = tempfile.mkstemp() + os.close(tmp[0]) + return tmp[1] + ######################################################################## # list possible devices ######################################################################## @@ -136,10 +145,12 @@ def get_raw_device_hints(): # write and verify with dd ######################################################################## def verify_image(image_file, device_file, offset): - #create a temporary file to store the readback - tmp = tempfile.mkstemp() - os.close(tmp[0]) - tmp_file = tmp[1] + #create a temporary file to store the readback image + tmp_file = get_tmp_file() + + #read the image data + img_data = open(image_file, 'rb').read() + count = int_ceil_div(len(img_data), SECTOR_SIZE) #execute a dd subprocess verbose = command( @@ -148,24 +159,33 @@ def verify_image(image_file, device_file, offset): "if=%s"%device_file, "skip=%d"%(offset/SECTOR_SIZE), "bs=%d"%SECTOR_SIZE, - "count=%d"%(MAX_FILE_SIZE/SECTOR_SIZE), + "count=%d"%count, ) - #read in the image and readback - img_data = open(image_file, 'rb').read() - tmp_data = open(tmp_file, 'rb').read(len(img_data)) - #verfy the data + tmp_data = open(tmp_file, 'rb').read(len(img_data)) if img_data != tmp_data: return 'Verification Failed:\n%s'%verbose return 'Verification Passed:\n%s'%verbose def write_image(image_file, device_file, offset): + #create a temporary file to store the padded image + tmp_file = get_tmp_file() + + #write the padded image data + img_data = open(image_file, 'rb').read() + count = int_ceil_div(len(img_data), SECTOR_SIZE) + pad_len = SECTOR_SIZE*count - len(img_data) + pad_str = ''.join([chr(0)]*pad_len) #zero-padding + open(tmp_file, 'wb').write(img_data + pad_str) + + #execute a dd subprocess verbose = command( get_dd_path(), - "if=%s"%image_file, + "if=%s"%tmp_file, "of=%s"%device_file, "seek=%d"%(offset/SECTOR_SIZE), "bs=%d"%SECTOR_SIZE, + "count=%d"%count, ) try: #exec the sync command (only works on linux) diff --git a/host/utils/usrp2_card_burner_gui.py b/host/utils/usrp2_card_burner_gui.py index 61fbadbe3..58b7a514a 100755 --- a/host/utils/usrp2_card_burner_gui.py +++ b/host/utils/usrp2_card_burner_gui.py @@ -17,7 +17,7 @@ # import usrp2_card_burner #import implementation -import Tkinter, Tkconstants, tkFileDialog, tkFont, tkMessageBox +import Tkinter, tkFileDialog, tkFont, tkMessageBox import os class BinFileEntry(Tkinter.Frame): @@ -53,7 +53,7 @@ class BinFileEntry(Tkinter.Frame): class DeviceEntryWidget(Tkinter.Frame): """ - Simple entry widget for getting the raw device name. + Simple entry widget for getting the raw device name. Combines a label, entry, and helpful text box with hints. """ diff --git a/images/.gitignore b/images/.gitignore new file mode 100644 index 000000000..8947b7a83 --- /dev/null +++ b/images/.gitignore @@ -0,0 +1,2 @@ +/build +/images diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt new file mode 100644 index 000000000..75cb4c9d3 --- /dev/null +++ b/images/CMakeLists.txt @@ -0,0 +1,42 @@ +# +# 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 <http://www.gnu.org/licenses/>. +# + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(UHD-images NONE) + +######################################################################## +# Config Files (include order is important) +######################################################################## +INCLUDE(${CMAKE_SOURCE_DIR}/../host/config/Python.cmake) +INCLUDE(${CMAKE_SOURCE_DIR}/../host/config/Version.cmake) + +######################################################################## +# Setup CPack +######################################################################## +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ettus Research - Universal Hardware Driver Images") +SET(CPACK_PACKAGE_VENDOR "Ettus Research LLC") +SET(CPACK_PACKAGE_CONTACT "support@ettus.com") +SET(CPACK_PACKAGE_VERSION_MAJOR ${UHD_VERSION_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${UHD_VERSION_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${UHD_VERSION_PATCH}) +INCLUDE(CPack) #include after setting vars +MESSAGE(STATUS "Version: ${CPACK_PACKAGE_VERSION}") + +######################################################################## +# Install Images +######################################################################## +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/images DESTINATION share/uhd) diff --git a/images/Makefile b/images/Makefile new file mode 100644 index 000000000..6ab54e6ac --- /dev/null +++ b/images/Makefile @@ -0,0 +1,86 @@ +# +# 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 <http://www.gnu.org/licenses/>. +# + +all: + @echo "Pick a specific target" + +######################################################################## +# Common Variables +######################################################################## +TOP_DIR = $(shell pwd) +TOP_FW_DIR = $(TOP_DIR)/../firmware +TOP_FPGA_DIR = $(TOP_DIR)/../fpga +BUILT_IMAGES_DIR = $(TOP_DIR)/images +CMAKE_BUILD_DIR = $(TOP_DIR)/build + +##filled in below +IMAGES_LIST = + +######################################################################## +# USRP2 firmware +######################################################################## +_usrp2_fw_dir = $(TOP_FW_DIR)/microblaze +_usrp2_fw_bin = $(BUILT_IMAGES_DIR)/usrp2_fw.bin +IMAGES_LIST += $(_usrp2_fw_bin) + +$(_usrp2_fw_bin): + cd $(_usrp2_fw_dir) && ./bootstrap + cd $(_usrp2_fw_dir) && ./configure --host=mb + make -C $(_usrp2_fw_dir) clean + make -C $(_usrp2_fw_dir) all + cp $(_usrp2_fw_dir)/usrp2/usrp2_txrx_uhd.bin $@ + +######################################################################## +# USRP2 fpga +######################################################################## +_usrp2_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u2_rev3 +_usrp2_fpga_bin = $(BUILT_IMAGES_DIR)/usrp2_fpga.bin +IMAGES_LIST += $(_usrp2_fpga_bin) + +$(_usrp2_fpga_bin): + cd $(_usrp2_fpga_dir) && make -f Makefile.udp clean + cd $(_usrp2_fpga_dir) && make -f Makefile.udp bin + cp $(_usrp2_fpga_dir)/build-udp/u2_rev3.bin $@ + +######################################################################## +# Build rules +######################################################################## +##little rule to make the images directory +$(BUILT_IMAGES_DIR): + mkdir $@ + +images: $(BUILT_IMAGES_DIR) $(IMAGES_LIST) + +clean: + $(RM) -rf $(BUILT_IMAGES_DIR) + $(RM) -rf $(CMAKE_BUILD_DIR) + +#packages that a linux machine can build +linux-packages: + mkdir -p $(CMAKE_BUILD_DIR) + + cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=TGZ $(TOP_DIR) + make -C $(CMAKE_BUILD_DIR) package + + cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=ZIP $(TOP_DIR) + make -C $(CMAKE_BUILD_DIR) package + + cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=DEB $(TOP_DIR) + make -C $(CMAKE_BUILD_DIR) package + + cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=RPM $(TOP_DIR) + make -C $(CMAKE_BUILD_DIR) package diff --git a/images/README b/images/README new file mode 100644 index 000000000..ec8391826 --- /dev/null +++ b/images/README @@ -0,0 +1,20 @@ +The images directory contains the following: + - a Makefile for building firmware and fpga images + - a CMake file for building an images package + +The Makefile and build systems for the images are probably Unix specific. +Its best to build the images on a Unix system with standard build tools. +The CMake package target will create an images package for your system. + +To build the images (unix): + make clean + make images + +To build the package (unix): + mkdir build + cd build + cmake -DCPACK_GENERATOR=<type> ../ + make package + +The package generator types are described here: + http://www.cmake.org/Wiki/CMake:CPackPackageGenerators |