From 7921b0216f2fbcbb70925b4c0d5b8223579c42ef Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 4 Aug 2021 22:40:53 +0800 Subject: [PATCH] try to improve system stability in debug modes --- services/llio/src/main.rs | 21 ++++++++++++++++++--- services/root-keys/src/implementation.rs | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/services/llio/src/main.rs b/services/llio/src/main.rs index 2b64f4724..1d94f844c 100644 --- a/services/llio/src/main.rs +++ b/services/llio/src/main.rs @@ -272,9 +272,24 @@ mod implementation { } pub fn set_uart_mux(&mut self, mux: UartType) { match mux { - UartType::Kernel => self.gpio_csr.wfo(utra::gpio::UARTSEL_UARTSEL, 0), - UartType::Log => self.gpio_csr.wfo(utra::gpio::UARTSEL_UARTSEL, 1), - UartType::Application => self.gpio_csr.wfo(utra::gpio::UARTSEL_UARTSEL, 2), + UartType::Kernel => { + log::warn!("disabling WFI so that kernel console works as expected"); + self.power_csr.rmwf(utra::power::POWER_DISABLE_WFI, 1); + self.gpio_csr.wfo(utra::gpio::UARTSEL_UARTSEL, 0); + }, + UartType::Log => { + // this is a command mainly for debugging, so we'll accept the chance that we re-enabled WFI e.g. + // during a critical operation like SPINOR flashing because we swapped consoles at a bad time. Should be + // very rare and only affect devs... + log::warn!("unsafe re-enabling WFI -- if you issued this command at a bad time, could have side effects"); + self.power_csr.rmwf(utra::power::POWER_DISABLE_WFI, 0); + self.gpio_csr.wfo(utra::gpio::UARTSEL_UARTSEL, 1) + }, + UartType::Application => { + log::warn!("disabling WFI so that app console works as expected"); + self.power_csr.rmwf(utra::power::POWER_DISABLE_WFI, 1); + self.gpio_csr.wfo(utra::gpio::UARTSEL_UARTSEL, 2) + }, _ => info!("invalid UART type specified for mux, doing nothing."), } } diff --git a/services/root-keys/src/implementation.rs b/services/root-keys/src/implementation.rs index 60fba9232..86cc63e34 100644 --- a/services/root-keys/src/implementation.rs +++ b/services/root-keys/src/implementation.rs @@ -533,7 +533,7 @@ impl RootKeys { } fn make_gateware_backup(&mut self, prog_start: u32, prog_end: u32, progress_modal: &mut Modal, progress_action: &mut Slider) { - // println!("this is a test of stdlib"); + } #[cfg(feature = "hazardous-debug")]