mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
improve the link sync-up for the EC after a WF200 reset
This commit is contained in:
parent
827888ccbb
commit
3d7ee0663c
3 changed files with 12 additions and 9 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -477,7 +477,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "com_rs"
|
name = "com_rs"
|
||||||
version = "0.1.0"
|
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]]
|
[[package]]
|
||||||
name = "com_rs-ref"
|
name = "com_rs-ref"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ description = "com_rs import package"
|
||||||
|
|
||||||
# Dependency policy: fully specify dependencies to the minor version number
|
# Dependency policy: fully specify dependencies to the minor version number
|
||||||
[dependencies]
|
[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" }
|
#com_rs = { path = "../../../betrusted-ec/sw/com_rs" }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -672,17 +672,20 @@ fn xmain() -> ! {
|
||||||
com.txrx(ComState::WF200_RESET.verb);
|
com.txrx(ComState::WF200_RESET.verb);
|
||||||
com.txrx(0);
|
com.txrx(0);
|
||||||
let mut attempts = 0;
|
let mut attempts = 0;
|
||||||
|
let ping_value = 0xaeedu16; // for various reasons, this is a string that is "unlikely" to happen randomly
|
||||||
loop {
|
loop {
|
||||||
com.txrx(ComState::LOOP_TEST.verb);
|
com.txrx(ComState::LINK_PING.verb);
|
||||||
let ack = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // should finish with 5 seconds
|
com.txrx(ping_value);
|
||||||
// TODO: offer a more robust sequence than 0x00 for detecting if sync is back...
|
let pong = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // should finish with 5 seconds
|
||||||
if (ack & 0xff) != 0x00 { //it will read 0xdd or 0xff if the EC is actually still in reset or held up
|
let phase = com.wait_txrx(ComState::LINK_READ.verb, Some(500));
|
||||||
log::warn!("Wf200 reset took too long, trying to re-establish link sync...{:x}", ack);
|
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);
|
com.txrx(ComState::LINK_SYNC.verb);
|
||||||
ticktimer.sleep_ms(200).unwrap();
|
ticktimer.sleep_ms(200).unwrap();
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if attempts > 50 {
|
if attempts > 50 {
|
||||||
// something has gone horribly wrong. Reset the EC entirely.
|
// something has gone horribly wrong. Reset the EC entirely.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue