diff --git a/services/pddb/src/backend/hw.rs b/services/pddb/src/backend/hw.rs index ab3eb2318..54791cb33 100644 --- a/services/pddb/src/backend/hw.rs +++ b/services/pddb/src/backend/hw.rs @@ -530,7 +530,7 @@ impl PddbOs { let remaining_len = buf.len() - written; // this is OK here because we took care of any misaligned start data in step 1. let aligned_start = (offset + (SPINOR_ERASE_SIZE as usize - 1)) & !(SPINOR_ERASE_SIZE as usize - 1); - log::info!( + log::debug!( "aligned_start {:x} end {:x}", aligned_start, (aligned_start + (remaining_len + (SPINOR_ERASE_SIZE as usize - 1)) diff --git a/services/pddb/src/main.rs b/services/pddb/src/main.rs index cf1bcdd7b..70312b04a 100644 --- a/services/pddb/src/main.rs +++ b/services/pddb/src/main.rs @@ -797,28 +797,24 @@ fn wrapped_main() -> ! { #[cfg(feature = "gen2")] Opcode::TryMount => { xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, { + fn try_mount( + pddb_os: &mut PddbOs, + basis_cache: &mut BasisCache, + basis_monitor_notifications: &mut Vec, + ) -> bool { + if let Some(sys_basis) = pddb_os.pddb_mount() { + log::info!("PDDB mount operation finished successfully"); + basis_cache.basis_add(sys_basis); + if basis_monitor_notifications.len() > 0 { + notify_basis_change(basis_monitor_notifications, basis_cache.basis_list()); + } + true + } else { + false + } + } match pddb_os.ensure_password() { PasswordState::Correct => { - fn try_mount( - pddb_os: &mut PddbOs, - basis_cache: &mut BasisCache, - basis_monitor_notifications: &mut Vec, - ) -> bool { - if let Some(sys_basis) = pddb_os.pddb_mount() { - log::info!("PDDB mount operation finished successfully"); - basis_cache.basis_add(sys_basis); - if basis_monitor_notifications.len() > 0 { - notify_basis_change( - basis_monitor_notifications, - basis_cache.basis_list(), - ); - } - true - } else { - false - } - } - // The behavior in gen2 is mount-or-format: no user approval // is requested in case of format. This is silghtly dangerous in case // of data corruption but I think this is the "right" user experience @@ -833,11 +829,13 @@ fn wrapped_main() -> ! { panic!("Couldn't format & mount PDDB"); } } - log::info!("{}PDDB.MOUNTED,{}", BOOKEND_START, BOOKEND_END); - xous::return_scalar2(msg.sender, 0, 0).expect("couldn't return scalar"); } PasswordState::Uninit => { - unimplemented!("Password is always available on gen2") + log::warn!("PDDB not formatted - formatting the PDDB!"); + pddb_os.pddb_format(false, None).expect("couldn't format PDDB"); + if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) { + panic!("Couldn't format & mount PDDB"); + } } PasswordState::ForcedAbort(_failcount) => { unreachable!(); @@ -846,6 +844,12 @@ fn wrapped_main() -> ! { unreachable!(); } } + // the above operation should either succeed or panic, so we are always "success" here + log::info!("{}PDDB.MOUNTED,{}", BOOKEND_START, BOOKEND_END); + xous::return_scalar2(msg.sender, 0, 0).expect("couldn't return scalar"); + for requester in attempt_notifications.drain(..) { + xous::return_scalar2(requester, 0, 0).expect("couldn't return scalar"); + } }) } #[cfg(feature = "gen1")]