Skip to content

Commit 3ee36f4

Browse files
committed
remove UX delays on PDDB path
retain just one of them going into the erase routine, because it consumes enough CPU that the dialog box takes a bit too long to pop up.
1 parent 880675c commit 3ee36f4

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

services/pddb/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ hwtest = []
8888
# routines to help with performance profiling of the PDDB in hosted mode
8989
pddb-flamegraph = ["hex"]
9090
perfcounter = ["perflib"]
91+
# introduce a slight delay after UX boxes swap, in case of race conditions. Shouldn't be necessary anymore, but kept around in case there's a new edge case we missed.
92+
ux-swap-delay = []
9193
# make the PDDB very small (4MiB). Note that booting a device with an incompatible `smalldb` setting will break the PDDB image. Use with caution.
9294
smalldb = []
9395
default = ["mbbb"]

services/pddb/src/backend/hw.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,8 @@ impl PddbOs {
18241824
t!("pddb.erase", xous::LANG),
18251825
xous::PDDB_LOC, xous::PDDB_LOC + PDDB_A_LEN as u32, xous::PDDB_LOC)
18261826
.expect("couldn't raise progress bar");
1827+
// retain this delay, because the next section is so compute-intensive, it may take a
1828+
// while for the GAM to catch up.
18271829
self.tt.sleep_ms(100).unwrap();
18281830
}
18291831
for offset in (xous::PDDB_LOC..(xous::PDDB_LOC + PDDB_A_LEN as u32)).step_by(SPINOR_BULK_ERASE_SIZE as usize) {
@@ -1849,6 +1851,7 @@ impl PddbOs {
18491851
if let Some(modals) = progress {
18501852
modals.update_progress(xous::PDDB_LOC + PDDB_A_LEN as u32).expect("couldn't update progress bar");
18511853
modals.finish_progress().expect("couldn't dismiss progress bar");
1854+
#[cfg(feature="ux-swap-delay")]
18521855
self.tt.sleep_ms(100).unwrap();
18531856
}
18541857
}
@@ -1881,6 +1884,7 @@ impl PddbOs {
18811884
}
18821885
if let Some(modals) = progress {
18831886
modals.finish_progress().expect("couldn't dismiss progress bar");
1887+
#[cfg(feature="ux-swap-delay")]
18841888
self.tt.sleep_ms(100).unwrap();
18851889
}
18861890

@@ -1891,6 +1895,7 @@ impl PddbOs {
18911895
//}
18921896
if let Some(modals) = progress {
18931897
modals.start_progress(t!("pddb.key", xous::LANG), 0, 100, 0).expect("couldn't raise progress bar");
1898+
#[cfg(feature="ux-swap-delay")]
18941899
self.tt.sleep_ms(100).unwrap();
18951900
}
18961901
assert!(size_of::<StaticCryptoData>() == PAGE_SIZE, "StaticCryptoData structure is not correctly sized");
@@ -1914,6 +1919,7 @@ impl PddbOs {
19141919
crypto_keys.version = SCD_VERSION; // should already be set by `default()` but let's be sure.
19151920
if let Some(modals) = progress {
19161921
modals.update_progress(50).expect("couldn't update progress bar");
1922+
#[cfg(feature="ux-swap-delay")]
19171923
self.tt.sleep_ms(100).unwrap();
19181924
}
19191925
// copy the encrypted key into the data structure for commit to Flash
@@ -1932,8 +1938,10 @@ impl PddbOs {
19321938
self.patch_keys(crypto_keys.deref(), 0);
19331939
if let Some(modals) = progress {
19341940
modals.update_progress(100).expect("couldn't update progress bar");
1941+
#[cfg(feature="ux-swap-delay")]
19351942
self.tt.sleep_ms(100).unwrap();
19361943
modals.finish_progress().expect("couldn't dismiss progress bar");
1944+
#[cfg(feature="ux-swap-delay")]
19371945
self.tt.sleep_ms(100).unwrap();
19381946
}
19391947
// now we have a copy of the AES key necessary to encrypt the default System basis that we created in step 2.
@@ -1960,13 +1968,16 @@ impl PddbOs {
19601968
}
19611969
if let Some(modals) = progress {
19621970
modals.update_progress(50).expect("couldn't update progress bar");
1971+
#[cfg(feature="ux-swap-delay")]
19631972
self.tt.sleep_ms(100).unwrap();
19641973
}
19651974
self.fast_space_write(&fast_space);
19661975
if let Some(modals) = progress {
19671976
modals.update_progress(100).expect("couldn't update progress bar");
1977+
#[cfg(feature="ux-swap-delay")]
19681978
self.tt.sleep_ms(100).unwrap();
19691979
modals.finish_progress().expect("couldn't dismiss progress bar");
1980+
#[cfg(feature="ux-swap-delay")]
19701981
self.tt.sleep_ms(100).unwrap();
19711982
}
19721983

@@ -1979,6 +1990,7 @@ impl PddbOs {
19791990
if let Some(modals) = progress {
19801991
modals.start_progress(t!("pddb.randomize", xous::LANG),
19811992
self.data_phys_base.as_u32(), PDDB_A_LEN as u32, self.data_phys_base.as_u32()).expect("couldn't raise progress bar");
1993+
#[cfg(feature="ux-swap-delay")]
19821994
self.tt.sleep_ms(100).unwrap();
19831995
}
19841996
let blank = [0xffu8; aes::BLOCK_SIZE];
@@ -2018,14 +2030,17 @@ impl PddbOs {
20182030
}
20192031
if let Some(modals) = progress {
20202032
modals.update_progress(PDDB_A_LEN as u32).expect("couldn't update progress bar");
2033+
#[cfg(feature="ux-swap-delay")]
20212034
self.tt.sleep_ms(100).unwrap();
20222035
modals.finish_progress().expect("couldn't dismiss progress bar");
2036+
#[cfg(feature="ux-swap-delay")]
20232037
self.tt.sleep_ms(100).unwrap();
20242038
}
20252039

20262040
// step 6. create the system basis root structure
20272041
if let Some(modals) = progress {
20282042
modals.start_progress(t!("pddb.structure", xous::LANG), 0, 100, 0).expect("couldn't raise progress bar");
2043+
#[cfg(feature="ux-swap-delay")]
20292044
self.tt.sleep_ms(100).unwrap();
20302045
}
20312046
let basis_root = BasisRoot {
@@ -2040,6 +2055,7 @@ impl PddbOs {
20402055
self.fast_space_read(); // we reconstitute our fspace map even though it was just generated, partially as a sanity check that everything is ok
20412056
if let Some(modals) = progress {
20422057
modals.update_progress(33).expect("couldn't update progress bar");
2058+
#[cfg(feature="ux-swap-delay")]
20432059
self.tt.sleep_ms(100).unwrap();
20442060
}
20452061

@@ -2075,6 +2091,7 @@ impl PddbOs {
20752091
self.system_basis_key = Some(syskey); // put the key back
20762092
if let Some(modals) = progress {
20772093
modals.update_progress(66).expect("couldn't update progress bar");
2094+
#[cfg(feature="ux-swap-delay")]
20782095
self.tt.sleep_ms(100).unwrap();
20792096
}
20802097

@@ -2086,8 +2103,10 @@ impl PddbOs {
20862103
}
20872104
if let Some(modals) = progress {
20882105
modals.update_progress(100).expect("couldn't update progress bar");
2106+
#[cfg(feature="ux-swap-delay")]
20892107
self.tt.sleep_ms(100).unwrap();
20902108
modals.finish_progress().expect("couldn't dismiss progress bar");
2109+
#[cfg(feature="ux-swap-delay")]
20912110
self.tt.sleep_ms(100).unwrap();
20922111
}
20932112
Ok(())
@@ -2384,6 +2403,7 @@ impl PddbOs {
23842403
/// at the conclusion of the sweep, but their page use can be accounted for.
23852404
#[cfg(not(all(feature="pddbtest", feature="autobasis")))]
23862405
pub(crate) fn pddb_get_all_keys(&self, cache: &Vec::<BasisCacheEntry>) -> Option<Vec<(BasisKeys, String)>> {
2406+
#[cfg(feature="ux-swap-delay")]
23872407
const SWAP_DELAY_MS: usize = 300;
23882408
// populate the "known" entries
23892409
let mut ret = Vec::<(BasisKeys, String)>::new();
@@ -2420,6 +2440,7 @@ impl PddbOs {
24202440
DnaMode::Churn => t!("pddb.churn.request", xous::LANG),
24212441
},
24222442
None).ok();
2443+
#[cfg(feature="ux-swap-delay")]
24232444
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
24242445

24252446
// 0.5 display the Bases that we know
@@ -2429,10 +2450,12 @@ impl PddbOs {
24292450
blist.push_str(name);
24302451
}
24312452
modals.show_notification(&blist, None).ok();
2453+
#[cfg(feature="ux-swap-delay")]
24322454
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
24332455

24342456
// 1. prompt user to enter any name/password combos for other basis we want to keep
24352457
while self.yes_no_approval(&modals, t!("pddb.freespace.enumerate_another", xous::LANG)) {
2458+
#[cfg(feature="ux-swap-delay")]
24362459
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
24372460

24382461
match modals
@@ -2478,11 +2501,13 @@ impl PddbOs {
24782501
ret.push((basis_key, name));
24792502
} else {
24802503
modals.show_notification(t!("pddb.freespace.badpass", xous::LANG), None).ok();
2504+
#[cfg(feature="ux-swap-delay")]
24812505
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
24822506
}
24832507
},
24842508
_ => return None,
24852509
};
2510+
#[cfg(feature="ux-swap-delay")]
24862511
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
24872512
// 4. repeat summary print-out
24882513
let mut blist = String::from(t!("pddb.freespace.currentlist", xous::LANG));
@@ -2491,6 +2516,7 @@ impl PddbOs {
24912516
blist.push_str(name);
24922517
}
24932518
modals.show_notification(&blist, None).ok();
2519+
#[cfg(feature="ux-swap-delay")]
24942520
self.tt.sleep_ms(SWAP_DELAY_MS).unwrap();
24952521
}
24962522
// done!

0 commit comments

Comments
 (0)