From c473cc56fafcb47d6ba1f16e8c9fb89ff6c57bca Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 5 Nov 2010 12:32:09 -0700 Subject: usrp1: pulled in cmake build system for usrp1 firmware --- firmware/fx2/usrp1/CMakeLists.txt | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 firmware/fx2/usrp1/CMakeLists.txt (limited to 'firmware/fx2/usrp1/CMakeLists.txt') diff --git a/firmware/fx2/usrp1/CMakeLists.txt b/firmware/fx2/usrp1/CMakeLists.txt new file mode 100644 index 000000000..3d99a2ac1 --- /dev/null +++ b/firmware/fx2/usrp1/CMakeLists.txt @@ -0,0 +1,84 @@ +# +# 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_directories(${CMAKE_SOURCE_DIR}/common) + +#for usrp_common.h and the regs files... +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +#now make a lib to link against +set(libusrp1_sources + ${CMAKE_SOURCE_DIR}/common/delay.c + ${CMAKE_SOURCE_DIR}/common/fx2utils.c + ${CMAKE_SOURCE_DIR}/common/i2c.c + ${CMAKE_SOURCE_DIR}/common/init_gpif.c + ${CMAKE_SOURCE_DIR}/common/isr.c + ${CMAKE_SOURCE_DIR}/common/timer.c + ${CMAKE_SOURCE_DIR}/common/usb_common.c +# ${CMAKE_SOURCE_DIR}/common/spi.c +# ${CMAKE_SOURCE_DIR}/common/vectors.a51 +) + +#file(GLOB libusrp1_c_sources ${CMAKE_SOURCE_DIR}/common/*.c) +#file(GLOB libusrp1_a51_sources ${CMAKE_SOURCE_DIR}/common/*.a51) +#list(APPEND libusrp1_sources ${libusrp1_c_sources} ${libusrp1_a51_sources}) + +add_library(libusrp1 STATIC ${libusrp1_sources}) + +# edit-gpif hacks up gpif.c for our purposes. no major surgery, just moving stuff around. +set(GPIF_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/gpif.c) +set(GPIF_SOURCE_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/usrp_gpif.c) +set(GPIF_HEADER_OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/usrp_gpif_inline.h) + +add_custom_command( + OUTPUT ${GPIF_SOURCE_OUTPUT} + DEPENDS ${EDIT_GPIF_USRP1} + COMMAND ${PYTHON_EXECUTABLE} ${EDIT_GPIF_USRP1} ${GPIF_SOURCE} ${GPIF_SOURCE_OUTPUT} ${GPIF_HEADER_OUTPUT} + COMMENT "Generating ${GPIF_SOURCE_OUTPUT}" +) + +#file(GLOB usrp1_sources *.c) +set(usrp1_sources + ${CMAKE_SOURCE_DIR}/common/vectors.a51 + board_specific.c + eeprom_io.c + fpga_load.c + fpga_rev2.c + usrp_common.c + usrp_gpif.c + usrp_main.c + usb_descriptors.a51 + ${CMAKE_SOURCE_DIR}/common/spi.c + ${CMAKE_SOURCE_DIR}/common/_startup.a51 +) +add_executable(usrp1_fw ${usrp1_sources}) +target_link_libraries(usrp1_fw libusrp1) + +set(eeprom1_sources + ${CMAKE_SOURCE_DIR}/common/eeprom_boot.a51 + ${CMAKE_SOURCE_DIR}/common/eeprom_init.c + ${CMAKE_SOURCE_DIR}/common/_startup.a51 +) + +add_custom_target(usrp1_eeprom ALL + DEPENDS usrp1_boot + COMMAND objcopy -I ihex -O binary usrp1_boot.ihx usrp1_boot.bin + COMMAND ${PYTHON_EXECUTABLE} ${BUILD_EEPROM} -r2 usrp1_boot.bin usrp1_eeprom.bin +) + +add_executable(usrp1_boot ${eeprom1_sources}) +target_link_libraries(usrp1_boot libusrp1) -- cgit v1.2.3 From 94a492dc40a6450ada3fe34a7440c31077d9690e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 5 Nov 2010 17:39:18 -0700 Subject: uhd: rename identifier for usrp1 eeprom, and fix offsets, add serial support to usrp2 --- firmware/fx2/usrp1/CMakeLists.txt | 2 +- host/include/uhd/usrp/mboard_eeprom.hpp | 2 +- host/lib/usrp/mboard_eeprom.cpp | 30 +++++++++-------- host/lib/usrp/usrp1/mboard_impl.cpp | 2 +- host/lib/usrp/usrp1/usrp1_iface.cpp | 2 +- host/lib/usrp/usrp2/usrp2_impl.cpp | 57 +++++++++++++++++---------------- 6 files changed, 50 insertions(+), 45 deletions(-) (limited to 'firmware/fx2/usrp1/CMakeLists.txt') diff --git a/firmware/fx2/usrp1/CMakeLists.txt b/firmware/fx2/usrp1/CMakeLists.txt index 3d99a2ac1..6607bc7f2 100644 --- a/firmware/fx2/usrp1/CMakeLists.txt +++ b/firmware/fx2/usrp1/CMakeLists.txt @@ -77,7 +77,7 @@ set(eeprom1_sources add_custom_target(usrp1_eeprom ALL DEPENDS usrp1_boot COMMAND objcopy -I ihex -O binary usrp1_boot.ihx usrp1_boot.bin - COMMAND ${PYTHON_EXECUTABLE} ${BUILD_EEPROM} -r2 usrp1_boot.bin usrp1_eeprom.bin + COMMAND ${PYTHON_EXECUTABLE} ${BUILD_EEPROM} -r1 usrp1_boot.bin usrp1_eeprom.bin ) add_executable(usrp1_boot ${eeprom1_sources}) diff --git a/host/include/uhd/usrp/mboard_eeprom.hpp b/host/include/uhd/usrp/mboard_eeprom.hpp index bc3f1f8c9..f44275aad 100644 --- a/host/include/uhd/usrp/mboard_eeprom.hpp +++ b/host/include/uhd/usrp/mboard_eeprom.hpp @@ -37,7 +37,7 @@ namespace uhd{ namespace usrp{ //! Possible EEPROM maps types enum map_type{ MAP_NXXX, - MAP_BXXX + MAP_B1XX }; //! Make a new empty mboard eeprom diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 81dc6f194..49d429674 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -94,6 +94,9 @@ static void load_nxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ mb_eeprom["name"] = bytes_to_string(iface.read_eeprom( NXXX_EEPROM_ADDR, USRP_NXXX_OFFSETS["name"], NAME_MAX_LEN )); + + //empty serial correction: use the mac address + if (mb_eeprom["serial"].empty()) mb_eeprom["serial"] = mb_eeprom["mac-addr"]; } static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ @@ -129,37 +132,38 @@ static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ } /*********************************************************************** - * Implementation of BXXX load/store + * Implementation of B1XX load/store **********************************************************************/ -static const boost::uint8_t BXXX_EEPROM_ADDR = 0x50; +static const boost::uint8_t B1XX_EEPROM_ADDR = 0x50; +static const size_t B1XXX_SERIAL_LEN = 8; -static const uhd::dict USRP_BXXX_OFFSETS = boost::assign::map_list_of +static const uhd::dict USRP_B1XX_OFFSETS = boost::assign::map_list_of ("serial", 0xf8) - ("name", 0xf8 + SERIAL_LEN) + ("name", 0xf8 - NAME_MAX_LEN) ; -static void load_bxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ +static void load_b1xx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //extract the serial mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom( - BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["serial"], SERIAL_LEN + B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["serial"], B1XXX_SERIAL_LEN )); //extract the name mb_eeprom["name"] = bytes_to_string(iface.read_eeprom( - BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["name"], NAME_MAX_LEN + B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["name"], NAME_MAX_LEN )); } -static void store_bxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ +static void store_b1xx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ //store the serial iface.write_eeprom( - BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["serial"], - string_to_bytes(mb_eeprom["serial"], SERIAL_LEN) + B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["serial"], + string_to_bytes(mb_eeprom["serial"], B1XXX_SERIAL_LEN) ); //store the name iface.write_eeprom( - BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["name"], + B1XX_EEPROM_ADDR, USRP_B1XX_OFFSETS["name"], string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN) ); } @@ -174,13 +178,13 @@ mboard_eeprom_t::mboard_eeprom_t(void){ mboard_eeprom_t::mboard_eeprom_t(i2c_iface &iface, map_type map){ switch(map){ case MAP_NXXX: load_nxxx(*this, iface); break; - case MAP_BXXX: load_bxxx(*this, iface); break; + case MAP_B1XX: load_b1xx(*this, iface); break; } } void mboard_eeprom_t::commit(i2c_iface &iface, map_type map){ switch(map){ case MAP_NXXX: store_nxxx(*this, iface); break; - case MAP_BXXX: store_bxxx(*this, iface); break; + case MAP_B1XX: store_b1xx(*this, iface); break; } } diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp index 86f78a7a9..952da8dce 100644 --- a/host/lib/usrp/usrp1/mboard_impl.cpp +++ b/host/lib/usrp/usrp1/mboard_impl.cpp @@ -379,7 +379,7 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val) case MBOARD_PROP_EEPROM_MAP: _iface->mb_eeprom = val.as(); - _iface->mb_eeprom.commit(*_iface, mboard_eeprom_t::MAP_BXXX); + _iface->mb_eeprom.commit(*_iface, mboard_eeprom_t::MAP_B1XX); return; default: UHD_THROW_PROP_SET_ERROR(); diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index dcba3e819..691c51fe8 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -38,7 +38,7 @@ public: usrp1_iface_impl(usrp_ctrl::sptr ctrl_transport) { _ctrl_transport = ctrl_transport; - mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_BXXX); + mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_B1XX); } ~usrp1_iface_impl(void) diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 6625cf3e7..5f549c4fd 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -102,36 +102,37 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){ while(true){ size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem), DISCOVERY_TIMEOUT_MS); //std::cout << len << "\n"; - if (len > offsetof(usrp2_ctrl_data_t, data)){ - //handle the received data - switch(ntohl(ctrl_data_in->id)){ - case USRP2_CTRL_ID_WAZZUP_DUDE: - //make a boost asio ipv4 with the raw addr in host byte order - boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr)); - device_addr_t new_addr; - new_addr["type"] = "usrp2"; - new_addr["addr"] = ip_addr.to_string(); - //Attempt to read the name from the EEPROM and perform filtering. - //This operation can throw due to COMPAT mismatch. That is OK. - //We will allow the device to be found and the COMPAT mismatch - //will be thrown as an exception in the factory function. - try{ - new_addr["name"] = usrp2_iface::make(udp_simple::make_connected( - new_addr["addr"], num2str(USRP2_UDP_CTRL_PORT)) - )->mb_eeprom["name"]; - if (not hint.has_key("name") or hint["name"] == new_addr["name"]){ - usrp2_addrs.push_back(new_addr); - } + if (len > offsetof(usrp2_ctrl_data_t, data) and ntohl(ctrl_data_in->id) == USRP2_CTRL_ID_WAZZUP_DUDE){ + //make a boost asio ipv4 with the raw addr in host byte order + boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in->data.ip_addr)); + device_addr_t new_addr; + new_addr["type"] = "usrp2"; + new_addr["addr"] = ip_addr.to_string(); + //Attempt to read the name from the EEPROM and perform filtering. + //This operation can throw due to COMPAT mismatch. That is OK. + //We will allow the device to be found and the COMPAT mismatch + //will be thrown as an exception in the factory function. + try{ + mboard_eeprom_t mb_eeprom = usrp2_iface::make( + udp_simple::make_connected(new_addr["addr"], num2str(USRP2_UDP_CTRL_PORT)) + )->mb_eeprom; + new_addr["name"] = mb_eeprom["name"]; + new_addr["serial"] = mb_eeprom["serial"]; + if ( + (not hint.has_key("name") or hint["name"] == new_addr["name"]) and + (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]) + ){ + usrp2_addrs.push_back(new_addr); } - catch(const std::exception &e){ - uhd::warning::post( - std::string("Ignoring discovered device\n") - + e.what() - ); - } - //dont break here, it will exit the while loop - //just continue on to the next loop iteration } + catch(const std::exception &e){ + uhd::warning::post( + std::string("Ignoring discovered device\n") + + e.what() + ); + } + //dont break here, it will exit the while loop + //just continue on to the next loop iteration } if (len == 0) break; //timeout } -- cgit v1.2.3