Merge branch 'main' into bunnie-dev

This commit is contained in:
bunnie 2021-07-13 23:11:46 +08:00
commit 69d34d38dc
8 changed files with 41 additions and 24 deletions

View file

@ -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 |

17
loader/Cargo.lock generated
View file

@ -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",

View file

@ -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"]

View file

@ -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<ed25519_dalek::PublicKey, &'static str> {
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());

View file

@ -3,7 +3,7 @@
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
<vendor>litex</vendor>
<name>SOC</name>
<description><![CDATA[Litex SoC 2021-07-13 22:01:40]]></description>
<description><![CDATA[Litex SoC 2021-07-13 22:02:21]]></description>
<addressUnitBits>8</addressUnitBits>
<width>32</width>
@ -3580,7 +3580,7 @@ inject too fast.]]></description>
<name>SEED1</name>
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
<addressOffset>0x0000</addressOffset>
<resetValue>0x428fbb01</resetValue>
<resetValue>0x4b40c4ec</resetValue>
<size>32</size>
<fields>
<field>
@ -3595,7 +3595,7 @@ inject too fast.]]></description>
<name>SEED0</name>
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
<addressOffset>0x0004</addressOffset>
<resetValue>0x6bfadeed</resetValue>
<resetValue>0x3e6e25f8</resetValue>
<size>32</size>
<fields>
<field>

Binary file not shown.

View file

@ -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
}

View file

@ -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) {