add killkey test to the self test suite

This commit is contained in:
bunnie 2021-09-14 20:15:03 +08:00
parent 3f1ba5e279
commit dfc6444d78
7 changed files with 32 additions and 1 deletions

View file

@ -61,6 +61,9 @@ pub struct FlashRecord {
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
pub(crate) enum Opcode {
/// Reset the COM link - useful after an EC reset
LinkReset,
/// Refresh the TRNG seed for the EC
ReseedTrng,

View file

@ -78,6 +78,11 @@ impl Com {
}
}
pub fn link_reset(&self) -> Result<(), xous::Error> {
send_message(self.conn,
Message::new_blocking_scalar(Opcode::LinkReset.to_usize().unwrap(), 0, 0, 0, 0)
).map(|_| ())
}
pub fn reseed_ec_trng(&self) -> Result<(), xous::Error> {
send_message(self.conn,
Message::new_scalar(Opcode::ReseedTrng.to_usize().unwrap(), 0, 0, 0, 0)

View file

@ -331,6 +331,7 @@ fn xmain() -> ! {
const FLASH_LEN: u32 = 0x10_0000;
const FLASH_TIMEOUT: u32 = 250;
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
// initial seed of the COM trng
let trng = trng::Trng::new(&xns).expect("couldn't connect to TRNG");
com.txrx(ComState::TRNG_SEED.verb);
@ -358,6 +359,11 @@ fn xmain() -> ! {
com.txrx(ComState::BL_START.verb | (bl_main as u16) & 0x1f | (((bl_sec as u16) & 0x1f) << 5));
}
}),
Some(Opcode::LinkReset) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
com.txrx(ComState::LINK_SYNC.verb);
ticktimer.sleep_ms(200).unwrap(); // give some time for the link to reset - the EC does not have a guaranteed latency to respond to a link reset
xous::return_scalar(msg.sender, 1).unwrap();
}),
Some(Opcode::ReseedTrng) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
com.txrx(ComState::TRNG_SEED.verb);
for _ in 0..2 {

View file

@ -247,6 +247,7 @@ mod implementation {
// (these "should" be redundant)
self.power_csr.rmwf(utra::power::POWER_SELF, 1);
self.power_csr.rmwf(utra::power::POWER_STATE, 1);
self.power_csr.rmwf(utra::power::POWER_UP5K_ON, 1);
self.event_susres.resume();
self.gpio_susres.resume();
@ -400,6 +401,7 @@ mod implementation {
}
}
pub fn ec_reset(&mut self) {
self.power_csr.rmwf(utra::power::POWER_UP5K_ON, 1); // make sure the power is "on" if we're resetting it
self.power_csr.rmwf(utra::power::POWER_RESET_EC, 1);
self.ticktimer.sleep_ms(20).unwrap();
self.power_csr.rmwf(utra::power::POWER_RESET_EC, 0);
@ -705,6 +707,7 @@ fn xmain() -> ! {
// Create a new llio object
let handler_conn = xous::connect(llio_sid).expect("can't create IRQ handler connection");
let mut llio = Llio::new(handler_conn, gpio_base);
llio.ec_power_on(); // ensure this is set correctly; if we're on, we always want the EC on.
// register a suspend/resume listener
let sr_cid = xous::connect(llio_sid).expect("couldn't create suspend callback connection");

View file

@ -581,6 +581,7 @@ fn xmain() -> ! {
// - GAM
// - shellchat/rtc
// - shellchat/sleep x2
// - factory test
// - UX thread (self, created without xns, so does not count)
// - rootkeys (for coordinating reboot)
let rtc_sid = xns.register_name(api::SERVER_NAME_RTC, Some(5)).expect("can't register server");

View file

@ -357,6 +357,9 @@ impl<'a> ShellCmdApi<'a> for EcUpdate {
}
"reset" => {
env.llio.ec_reset().unwrap();
env.ticktimer.sleep_ms(4000).unwrap();
env.com.link_reset().unwrap();
env.com.reseed_ec_trng().unwrap();
write!(ret, "EC has been reset, and new firmware loaded.").unwrap();
}
"wf200" => {

View file

@ -23,7 +23,7 @@ pub struct Test {
right_play: bool,
speaker_play: bool,
freq: f32,
// rtc
//rtc: rtc::Rtc,
start_time: Option<DateTime>,
end_time: Option<DateTime>,
start_elapsed: Option<u64>,
@ -55,6 +55,7 @@ impl Test {
right_play: true,
speaker_play: true,
freq: 440.0,
//rtc: rtc::Rtc::new(&xns).unwrap(),
start_time: None,
end_time: None,
start_elapsed: None,
@ -227,6 +228,8 @@ impl<'a> ShellCmdApi<'a> for Test {
log::info!("{}|RTC|FAIL|NO_END|", SENTINEL);
}
env.com.link_reset().unwrap();
env.com.reseed_ec_trng().unwrap();
let ut_after = env.com.get_ec_uptime().unwrap();
if ut < ut_after || ut_after > 4200 {
@ -277,6 +280,13 @@ impl<'a> ShellCmdApi<'a> for Test {
env.llio.boost_on(false).unwrap();
log::info!("{}|BOOSTOFF|", SENTINEL);
}
"kill" => {
log::info!("{}|KILL|", SENTINEL);
env.ticktimer.sleep_ms(500).unwrap();
env.llio.self_destruct(0x2718_2818).unwrap();
env.llio.self_destruct(0x3141_5926).unwrap();
env.ticktimer.sleep_ms(100).unwrap();
}
"astart" => {
self.freq = if let Some(freq_str) = tokens.next() {
match freq_str.parse::<f32>() {