diff --git a/binaries/rt_cpu.bin b/binaries/rt_cpu.bin
index c537067f0db3c0c6a425a4ee88a1841942bbc33f..0a0e1faa3c9c89034fe1044a086c0921a46ac3e8 100755
Binary files a/binaries/rt_cpu.bin and b/binaries/rt_cpu.bin differ
diff --git a/kernel/wbgen-regs/endpoint-regs.h b/kernel/wbgen-regs/endpoint-regs.h
index c41b65825643a5f8ea7e1d412cb2304b6dbb834d..fc00a34ae8cc15117a97722df95aabc85fd2dd06 100644
--- a/kernel/wbgen-regs/endpoint-regs.h
+++ b/kernel/wbgen-regs/endpoint-regs.h
@@ -78,6 +78,13 @@
 /* definitions for field: Timestamping counter synchronization done in reg: Timestamping Control Register */
 #define EP_TSCR_CS_DONE                       WBGEN2_GEN_MASK(3, 1)
 
+/* definitions for field: Start calibration of RX timestamper in reg: Timestamping Control Register */
+#define EP_TSCR_RX_CAL_START                  WBGEN2_GEN_MASK(4, 1)
+
+/* definitions for field: RX timestamper calibration result flag in reg: Timestamping Control Register */
+#define EP_TSCR_RX_CAL_RESULT                 WBGEN2_GEN_MASK(5, 1)
+
+
 /* definitions for register: RX Deframer Control Register */
 
 /* definitions for field: RX accept runts in reg: RX Deframer Control Register */
diff --git a/rt/dev/ad9516.c b/rt/dev/ad9516.c
index a7d17db5d286c9fa4b0205a4ba19aa6d9d17934e..9cf0b20e31c4e88879a445dedd06e3da8984319f 100644
--- a/rt/dev/ad9516.c
+++ b/rt/dev/ad9516.c
@@ -14,6 +14,8 @@
 
 #include "ad9516.h"
 
+#include "rt_ipc.h"
+
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 #endif
@@ -244,3 +246,22 @@ int ad9516_init(int ref_source)
 	return 0;
 }
 
+
+int rts_debug_command(int command, int value)
+{
+	switch(command)
+	{
+		case RTS_DEBUG_ENABLE_SERDES_CLOCKS:
+			if(value)
+			{
+				ad9516_write_reg(0xf4, 0x08); // OUT4 enabled
+				ad9516_write_reg(0x232, 0x0);
+				ad9516_write_reg(0x232, 0x1);
+			} else {
+				ad9516_write_reg(0xf4, 0x0a); // OUT4 power-down, no serdes clock
+				ad9516_write_reg(0x232, 0x0);
+				ad9516_write_reg(0x232, 0x1);
+			}
+			break;
+	}
+}
\ No newline at end of file
diff --git a/rt/dev/ad9516_regs.h b/rt/dev/ad9516_regs.h
index e44974c2f4bceb985dc2e01a8605ddce9179b464..1f48ae0e1fa5f9c6156db92b72c20b934415fab6 100644
--- a/rt/dev/ad9516_regs.h
+++ b/rt/dev/ad9516_regs.h
@@ -16,7 +16,7 @@ const struct {int reg; uint8_t val} ad9516_regs[] = {
 {0x0019, 0x00},
 {0x001A, 0x00},
 {0x001B, 0x00},
-{0x001C, 0x02},
+{0x001C, 0x46}, 
 {0x001D, 0x00},
 {0x001E, 0x00},
 {0x001F, 0x0E},
diff --git a/rt/ipc/rt_ipc.c b/rt/ipc/rt_ipc.c
index d1265e625891bea0e3ac33288e68d45e1c5c0d1e..db3723b8f5dd53a9d97b884837097a51551c1737 100644
--- a/rt/ipc/rt_ipc.c
+++ b/rt/ipc/rt_ipc.c
@@ -33,6 +33,7 @@ static void clear_state()
     pstate.flags = 0;
     pstate.current_ref = 0;
     pstate.mode = RTS_MODE_DISABLED;
+    pstate.ipc_count = 0;
 }
 
 /* Sets the phase setpoint on a given channel */
@@ -152,12 +153,17 @@ static int rts_get_state_func(const struct minipc_pd *pd, uint32_t *args, void *
 
 //    TRACE("IPC Call: %s [rv at %x]\n", __FUNCTION__, ret);
 
+		pstate.ipc_count++;
+
     /* gaaaah, somebody should write a SWIG plugin for generating this stuff. */
     tmp->current_ref = htonl(pstate.current_ref);
     tmp->flags = htonl(pstate.flags);
     tmp->holdover_duration = htonl(pstate.holdover_duration);
     tmp->mode = htonl(pstate.mode);
 		tmp->delock_count = spll_get_delock_count();
+		tmp->ipc_count = pstate.ipc_count;
+		
+		softpll_copy_debug_data(&tmp->debug_data[0]);
 		
     for(i=0; i<RTS_PLL_CHANNELS;i++)
     {
@@ -173,25 +179,35 @@ static int rts_get_state_func(const struct minipc_pd *pd, uint32_t *args, void *
 
 static int rts_set_mode_func(const struct minipc_pd *pd, uint32_t *args, void *ret)
 {
+		pstate.ipc_count++;
     *(int *) ret = rts_set_mode(args[0]);
 }
 
 
 static int rts_lock_channel_func(const struct minipc_pd *pd, uint32_t *args, void *ret)
 {
+		pstate.ipc_count++;
     *(int *) ret = rts_lock_channel(args[0], (int)args[1]);
 }
 
 static int rts_adjust_phase_func(const struct minipc_pd *pd, uint32_t *args, void *ret)
 {
+		pstate.ipc_count++;
     *(int *) ret = rts_adjust_phase((int)args[0], (int)args[1]);
 }
 
 static int rts_enable_ptracker_func(const struct minipc_pd *pd, uint32_t *args, void *ret)
 {
+		pstate.ipc_count++;
     *(int *) ret = spll_enable_ptracker((int)args[0], (int)args[1]);
 }
 
+static int rts_debug_command_func(const struct minipc_pd *pd, uint32_t *args, void *ret)
+{
+		pstate.ipc_count++;
+    *(int *) ret = rts_debug_command((int)args[0], (int)args[1]);
+}
+
 
 
 /* The mailbox is mapped at 0x7000 in the linker script */
@@ -210,12 +226,14 @@ int rtipc_init()
 	rtipc_rts_lock_channel_struct.f = rts_lock_channel_func;
 	rtipc_rts_adjust_phase_struct.f = rts_adjust_phase_func;
 	rtipc_rts_enable_ptracker_struct.f = rts_enable_ptracker_func;
+	rtipc_rts_debug_command_struct.f = rts_debug_command_func;
 	
 	minipc_export(server, &rtipc_rts_set_mode_struct);
 	minipc_export(server, &rtipc_rts_get_state_struct);
 	minipc_export(server, &rtipc_rts_lock_channel_struct);
   minipc_export(server, &rtipc_rts_adjust_phase_struct);
   minipc_export(server, &rtipc_rts_enable_ptracker_struct);
+  minipc_export(server, &rtipc_rts_debug_command_struct);
 
 
 	return 0;
diff --git a/rt/ipc/rt_ipc.h b/rt/ipc/rt_ipc.h
index bec8768abad08fa023cf2f691462e228cba7d083..0b2910d00e77e4ac6151f5ed6fbd2e1e8d02a40f 100644
--- a/rt/ipc/rt_ipc.h
+++ b/rt/ipc/rt_ipc.h
@@ -57,6 +57,10 @@
 /* null reference input */
 #define REF_NONE 255
 
+/* RT Subsystem debug commands, handled via rts_debug_command() */
+
+/* Serdes reference clock enable/disable */
+#define RTS_DEBUG_ENABLE_SERDES_CLOCKS 1
 
 struct rts_pll_state {
 
@@ -87,10 +91,17 @@ struct rts_pll_state {
 	uint32_t mode;
 
 	uint32_t delock_count;
+
+	uint32_t ipc_count;
+	
+	uint32_t debug_data[8];
 };
 
 /* API */
 
+/* Connects to the RT CPU */
+int rts_connect();
+
 /* Queries the RT CPU PLL state */
 int rts_get_state(struct rts_pll_state *state);
 
@@ -106,6 +117,9 @@ int rts_lock_channel(int channel, int priority);
 /* Enabled/disables phase tracking on a particular port */
 int rts_enable_ptracker(int channel, int enable);
 
+/* Enabled/disables phase tracking on a particular port */
+int rts_debug_command(int param, int value);
+
 #ifdef RTIPC_EXPORT_STRUCTURES
 
 static struct minipc_pd rtipc_rts_get_state_struct = {
@@ -155,6 +169,16 @@ static struct minipc_pd rtipc_rts_enable_ptracker_struct = {
 	},
 };
 
+static struct minipc_pd rtipc_rts_debug_command_struct = {
+	.name = "ffff",
+	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
+	.args = {
+	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
+	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
+	    MINIPC_ARG_END
+	},
+};
+
 #endif
 
 #endif
diff --git a/rt/main.c b/rt/main.c
index 27684de85b1a1a7585dc4c858d3cf236c6973c40..bf61f448eef61abbd947ae974fe383589da1e53a 100644
--- a/rt/main.c
+++ b/rt/main.c
@@ -15,8 +15,8 @@ main()
 
 	uart_init();
 	
-	TRACE("WR Switch Real Time Subsystem (c) CERN 2011-2012\n");
-	TRACE("Revision: %s, built at %s.\n", build_revision, build_date);
+	TRACE("WR Switch Real Time Subsystem (c) CERN 2011 - 2013\n");
+	TRACE("Revision: %s, built %s.\n", build_revision, build_date);
 	TRACE("--");
 
 	ad9516_init();
@@ -27,8 +27,9 @@ main()
 	{
 			uint32_t tics = timer_get_tics();
 			
-			if(tics - start_tics > TICS_PER_SECOND)
+			if(tics - start_tics > TICS_PER_SECOND/5)
 			{
+//				TRACE("tick!\n");
 				spll_show_stats();
 				start_tics = tics;
 			}
diff --git a/userspace/mini-rpc b/userspace/mini-rpc
index 4c87062d8b19b39ba408369929fc28cc044d62cf..4094ddc352a86799f7ca04149ab554a8c63a2659 160000
--- a/userspace/mini-rpc
+++ b/userspace/mini-rpc
@@ -1 +1 @@
-Subproject commit 4c87062d8b19b39ba408369929fc28cc044d62cf
+Subproject commit 4094ddc352a86799f7ca04149ab554a8c63a2659
diff --git a/userspace/ptp-noposix b/userspace/ptp-noposix
index ef04daa548b29950dac29b1b34ac172ce4c9d3da..b426591a40158a0f039e02716ff8f9aa95973271 160000
--- a/userspace/ptp-noposix
+++ b/userspace/ptp-noposix
@@ -1 +1 @@
-Subproject commit ef04daa548b29950dac29b1b34ac172ce4c9d3da
+Subproject commit b426591a40158a0f039e02716ff8f9aa95973271
diff --git a/userspace/tools/Makefile b/userspace/tools/Makefile
index 996a56f4391bcf5630ba1e390c2847c78c3ce087..dfccc929de8812b070f38a507bc7029a4b4cc7c5 100644
--- a/userspace/tools/Makefile
+++ b/userspace/tools/Makefile
@@ -1,5 +1,5 @@
 TOOLS = rtu_stat wr_mon wr_phytool spll_dbg_proxy load-lm32 load-virtex com
-TOOLS += mapper wmapper shw_ver wr_date
+TOOLS += mapper wmapper shw_ver
 
 # # Standard stanza for cross-compilation (courtesy of the linux makefile)
 
@@ -31,7 +31,7 @@ CFLAGS =  -O2 -DDEBUG -g -Wall \
 LDFLAGS = -L../mini-rpc \
 		-L../libptpnetif \
 		-L../libswitchhw \
-		-lminipc -lptpnetif -lswitchhw
+		-lminipc -lptpnetif -lswitchhw -llua -lm -ldl
 
 all: 	$(TOOLS)
 
@@ -59,6 +59,15 @@ shw_ver.o: shw_ver.c
 shw_ver: shw_ver.o
 	${CC} -o $@ $^ $(LDFLAGS)	
 
+test_rt: test_rt.o ../wrsw_hal/rt_client.o
+	${CC} -o $@ $^ $(LDFLAGS)	
+
+test_ts: test_ts.o ../wrsw_hal/rt_client.o
+	${CC} -o $@ $^ $(LDFLAGS)	
+
+port_calibrator: port_calibrator.o ../wrsw_hal/rt_client.o
+	${CC} -o $@ $^ $(LDFLAGS)	
+
 clean:
 	rm -f $(TOOLS) *.o *~
 
diff --git a/userspace/tools/wr_phytool.c b/userspace/tools/wr_phytool.c
index 6b12ee29a3205f5dec97b592d9a5b22b4b236226..8d26da3d45b840d10acc1373090f61a18390d2cc 100644
--- a/userspace/tools/wr_phytool.c
+++ b/userspace/tools/wr_phytool.c
@@ -516,6 +516,8 @@ int main(int argc, char **argv)
 	if (fpga_map(argv[0]) < 0)
 		exit(1);
 
+	shw_init();
+
 	if(argc<3)
 	{
 
diff --git a/userspace/wrsw_hal/rt_client.c b/userspace/wrsw_hal/rt_client.c
index 6383696fe18d682f02b206246c78c6623a7e9257..ccfe7b57a6ba24b567f6dcd1dfa8ec8a2c148b15 100644
--- a/userspace/wrsw_hal/rt_client.c
+++ b/userspace/wrsw_hal/rt_client.c
@@ -111,6 +111,17 @@ int rts_enable_ptracker(int channel, int enable)
     return rval;
 }
 
+int rts_debug_command(int command, int value)
+{
+    int rval;
+		int ret = minipc_call(client, RTS_TIMEOUT, &rtipc_rts_debug_command_struct, &rval, command, value);
+
+    if(ret < 0)
+        return ret;
+
+    return rval;
+}
+
 
 int rts_connect()
 {
diff --git a/userspace/wrsw_hal/rt_ipc.h b/userspace/wrsw_hal/rt_ipc.h
deleted file mode 100644
index 83c628feca44de2793140c33abee311d2d95a3ff..0000000000000000000000000000000000000000
--- a/userspace/wrsw_hal/rt_ipc.h
+++ /dev/null
@@ -1,163 +0,0 @@
-#ifndef __RT_IPC_H
-#define __RT_IPC_H
-
-#include <stdint.h>
-
-#define RTS_PLL_CHANNELS 18
-
-/* Individual channel flags */
-/* Reference input frequency valid */
-#define CHAN_REF_VALID (1<<0)
-/* Frequency out of range */
-#define CHAN_FREQ_OUT_OF_RANGE (1<<1)
-/* Phase is drifting too fast */
-#define CHAN_DRIFTING (1<<2)
-/* Channel phase measurement is ready */
-#define CHAN_PMEAS_READY (1<<3)
-/* Channel not available/disabled */
-#define CHAN_DISABLED (1<<4)
-/* Channel is busy adjusting phase */
-#define CHAN_SHIFTING (1<<5)
-/* Channel is busy adjusting phase */
-#define CHAN_PTRACKER_ENABLED (1<<6)
-
-/* DMTD clock is present */
-#define RTS_DMTD_LOCKED (1<<0)
-
-/* 125 MHz reference locked */
-#define RTS_REF_LOCKED (1<<1)
-
-/* External 10 MHz reference present */
-#define RTS_EXT_10M_VALID (1<<2)
-
-/* External 1-PPS present */
-#define RTS_EXT_PPS_VALID (1<<3)
-
-/* External 10 MHz frequency out-of-range */
-#define RTS_EXT_10M_OUT_OF_RANGE (1<<4)
-
-/* External 1-PPS frequency out-of-range */
-#define RTS_EXT_PPS_OUT_OF_RANGE (1<<5)
-
-/* Holdover mode active */
-#define RTS_HOLDOVER_ACTIVE (1<<6)
-
-/* Grandmaster mode active (uses 10 MHz / 1-PPS reference) */
-#define RTS_MODE_GM_EXTERNAL 1
-
-/* Free-running grandmaster (uses local TCXO) */
-#define RTS_MODE_GM_FREERUNNING 2
-
-/* Boundary clock mode active (uses network reference) */
-#define RTS_MODE_BC 3
-
-/* PLL disabled */
-#define RTS_MODE_DISABLED 4
-
-/* null reference input */
-#define REF_NONE 255
-
-
-struct rts_pll_state {
-
-/* State of an individual input channel (i.e. switch port) */
-	struct channel {
-		/* Switchover priority: 0 = highest, 1 - 254 = high..low, 255 = channel disabled (a master port) */
-		uint32_t priority;
-		/* channel phase setpoint in picoseconds. Used only when channel is a slave. */
-		int32_t phase_setpoint;
-		/* current phase shift in picoseconds. Used only when channel is a slave. */
-		int32_t phase_current;
-		/* TX-RX Loopback phase measurement in picoseconds. */
-		int32_t phase_loopback;
-		/* flags (per channel - see CHAN_xxx defines) */
-		uint32_t flags;
-	} channels[RTS_PLL_CHANNELS];
-
-	/* flags (global - RTS_xxx defines) */
-	uint32_t flags;
-
-	/* duration of current holdover period in 10us units */
-	int32_t holdover_duration;
-
-	/* current reference source - or REF_NONE if free-running or grandmaster */
-	uint32_t current_ref;
-
-	/* mode of operation (RTS_MODE_xxx) */
-	uint32_t mode;
-
-	uint32_t delock_count;
-};
-
-/* API */
-
-/* Connects to the RT CPU */
-int rts_connect();
-
-/* Queries the RT CPU PLL state */
-int rts_get_state(struct rts_pll_state *state);
-
-/* Sets the phase setpoint on a given channel */
-int rts_adjust_phase(int channel, int32_t phase_setpoint);
-
-/* Sets the RT subsystem mode (Boundary Clock or Grandmaster) */
-int rts_set_mode(int mode);
-
-/* Reference channel configuration (BC mode only) */
-int rts_lock_channel(int channel, int priority);
-
-/* Enabled/disables phase tracking on a particular port */
-int rts_enable_ptracker(int channel, int enable);
-
-#ifdef RTIPC_EXPORT_STRUCTURES
-
-static struct minipc_pd rtipc_rts_get_state_struct = {
-	.name = "aaaa",
-	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_STRUCT, struct rts_pll_state),
-	.args = {
-		MINIPC_ARG_END
-	},
-};
-
-static struct minipc_pd rtipc_rts_set_mode_struct = {
-	.name = "bbbb",
-	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
-	.args = {
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_END
-	},
-};
-
-static struct minipc_pd rtipc_rts_lock_channel_struct = {
-	.name = "cccc",
-	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
-	.args = {
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_END
-	},
-};
-
-static struct minipc_pd rtipc_rts_adjust_phase_struct = {
-	.name = "dddd",
-	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
-	.args = {
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_END
-	},
-};
-
-static struct minipc_pd rtipc_rts_enable_ptracker_struct = {
-	.name = "eeee",
-	.retval = MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int),
-	.args = {
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_ENCODE(MINIPC_ATYPE_INT, int ),
-	    MINIPC_ARG_END
-	},
-};
-
-#endif
-
-#endif
diff --git a/userspace/wrsw_hal/rt_ipc.h b/userspace/wrsw_hal/rt_ipc.h
new file mode 120000
index 0000000000000000000000000000000000000000..377053b260893676d534067c84ed1c1fe7fecb51
--- /dev/null
+++ b/userspace/wrsw_hal/rt_ipc.h
@@ -0,0 +1 @@
+../../rt/ipc/rt_ipc.h
\ No newline at end of file