From 4cb73f32aa9800cad2d44599b5535c3551beeda2 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 24 Apr 2020 12:55:59 +0800 Subject: [PATCH] use logging --- runtime/src/comms.rs | 6 +++--- runtime/src/kernel.rs | 8 ++++---- runtime/src/main.rs | 6 +++--- runtime/src/rtio.rs | 35 +++++++++++++++++------------------ 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/runtime/src/comms.rs b/runtime/src/comms.rs index a8d6137..8a4034a 100644 --- a/runtime/src/comms.rs +++ b/runtime/src/comms.rs @@ -3,12 +3,12 @@ use core::fmt; use core::cmp::min; use core::cell::RefCell; use alloc::rc::Rc; +use log::{warn, error}; use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive}; use libboard_zynq::{ - println, self as zynq, smoltcp::{ self, @@ -185,7 +185,7 @@ async fn handle_connection(stream: &TcpStream, control: Rc { - println!("received unexpected message from core1: {:?}", reply); + error!("received unexpected message from core1: {:?}", reply); write_header(&stream, Reply::LoadFailed).await?; write_chunk(&stream, b"core1 sent unexpected reply").await?; } @@ -250,7 +250,7 @@ pub fn main() { task::spawn(async { let _ = handle_connection(&stream, control) .await - .map_err(|e| println!("Connection: {}", e)); + .map_err(|e| warn!("Connection: {}", e)); let _ = stream.flush().await; let _ = stream.abort().await; }); diff --git a/runtime/src/kernel.rs b/runtime/src/kernel.rs index 23686cc..7006d49 100644 --- a/runtime/src/kernel.rs +++ b/runtime/src/kernel.rs @@ -1,7 +1,7 @@ +use log::{debug, error}; use alloc::{vec, vec::Vec, sync::Arc}; use libcortex_a9::{mutex::Mutex, sync_channel::{self, sync_channel}}; -use libboard_zynq::println; use libsupport_zynq::boot::Core1; use dyld; @@ -93,7 +93,7 @@ fn resolve(required: &[u8]) -> Option { #[no_mangle] pub fn main_core1() { - println!("Core1 started"); + debug!("Core1 started"); let mut core1_tx = None; while core1_tx.is_none() { @@ -116,12 +116,12 @@ pub fn main_core1() { core1_tx.send(Message::LoadCompleted) }, Err(error) => { - println!("failed to load shared library: {}", error); + error!("failed to load shared library: {}", error); core1_tx.send(Message::LoadFailed) } } }, - _ => println!("Core1 received unexpected message: {:?}", message), + _ => error!("Core1 received unexpected message: {:?}", message), } } } diff --git a/runtime/src/main.rs b/runtime/src/main.rs index 835c326..d7a7fdf 100644 --- a/runtime/src/main.rs +++ b/runtime/src/main.rs @@ -5,9 +5,9 @@ extern crate alloc; extern crate log; use core::{cmp, str}; +use log::info; use libboard_zynq::{ - println, self as zynq, clocks::Clocks, clocks::source::{ClockSource, ArmPll, IoPll}, }; use libsupport_zynq::{logger, ram}; @@ -33,9 +33,9 @@ fn identifier_read(buf: &mut [u8]) -> &str { #[no_mangle] pub fn main_core0() { - println!("ARTIQ runtime starting..."); let _ = logger::init(); log::set_max_level(log::LevelFilter::Debug); + info!("NAR3 starting..."); const CPU_FREQ: u32 = 800_000_000; @@ -46,7 +46,7 @@ pub fn main_core0() { let mut ddr = zynq::ddr::DdrRam::new(); ram::init_alloc(&mut ddr); - println!("Detected gateware: {}", identifier_read(&mut [0; 64])); + info!("Detected gateware: {}", identifier_read(&mut [0; 64])); comms::main(); } diff --git a/runtime/src/rtio.rs b/runtime/src/rtio.rs index f9d2e85..7b1c0ab 100644 --- a/runtime/src/rtio.rs +++ b/runtime/src/rtio.rs @@ -1,7 +1,6 @@ use core::ptr::{read_volatile, write_volatile}; use cslice::CSlice; - -use libboard_zynq::println; +use log::error; use crate::pl::csr; @@ -56,12 +55,12 @@ unsafe fn process_exceptional_status(channel: i32, status: u8) { while csr::rtio::o_status_read() & RTIO_O_STATUS_WAIT != 0 {} } if status & RTIO_O_STATUS_UNDERFLOW != 0 { - println!("RTIO underflow at {0} mu, channel {1}, slack {2} mu", - timestamp, channel as i64, timestamp - get_counter()); + error!("RTIO underflow at {0} mu, channel {1}, slack {2} mu", + timestamp, channel as i64, timestamp - get_counter()); } if status & RTIO_O_STATUS_DESTINATION_UNREACHABLE != 0 { - println!("RTIO destination unreachable, output, at {0} mu, channel {1}", - timestamp, channel as i64); + error!("RTIO destination unreachable, output, at {0} mu, channel {1}", + timestamp, channel as i64); } } @@ -103,15 +102,15 @@ pub extern fn input_timestamp(timeout: i64, channel: i32) -> i64 { if status & RTIO_I_STATUS_OVERFLOW != 0 { csr::rtio::i_overflow_reset_write(1); - println!("RTIO input overflow on channel {0}", - channel as i64); + error!("RTIO input overflow on channel {0}", + channel as i64); } if status & RTIO_I_STATUS_WAIT_EVENT != 0 { return -1 } if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 { - println!("RTIO destination unreachable, input, on channel {0}", - channel as i64); + error!("RTIO destination unreachable, input, on channel {0}", + channel as i64); } csr::rtio::i_timestamp_read() as i64 @@ -130,12 +129,12 @@ pub extern fn input_data(channel: i32) -> i32 { if status & RTIO_I_STATUS_OVERFLOW != 0 { csr::rtio::i_overflow_reset_write(1); - println!("RTIO input overflow on channel {0}", - channel as i64); + error!("RTIO input overflow on channel {0}", + channel as i64); } if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 { - println!("RTIO destination unreachable, input, on channel {0}", - channel as i64); + error!("RTIO destination unreachable, input, on channel {0}", + channel as i64); } rtio_i_data_read(0) as i32 @@ -154,15 +153,15 @@ pub extern fn input_timestamped_data(timeout: i64, channel: i32) -> TimestampedD if status & RTIO_I_STATUS_OVERFLOW != 0 { csr::rtio::i_overflow_reset_write(1); - println!("RTIO input overflow on channel {0}", - channel as i64); + error!("RTIO input overflow on channel {0}", + channel as i64); } if status & RTIO_I_STATUS_WAIT_EVENT != 0 { return TimestampedData { timestamp: -1, data: 0 } } if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 { - println!("RTIO destination unreachable, input, on channel {0}", - channel as i64); + error!("RTIO destination unreachable, input, on channel {0}", + channel as i64); } TimestampedData {