diff --git a/Cargo.lock b/Cargo.lock index a961c4890..7483f098b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,7 +477,7 @@ dependencies = [ [[package]] name = "com_rs" version = "0.1.0" -source = "git+https://github.com/betrusted-io/com_rs.git?rev=f7c46612a4181e3d33ec6c5fc90740062d2d9832#f7c46612a4181e3d33ec6c5fc90740062d2d9832" +source = "git+https://github.com/betrusted-io/com_rs.git?rev=5e3c741369ae2c1a537b41b70bdfd40d1b62e06d#5e3c741369ae2c1a537b41b70bdfd40d1b62e06d" [[package]] name = "com_rs-ref" diff --git a/imports/com_rs-ref/Cargo.toml b/imports/com_rs-ref/Cargo.toml index 4a1be6c2c..e76e51981 100644 --- a/imports/com_rs-ref/Cargo.toml +++ b/imports/com_rs-ref/Cargo.toml @@ -7,7 +7,7 @@ description = "com_rs import package" # Dependency policy: fully specify dependencies to the minor version number [dependencies] -com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "f7c46612a4181e3d33ec6c5fc90740062d2d9832" } +com_rs = { git = "https://github.com/betrusted-io/com_rs.git", rev = "5e3c741369ae2c1a537b41b70bdfd40d1b62e06d" } #com_rs = { path = "../../../betrusted-ec/sw/com_rs" } diff --git a/services/com/src/main.rs b/services/com/src/main.rs index aa5936641..0e5cf3926 100644 --- a/services/com/src/main.rs +++ b/services/com/src/main.rs @@ -672,17 +672,20 @@ fn xmain() -> ! { com.txrx(ComState::WF200_RESET.verb); com.txrx(0); let mut attempts = 0; + let ping_value = 0xaeedu16; // for various reasons, this is a string that is "unlikely" to happen randomly loop { - com.txrx(ComState::LOOP_TEST.verb); - let ack = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // should finish with 5 seconds - // TODO: offer a more robust sequence than 0x00 for detecting if sync is back... - if (ack & 0xff) != 0x00 { //it will read 0xdd or 0xff if the EC is actually still in reset or held up - log::warn!("Wf200 reset took too long, trying to re-establish link sync...{:x}", ack); + com.txrx(ComState::LINK_PING.verb); + com.txrx(ping_value); + let pong = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // should finish with 5 seconds + let phase = com.wait_txrx(ComState::LINK_READ.verb, Some(500)); + if pong == !ping_value && + phase == 0x600d { // 0x600d is a hard-coded constant. It's included to confirm that we aren't "wedged" just sending one value back at us + break; + } else { + log::warn!("Wf200 reset: establishing link sync, attempt {} [{:04x}/{:04x}]", attempts, pong, phase); com.txrx(ComState::LINK_SYNC.verb); ticktimer.sleep_ms(200).unwrap(); attempts += 1; - } else { - break; } if attempts > 50 { // something has gone horribly wrong. Reset the EC entirely.