From 0adbbd8ede0ccc119ae35c32b5689934d33776de Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 8 Mar 2018 15:41:05 +0800 Subject: [PATCH] drtio: reset aux packet gateware after locking to recovered clock Closes #949 --- artiq/firmware/libdrtioaux/lib.rs | 11 +++++++++++ artiq/firmware/satman/main.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/artiq/firmware/libdrtioaux/lib.rs b/artiq/firmware/libdrtioaux/lib.rs index bb4aa6dcc..e818ab22e 100644 --- a/artiq/firmware/libdrtioaux/lib.rs +++ b/artiq/firmware/libdrtioaux/lib.rs @@ -269,6 +269,17 @@ pub mod hw { use super::*; use std::io::Cursor; + pub fn reset(linkno: u8) { + let linkno = linkno as usize; + unsafe { + // clear buffer first to limit race window with buffer overflow + // error. We assume the CPU is fast enough so that no two packets + // will be received between the buffer and the error flag are cleared. + (board::csr::DRTIO[linkno].aux_rx_present_write)(1); + (board::csr::DRTIO[linkno].aux_rx_error_write)(1); + } + } + fn rx_has_error(linkno: u8) -> bool { let linkno = linkno as usize; unsafe { diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index c00c5b484..19ab75bcc 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -237,6 +237,7 @@ fn startup() { info!("link is up, switching to recovered clock"); si5324::siphaser::select_recovered_clock(true).expect("failed to switch clocks"); si5324::siphaser::calibrate_skew(32).expect("failed to calibrate skew"); + drtioaux::hw::reset(0); drtio_reset(false); drtio_reset_phy(false); while drtio_link_rx_up() {