diff --git a/docs/flash.md b/docs/flash.md index 7cf3cd021..052d2a6d9 100644 --- a/docs/flash.md +++ b/docs/flash.md @@ -45,9 +45,9 @@ of wear leveling, however. + 204F_FFFF | | +-----------+----------------------------------------+ + 2050_0000 | top 0x1000 is signature record | -+ 2050_FFFF | 0x2050_1000: loader.bin - Xous loader | ++ 2051_FFFF | 0x2050_1000: loader.bin - Xous loader | +-----------+----------------------------------------+ -+ 2051_0000 | Font planes | ++ 2052_0000 | Font planes | + 2097_FFFF | | +-----------+----------------------------------------+ + 2098_0000 | Xous kernel plus | diff --git a/loader/Cargo.lock b/loader/Cargo.lock index f0c5a673c..5383ded1f 100644 --- a/loader/Cargo.lock +++ b/loader/Cargo.lock @@ -73,19 +73,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "curve25519-dalek" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" -dependencies = [ - "byteorder", - "digest", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "curve25519-dalek" version = "3.1.0" @@ -124,7 +111,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek", "ed25519", "sha2", "zeroize", @@ -171,7 +158,7 @@ name = "loader" version = "0.1.0" dependencies = [ "com_rs", - "curve25519-dalek 3.1.0 (git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main)", + "curve25519-dalek", "ed25519-dalek", "lazy_static", "utralib", diff --git a/loader/Cargo.toml b/loader/Cargo.toml index 732aa7677..427f0f812 100644 --- a/loader/Cargo.toml +++ b/loader/Cargo.toml @@ -24,7 +24,7 @@ features = ["u32e_backend"] [dependencies.ed25519-dalek] version="1.0.1" default-features = false -features = ["u32_backend"] +#features = ["u32_backend"] [dev-dependencies] lazy_static = "1.4.0" @@ -52,3 +52,11 @@ default-features = false [patch.crates-io.utralib] path = "../utralib" + +[patch.crates-io.curve25519-dalek] +git="https://github.com/betrusted-io/curve25519-dalek.git" +branch="main" +package = "curve25519-dalek" +version = "3.1.0" +default-features = false +features = ["u32e_backend"] \ No newline at end of file diff --git a/loader/src/secboot.rs b/loader/src/secboot.rs index f910e5ae1..9f880401b 100755 --- a/loader/src/secboot.rs +++ b/loader/src/secboot.rs @@ -229,7 +229,7 @@ impl Keyrom { } true } - fn read_ed25519(&mut self, key_base: KeyLoc) -> ed25519_dalek::PublicKey { + fn read_ed25519(&mut self, key_base: KeyLoc) -> Result { let mut pk_bytes: [u8; 32] = [0; 32]; for (offset, pk_word) in pk_bytes.chunks_exact_mut(4).enumerate() { self.csr.wfo(utra::keyrom::ADDRESS_ADDRESS, key_base as u32 + offset as u32); @@ -238,7 +238,7 @@ impl Keyrom { *dst_byte = src_byte; } } - ed25519_dalek::PublicKey::from_bytes(&pk_bytes).unwrap() + ed25519_dalek::PublicKey::from_bytes(&pk_bytes).or(Err("invalid public key")) } } @@ -313,7 +313,12 @@ pub fn validate_xous_img(xous_img_offset: *const u32) -> bool { gfx.set_devboot(); KeyLoc::DevPub }; - let pubkey = keyrom.read_ed25519(keyloc); + let pubkey = keyrom.read_ed25519(keyloc).unwrap_or_else(|e| { + gfx.msg("Unable to read key: ", &mut cursor); + gfx.msg(e, &mut cursor); + gfx.msg("\n\r", &mut cursor); + panic!("Unable to read key: {}", e) + }); println!("Public key bytes: {:x?}", pubkey.as_bytes()); diff --git a/precursors/soc.svd b/precursors/soc.svd index 9195ee702..8e3303eaa 100755 --- a/precursors/soc.svd +++ b/precursors/soc.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -3580,7 +3580,7 @@ inject too fast.]]> SEED1 0x0000 - 0x428fbb01 + 0x4b40c4ec 32 @@ -3595,7 +3595,7 @@ inject too fast.]]> SEED0 0x0004 - 0x6bfadeed + 0x3e6e25f8 32 diff --git a/precursors/soc_csr.bin b/precursors/soc_csr.bin index 4e0850056..00852932a 100755 Binary files a/precursors/soc_csr.bin and b/precursors/soc_csr.bin differ diff --git a/services/keyboard/src/api.rs b/services/keyboard/src/api.rs index 9a2342286..a78ca729c 100644 --- a/services/keyboard/src/api.rs +++ b/services/keyboard/src/api.rs @@ -36,6 +36,10 @@ impl RowColVec { iter: 0 } } + pub fn clear(&mut self) { + self.storage = [None; MAX_KEYS]; + self.iter = 0; + } pub fn len(&self) -> usize { return MAX_KEYS } diff --git a/services/keyboard/src/main.rs b/services/keyboard/src/main.rs index e7a57f349..11f3cf4d2 100644 --- a/services/keyboard/src/main.rs +++ b/services/keyboard/src/main.rs @@ -293,6 +293,19 @@ mod implementation { } pub fn resume(&mut self) { self.susres.resume(); + + // clear the keyboard state vectors -- actually, if a key was being pressed at the time of suspend + // it's not really relevant anymore; let's throw everything away and start from a clean slate. + self.new_state.clear(); + self.last_state.clear(); + self.shift_down = false; + self.shift_up = false; + self.alt_down = false; + self.alt_up = false; + self.repeating_key = None; + self.chord_captured = false; + self.chord_active = 0; + self.chord = [[false; KBD_COLS]; KBD_ROWS]; } pub fn set_map(&mut self, map: KeyMap) {