use logging

This commit is contained in:
Sebastien Bourdeauducq 2020-04-24 12:55:59 +08:00
parent 79846504bd
commit 4cb73f32aa
4 changed files with 27 additions and 28 deletions

View File

@ -3,12 +3,12 @@ use core::fmt;
use core::cmp::min; use core::cmp::min;
use core::cell::RefCell; use core::cell::RefCell;
use alloc::rc::Rc; use alloc::rc::Rc;
use log::{warn, error};
use num_derive::{FromPrimitive, ToPrimitive}; use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive}; use num_traits::{FromPrimitive, ToPrimitive};
use libboard_zynq::{ use libboard_zynq::{
println,
self as zynq, self as zynq,
smoltcp::{ smoltcp::{
self, self,
@ -185,7 +185,7 @@ async fn handle_connection(stream: &TcpStream, control: Rc<RefCell<kernel::Contr
write_chunk(&stream, b"core1 failed to process data").await?; write_chunk(&stream, b"core1 failed to process data").await?;
}, },
_ => { _ => {
println!("received unexpected message from core1: {:?}", reply); error!("received unexpected message from core1: {:?}", reply);
write_header(&stream, Reply::LoadFailed).await?; write_header(&stream, Reply::LoadFailed).await?;
write_chunk(&stream, b"core1 sent unexpected reply").await?; write_chunk(&stream, b"core1 sent unexpected reply").await?;
} }
@ -250,7 +250,7 @@ pub fn main() {
task::spawn(async { task::spawn(async {
let _ = handle_connection(&stream, control) let _ = handle_connection(&stream, control)
.await .await
.map_err(|e| println!("Connection: {}", e)); .map_err(|e| warn!("Connection: {}", e));
let _ = stream.flush().await; let _ = stream.flush().await;
let _ = stream.abort().await; let _ = stream.abort().await;
}); });

View File

@ -1,7 +1,7 @@
use log::{debug, error};
use alloc::{vec, vec::Vec, sync::Arc}; use alloc::{vec, vec::Vec, sync::Arc};
use libcortex_a9::{mutex::Mutex, sync_channel::{self, sync_channel}}; use libcortex_a9::{mutex::Mutex, sync_channel::{self, sync_channel}};
use libboard_zynq::println;
use libsupport_zynq::boot::Core1; use libsupport_zynq::boot::Core1;
use dyld; use dyld;
@ -93,7 +93,7 @@ fn resolve(required: &[u8]) -> Option<u32> {
#[no_mangle] #[no_mangle]
pub fn main_core1() { pub fn main_core1() {
println!("Core1 started"); debug!("Core1 started");
let mut core1_tx = None; let mut core1_tx = None;
while core1_tx.is_none() { while core1_tx.is_none() {
@ -116,12 +116,12 @@ pub fn main_core1() {
core1_tx.send(Message::LoadCompleted) core1_tx.send(Message::LoadCompleted)
}, },
Err(error) => { Err(error) => {
println!("failed to load shared library: {}", error); error!("failed to load shared library: {}", error);
core1_tx.send(Message::LoadFailed) core1_tx.send(Message::LoadFailed)
} }
} }
}, },
_ => println!("Core1 received unexpected message: {:?}", message), _ => error!("Core1 received unexpected message: {:?}", message),
} }
} }
} }

View File

@ -5,9 +5,9 @@ extern crate alloc;
extern crate log; extern crate log;
use core::{cmp, str}; use core::{cmp, str};
use log::info;
use libboard_zynq::{ use libboard_zynq::{
println,
self as zynq, clocks::Clocks, clocks::source::{ClockSource, ArmPll, IoPll}, self as zynq, clocks::Clocks, clocks::source::{ClockSource, ArmPll, IoPll},
}; };
use libsupport_zynq::{logger, ram}; use libsupport_zynq::{logger, ram};
@ -33,9 +33,9 @@ fn identifier_read(buf: &mut [u8]) -> &str {
#[no_mangle] #[no_mangle]
pub fn main_core0() { pub fn main_core0() {
println!("ARTIQ runtime starting...");
let _ = logger::init(); let _ = logger::init();
log::set_max_level(log::LevelFilter::Debug); log::set_max_level(log::LevelFilter::Debug);
info!("NAR3 starting...");
const CPU_FREQ: u32 = 800_000_000; const CPU_FREQ: u32 = 800_000_000;
@ -46,7 +46,7 @@ pub fn main_core0() {
let mut ddr = zynq::ddr::DdrRam::new(); let mut ddr = zynq::ddr::DdrRam::new();
ram::init_alloc(&mut ddr); ram::init_alloc(&mut ddr);
println!("Detected gateware: {}", identifier_read(&mut [0; 64])); info!("Detected gateware: {}", identifier_read(&mut [0; 64]));
comms::main(); comms::main();
} }

View File

@ -1,7 +1,6 @@
use core::ptr::{read_volatile, write_volatile}; use core::ptr::{read_volatile, write_volatile};
use cslice::CSlice; use cslice::CSlice;
use log::error;
use libboard_zynq::println;
use crate::pl::csr; 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 {} while csr::rtio::o_status_read() & RTIO_O_STATUS_WAIT != 0 {}
} }
if status & RTIO_O_STATUS_UNDERFLOW != 0 { if status & RTIO_O_STATUS_UNDERFLOW != 0 {
println!("RTIO underflow at {0} mu, channel {1}, slack {2} mu", error!("RTIO underflow at {0} mu, channel {1}, slack {2} mu",
timestamp, channel as i64, timestamp - get_counter()); timestamp, channel as i64, timestamp - get_counter());
} }
if status & RTIO_O_STATUS_DESTINATION_UNREACHABLE != 0 { if status & RTIO_O_STATUS_DESTINATION_UNREACHABLE != 0 {
println!("RTIO destination unreachable, output, at {0} mu, channel {1}", error!("RTIO destination unreachable, output, at {0} mu, channel {1}",
timestamp, channel as i64); 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 { if status & RTIO_I_STATUS_OVERFLOW != 0 {
csr::rtio::i_overflow_reset_write(1); csr::rtio::i_overflow_reset_write(1);
println!("RTIO input overflow on channel {0}", error!("RTIO input overflow on channel {0}",
channel as i64); channel as i64);
} }
if status & RTIO_I_STATUS_WAIT_EVENT != 0 { if status & RTIO_I_STATUS_WAIT_EVENT != 0 {
return -1 return -1
} }
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 { if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
println!("RTIO destination unreachable, input, on channel {0}", error!("RTIO destination unreachable, input, on channel {0}",
channel as i64); channel as i64);
} }
csr::rtio::i_timestamp_read() 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 { if status & RTIO_I_STATUS_OVERFLOW != 0 {
csr::rtio::i_overflow_reset_write(1); csr::rtio::i_overflow_reset_write(1);
println!("RTIO input overflow on channel {0}", error!("RTIO input overflow on channel {0}",
channel as i64); channel as i64);
} }
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 { if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
println!("RTIO destination unreachable, input, on channel {0}", error!("RTIO destination unreachable, input, on channel {0}",
channel as i64); channel as i64);
} }
rtio_i_data_read(0) as i32 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 { if status & RTIO_I_STATUS_OVERFLOW != 0 {
csr::rtio::i_overflow_reset_write(1); csr::rtio::i_overflow_reset_write(1);
println!("RTIO input overflow on channel {0}", error!("RTIO input overflow on channel {0}",
channel as i64); channel as i64);
} }
if status & RTIO_I_STATUS_WAIT_EVENT != 0 { if status & RTIO_I_STATUS_WAIT_EVENT != 0 {
return TimestampedData { timestamp: -1, data: 0 } return TimestampedData { timestamp: -1, data: 0 }
} }
if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 { if status & RTIO_I_STATUS_DESTINATION_UNREACHABLE != 0 {
println!("RTIO destination unreachable, input, on channel {0}", error!("RTIO destination unreachable, input, on channel {0}",
channel as i64); channel as i64);
} }
TimestampedData { TimestampedData {