From 161a4145673845e67a39ed6cb6b337d1df1e8f55 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 4 Jan 2018 22:23:59 +0800 Subject: [PATCH] serwb: debug print on error --- artiq/firmware/libboard_artiq/serwb.rs | 45 +++++++++++++++----------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/artiq/firmware/libboard_artiq/serwb.rs b/artiq/firmware/libboard_artiq/serwb.rs index 69b9f9676..c31fa8eeb 100644 --- a/artiq/firmware/libboard_artiq/serwb.rs +++ b/artiq/firmware/libboard_artiq/serwb.rs @@ -1,11 +1,36 @@ use board::csr; +unsafe fn debug_print(rtm: bool) { + debug!("AMC serwb settings:"); + debug!(" delay_min_found: {}", csr::serwb_phy_amc::control_delay_min_found_read()); + debug!(" delay_min: {}", csr::serwb_phy_amc::control_delay_min_read()); + debug!(" delay_max_found: {}", csr::serwb_phy_amc::control_delay_max_found_read()); + debug!(" delay_max: {}", csr::serwb_phy_amc::control_delay_max_read()); + debug!(" delay: {}", csr::serwb_phy_amc::control_delay_read()); + debug!(" bitslip: {}", csr::serwb_phy_amc::control_bitslip_read()); + debug!(" ready: {}", csr::serwb_phy_amc::control_ready_read()); + debug!(" error: {}", csr::serwb_phy_amc::control_error_read()); + + if rtm { + debug!("RTM serwb settings:"); + debug!(" delay_min_found: {}", csr::serwb_phy_rtm::control_delay_min_found_read()); + debug!(" delay_min: {}", csr::serwb_phy_rtm::control_delay_min_read()); + debug!(" delay_max_found: {}", csr::serwb_phy_rtm::control_delay_max_found_read()); + debug!(" delay_max: {}", csr::serwb_phy_rtm::control_delay_max_read()); + debug!(" delay: {}", csr::serwb_phy_rtm::control_delay_read()); + debug!(" bitslip: {}", csr::serwb_phy_rtm::control_bitslip_read()); + debug!(" ready: {}", csr::serwb_phy_rtm::control_ready_read()); + debug!(" error: {}", csr::serwb_phy_rtm::control_error_read()); + } +} + pub fn wait_init() { info!("waiting for AMC/RTM serwb bridge to be ready..."); unsafe { csr::serwb_phy_amc::control_reset_write(1); while csr::serwb_phy_amc::control_ready_read() == 0 { if csr::serwb_phy_amc::control_error_read() == 1 { + debug_print(false); warn!("AMC/RTM serwb bridge initialization failed, retrying."); csr::serwb_phy_amc::control_reset_write(1); } @@ -23,24 +48,6 @@ pub fn wait_init() { } unsafe { - debug!("AMC serwb settings:"); - debug!(" delay_min_found: {}", csr::serwb_phy_amc::control_delay_min_found_read()); - debug!(" delay_min: {}", csr::serwb_phy_amc::control_delay_min_read()); - debug!(" delay_max_found: {}", csr::serwb_phy_amc::control_delay_max_found_read()); - debug!(" delay_max: {}", csr::serwb_phy_amc::control_delay_max_read()); - debug!(" delay: {}", csr::serwb_phy_amc::control_delay_read()); - debug!(" bitslip: {}", csr::serwb_phy_amc::control_bitslip_read()); - debug!(" ready: {}", csr::serwb_phy_amc::control_ready_read()); - debug!(" error: {}", csr::serwb_phy_amc::control_error_read()); - - debug!("RTM serwb settings:"); - debug!(" delay_min_found: {}", csr::serwb_phy_rtm::control_delay_min_found_read()); - debug!(" delay_min: {}", csr::serwb_phy_rtm::control_delay_min_read()); - debug!(" delay_max_found: {}", csr::serwb_phy_rtm::control_delay_max_found_read()); - debug!(" delay_max: {}", csr::serwb_phy_rtm::control_delay_max_read()); - debug!(" delay: {}", csr::serwb_phy_rtm::control_delay_read()); - debug!(" bitslip: {}", csr::serwb_phy_rtm::control_bitslip_read()); - debug!(" ready: {}", csr::serwb_phy_rtm::control_ready_read()); - debug!(" error: {}", csr::serwb_phy_rtm::control_error_read()); + debug_print(true); } }