aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/usrp3
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usrp3')
-rw-r--r--firmware/usrp3/lib/CMakeLists.txt1
-rw-r--r--firmware/usrp3/n230/CMakeLists.txt7
-rw-r--r--firmware/usrp3/n230/n230_eth_handlers.c2
-rw-r--r--firmware/usrp3/n230/n230_fw_comm_protocol.c (renamed from firmware/usrp3/lib/fw_comm_protocol.c)2
-rwxr-xr-xfirmware/usrp3/x300/x300_aurora_bist.py40
5 files changed, 24 insertions, 28 deletions
diff --git a/firmware/usrp3/lib/CMakeLists.txt b/firmware/usrp3/lib/CMakeLists.txt
index 9d9ee3c6c..cd1a82c3f 100644
--- a/firmware/usrp3/lib/CMakeLists.txt
+++ b/firmware/usrp3/lib/CMakeLists.txt
@@ -30,7 +30,6 @@ add_library(usrp3fw STATIC
print_addrs.c
link_state_route_proto.c
cron.c
- fw_comm_protocol.c
flash/spi_flash.c
flash/spif_spsn_s25flxx.c
)
diff --git a/firmware/usrp3/n230/CMakeLists.txt b/firmware/usrp3/n230/CMakeLists.txt
index 6247477f0..5787fbb7d 100644
--- a/firmware/usrp3/n230/CMakeLists.txt
+++ b/firmware/usrp3/n230/CMakeLists.txt
@@ -19,7 +19,12 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/../../host/lib/usrp/n230)
-list(APPEND n230_sources n230_eeprom.c n230_eth_handlers.c n230_init.c n230_main.c)
+list(APPEND n230_sources
+ n230_eeprom.c
+ n230_fw_comm_protocol.c
+ n230_eth_handlers.c
+ n230_init.c
+ n230_main.c)
########################################################################
set(GEN_OUTPUTS_BIN_SIZE 0x7fff)
diff --git a/firmware/usrp3/n230/n230_eth_handlers.c b/firmware/usrp3/n230/n230_eth_handlers.c
index b291bb39f..f5c319681 100644
--- a/firmware/usrp3/n230/n230_eth_handlers.c
+++ b/firmware/usrp3/n230/n230_eth_handlers.c
@@ -22,7 +22,7 @@
#include <u3_net_stack.h>
#include <print_addrs.h>
#include <trace.h>
-#include "../../../host/lib/usrp/common/fw_comm_protocol.h"
+#include "../../../host/lib/usrp/n230/n230_fw_comm_protocol.h"
#include "../../../host/lib/usrp/n230/n230_fw_defs.h"
#include "../n230/n230_fw_host_iface.h"
#include "../../../host/lib/usrp/n230/n230_eeprom.h"
diff --git a/firmware/usrp3/lib/fw_comm_protocol.c b/firmware/usrp3/n230/n230_fw_comm_protocol.c
index 0cc931a76..d6f6dff5a 100644
--- a/firmware/usrp3/lib/fw_comm_protocol.c
+++ b/firmware/usrp3/n230/n230_fw_comm_protocol.c
@@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
-#include "../../../host/lib/usrp/common/fw_comm_protocol.h"
+#include "../../../host/lib/usrp/n230/n230_fw_comm_protocol.h"
#include <trace.h>
#include <string.h> //memcmp
diff --git a/firmware/usrp3/x300/x300_aurora_bist.py b/firmware/usrp3/x300/x300_aurora_bist.py
index f5e119b66..5f7a22a3b 100755
--- a/firmware/usrp3/x300/x300_aurora_bist.py
+++ b/firmware/usrp3/x300/x300_aurora_bist.py
@@ -43,8 +43,9 @@ SFP_TYPE_AURORA = 2
MAC_REG_CTRL = 0
MAC_REG_STATUS = 0
MAC_REG_OVERRUNS = 4
-MAC_REG_BIST_SAMPS = 8
-MAC_REG_BIST_ERRORS = 12
+MAC_REG_CHECKSUM_ERRS = 8
+MAC_REG_BIST_SAMPS = 12
+MAC_REG_BIST_ERRORS = 16
MAC_STATUS_LINK_UP_MSK = 0x00000001
MAC_STATUS_HARD_ERR_MSK = 0x00000002
@@ -52,19 +53,16 @@ MAC_STATUS_SOFT_ERR_MSK = 0x00000004
MAC_STATUS_BIST_LOCKED_MSK = 0x00000008
MAC_STATUS_BIST_LATENCY_MSK = 0x000FFFF0
MAC_STATUS_BIST_LATENCY_OFFSET = 4
-MAC_STATUS_CHECKSUM_ERRS_MSK = 0xFFF00000
-MAC_STATUS_CHECKSUM_ERRS_OFFSET = 20
MAC_CTRL_BIST_CHECKER_EN = 0x00000001
MAC_CTRL_BIST_GEN_EN = 0x00000002
MAC_CTRL_BIST_LOOPBACK_EN = 0x00000004
-MAC_CTRL_PHY_RESET = 0x00000100
-MAC_CTRL_BIST_RATE_MSK = 0x000000F8
+MAC_CTRL_PHY_RESET = 0x00000200
+MAC_CTRL_BIST_RATE_MSK = 0x000001F8
MAC_CTRL_BIST_RATE_OFFSET = 3
-AURORA_CLK_RATE = 156.25e6
BUS_CLK_RATE = 166.66e6
-BIST_MAX_TIME_LIMIT = math.floor(pow(2,48)/AURORA_CLK_RATE)-1
+BIST_MAX_TIME_LIMIT = math.floor(pow(2,48)/BUS_CLK_RATE)-1
########################################################################
# utils
@@ -83,10 +81,11 @@ def get_aurora_info(ctrl):
return (aur_port, link_up)
def get_rate_setting(rate):
- for div in range(2,32):
- if (rate < 8e-6 * BUS_CLK_RATE * (1.0 - 1.0/div)):
- return (div-1, 8e-6 * BUS_CLK_RATE * (1.0 - 1.0/(div-1)))
- return (0, 8e-6 * BUS_CLK_RATE)
+ RATE_RES_BITS = 6
+ rate_sett = int((1.0*rate/(8e-6*BUS_CLK_RATE))*pow(2, RATE_RES_BITS))-1 # Round rate down
+ rate_sett = numpy.clip(rate_sett, 0, pow(2, RATE_RES_BITS)-1)
+ coerced_rate = ((1.0+rate_sett)/pow(2, RATE_RES_BITS))*(8e-6*BUS_CLK_RATE)
+ return (rate_sett, coerced_rate)
def run_ber_loopback_bist(ctrls, duration, rate_tuple):
(rate_sett, rate) = rate_tuple
@@ -107,10 +106,7 @@ def run_ber_loopback_bist(ctrls, duration, rate_tuple):
# Put the slave in loopback mode and the master in BIST mode
if 'slave' in ctrls:
ctrls['slave'].poke(SLA_MAC_REG_BASE + MAC_REG_CTRL, MAC_CTRL_BIST_LOOPBACK_EN)
- if rate_sett == 0:
- master_ctrl = MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
- else:
- master_ctrl = ((rate_sett - 1) << MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
+ master_ctrl = (rate_sett<<MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
ctrls['master'].poke(MST_MAC_REG_BASE + MAC_REG_CTRL, master_ctrl)
start_time = datetime.datetime.now()
# Wait and check if BIST locked
@@ -153,7 +149,7 @@ def run_ber_loopback_bist(ctrls, duration, rate_tuple):
print('[INFO] BIST Complete!')
print('- Elapsed Time = ' + str(time_diff))
print('- Max BER (Bit Error Ratio) = %.4g (%d errors out of %d)'%((mst_errors+1)/mst_samps,mst_errors,mst_samps))
- print('- Max Roundtrip Latency = %.1fus'%(1e6*mst_latency_cyc/AURORA_CLK_RATE))
+ print('- Max Roundtrip Latency = %.1fus'%(1e6*mst_latency_cyc/BUS_CLK_RATE))
print('- Approx Throughput = %.0fMB/s'%((8e-6*mst_samps)/time_diff.total_seconds()))
else:
print('[ERROR] BIST Failed!')
@@ -187,10 +183,7 @@ def run_latency_loopback_bist(ctrls, duration, rate_tuple):
# Put the slave in loopback mode and the master in BIST mode
if 'slave' in ctrls:
ctrls['slave'].poke(SLA_MAC_REG_BASE + MAC_REG_CTRL, MAC_CTRL_BIST_LOOPBACK_EN)
- if rate_sett == 0:
- master_ctrl = MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
- else:
- master_ctrl = ((rate_sett - 1) << MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
+ master_ctrl = (rate_sett<<MAC_CTRL_BIST_RATE_OFFSET)|MAC_CTRL_BIST_GEN_EN|MAC_CTRL_BIST_CHECKER_EN
start_time = datetime.datetime.now()
latencies = []
@@ -216,7 +209,7 @@ def run_latency_loopback_bist(ctrls, duration, rate_tuple):
ctrls['master'].poke(MST_MAC_REG_BASE + MAC_REG_CTRL, 0)
# Compure latency
mst_latency_cyc = 16.0*((mst_status & MAC_STATUS_BIST_LATENCY_MSK) >> MAC_STATUS_BIST_LATENCY_OFFSET)
- mst_latency_us = 1e6*mst_latency_cyc/AURORA_CLK_RATE
+ mst_latency_us = 1e6*mst_latency_cyc/BUS_CLK_RATE
latencies.append(mst_latency_us)
except KeyboardInterrupt:
print('[WARNING] Operation cancelled by user.')
@@ -233,7 +226,7 @@ def run_latency_loopback_bist(ctrls, duration, rate_tuple):
print('- Elapsed Time = ' + str(stop_time - start_time))
print('- Roundtrip Latency Mean = %.2fus'%(numpy.mean(latencies)))
print('- Roundtrip Latency Stdev = %.2fus'%(numpy.std(latencies)))
- # Turn off BIST loopback
+ # Turn off BIST loopback
time.sleep(0.5)
if 'slave' in ctrls:
ctrls['slave'].poke(SLA_MAC_REG_BASE + MAC_REG_CTRL, 0)
@@ -304,4 +297,3 @@ if __name__=='__main__':
run_ber_loopback_bist(ctrls, options.duration, get_rate_setting(options.rate))
else:
run_latency_loopback_bist(ctrls, options.duration, get_rate_setting(options.rate))
-