diff --git a/Cargo.toml b/Cargo.toml index 550cc607d..585617c9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,8 +78,8 @@ resolver = "2" # Keep them out of the main workspace. exclude = [ "kernel", - "loader", # Exclude UTRA, since it is machine-generated. - "utralib", + "loader", + "utralib", # Exclude UTRA, since it is machine-generated. ] [profile.release] diff --git a/loader/Cargo.lock b/loader/Cargo.lock index bdb8bbe9f..f0c5a673c 100644 --- a/loader/Cargo.lock +++ b/loader/Cargo.lock @@ -47,12 +47,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "clap" version = "2.33.3" @@ -68,21 +62,17 @@ dependencies = [ "vec_map", ] +[[package]] +name = "com_rs" +version = "0.1.0" +source = "git+https://github.com/betrusted-io/com_rs?branch=main#4b45a42ad2d932550566d6c32ec1e1dd60e93c67" + [[package]] name = "convert_case" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "cpufeatures" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" -dependencies = [ - "libc", -] - [[package]] name = "curve25519-dalek" version = "3.1.0" @@ -96,6 +86,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "curve25519-dalek" +version = "3.1.0" +source = "git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main#c0ee5bf18c606b51bbffb02fde5801ac129b4e7d" +dependencies = [ + "byteorder", + "digest", + "engine25519-as", + "rand_core", + "subtle", + "utralib", + "zeroize", +] + [[package]] name = "digest" version = "0.9.0" @@ -120,12 +124,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek", + "curve25519-dalek 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ed25519", "sha2", "zeroize", ] +[[package]] +name = "engine25519-as" +version = "0.1.0" +source = "git+https://github.com/betrusted-io/engine25519-as.git?rev=6681e73c1fdc4a460b5ef9f9c7c91aef546d00f3#6681e73c1fdc4a460b5ef9f9c7c91aef546d00f3" + [[package]] name = "generic-array" version = "0.14.4" @@ -161,7 +170,8 @@ checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" name = "loader" version = "0.1.0" dependencies = [ - "curve25519-dalek", + "com_rs", + "curve25519-dalek 3.1.0 (git+https://github.com/betrusted-io/curve25519-dalek.git?branch=main)", "ed25519-dalek", "lazy_static", "utralib", @@ -215,14 +225,11 @@ checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" [[package]] name = "sha2" version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer", - "cfg-if", - "cpufeatures", "digest", "opaque-debug", + "utralib", ] [[package]] diff --git a/loader/Cargo.toml b/loader/Cargo.toml index 0204cae45..732aa7677 100644 --- a/loader/Cargo.toml +++ b/loader/Cargo.toml @@ -8,10 +8,18 @@ description = "Initial kernel loader for Xous" [dependencies] utralib = {path = "../utralib"} +[dependencies.com_rs] +git="https://github.com/betrusted-io/com_rs" +branch="main" + [dependencies.curve25519-dalek] +git="https://github.com/betrusted-io/curve25519-dalek.git" +branch="main" +#path = "../../curve25519-dalek" +package = "curve25519-dalek" version = "3.1.0" default-features = false -features = ["u32_backend"] +features = ["u32e_backend"] [dependencies.ed25519-dalek] version="1.0.1" @@ -35,3 +43,12 @@ lto = "fat" [target.'cfg(not(any(windows, unix)))'.dependencies] utralib = { path = "../utralib"} + +# patch key references into our local name space +[patch.crates-io.sha2] +path = "./sha2" +package = "sha2" +default-features = false + +[patch.crates-io.utralib] +path = "../utralib" diff --git a/loader/link.x b/loader/link.x index ac1f4fd36..035c30181 100644 --- a/loader/link.x +++ b/loader/link.x @@ -5,7 +5,7 @@ MEMORY MEMLCD: ORIGIN = 0xB0000000, LENGTH = 32k } /* -Fonts go from 0x2051_0000 to 0x2098_0000 +Fonts go from 0x2052_0000 to 0x2098_0000 */ REGION_ALIAS("REGION_TEXT", FLASH); @@ -90,7 +90,7 @@ SECTIONS _edata = .; } > REGION_DATA AT > REGION_RODATA - .fonts ALIGN(65536) : SUBALIGN(65536) + .fonts ALIGN(131072) : SUBALIGN(131072) { KEEP(*(.fontdata)); } > REGION_RODATA diff --git a/loader/sha2/Cargo.toml b/loader/sha2/Cargo.toml new file mode 100644 index 000000000..fa32b50d4 --- /dev/null +++ b/loader/sha2/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "sha2" +version = "0.9.5" +authors = ["bunnie "] +edition = "2018" +description = "sha2 hardware accelerator engine" + +[dependencies] +utralib = {path = "../../utralib"} + +# Rust-standard digest API dependencies +digest = "0.9" +block-buffer = "0.9" +opaque-debug = "0.3" # prevents internal hash state leakage from debug structures + +[target.'cfg(not(any(windows,unix)))'.dependencies] +utralib = { path = "../../utralib"} + +[features] +default = [] diff --git a/loader/sha2/src/lib.rs b/loader/sha2/src/lib.rs new file mode 100644 index 000000000..87ad49c7d --- /dev/null +++ b/loader/sha2/src/lib.rs @@ -0,0 +1,148 @@ +#![cfg_attr(target_os = "none", no_std)] + +use digest::{BlockInput, FixedOutputDirty, Reset, Update}; +use digest::consts::{U64, U128}; +type BlockSize = U128; + +use utralib::generated::*; + +/// The SHA-512 hash algorithm with the SHA-512 initial hash value. +#[derive(Clone)] +pub struct Sha512 { + csr: utralib::CSR, + fifo: *mut u32, +} +impl Sha512 { + // use this function instead of default for more control over configuration of the hardware engine + pub fn new() -> Self { + let mut csr = CSR::new(utra::sha512::HW_SHA512_BASE as *mut u32); + csr.wfo(utra::sha512::POWER_ON, 1); + // setup for sha512 operation + csr.wo(utra::sha512::CONFIG, + csr.ms(utra::sha512::CONFIG_DIGEST_SWAP, 1) | + csr.ms(utra::sha512::CONFIG_ENDIAN_SWAP, 1) | + csr.ms(utra::sha512::CONFIG_SHA_EN, 1) + ); + csr.wfo(utra::sha512::COMMAND_HASH_START, 1); + // csr.wfo(utra::sha512::EV_ENABLE_SHA512_DONE, 1); + + Sha512 { + csr, + fifo: utralib::HW_SHA512_MEM as *mut u32, + } + } + // call before exit, to cleanup from bootloader -- otherwise the unit might be stuck on as it's assumed to be off going into Xous + pub fn power_off(&mut self) { + self.csr.wfo(utra::sha512::POWER_ON, 0); + } +} + +impl Default for Sha512 { + fn default() -> Self { + Sha512::new() + } +} + +impl Drop for Sha512 { + fn drop(&mut self) { + self.csr.wo(utra::sha512::CONFIG, 0); // clear all config bits, including EN, which resets the unit + } +} + +impl BlockInput for Sha512 { + type BlockSize = BlockSize; +} + +impl Update for Sha512 { + fn update(&mut self, input: impl AsRef<[u8]>) { + let buf: &[u8] = input.as_ref(); + + self.csr.wfo(utra::sha512::POWER_ON, 1); + let sha = self.fifo; + let sha_byte = self.fifo as *mut u8; + + for (_reg, chunk) in buf.chunks(4).enumerate() { + let mut temp: [u8; 4] = Default::default(); + if chunk.len() == 4 { + temp.copy_from_slice(chunk); + let dword: u32 = u32::from_le_bytes(temp); + + while self.csr.rf(utra::sha512::FIFO_ALMOST_FULL) != 0 { + } + unsafe { sha.write_volatile(dword); } + } else { + for index in 0..chunk.len() { + while self.csr.rf(utra::sha512::FIFO_ALMOST_FULL) != 0 { + } + unsafe{ sha_byte.write_volatile(chunk[index]); } + } + } + } + } +} + +impl FixedOutputDirty for Sha512 { + type OutputSize = U64; + + fn finalize_into_dirty(&mut self, out: &mut digest::Output) { + self.csr.wfo(utra::sha512::EV_PENDING_SHA512_DONE, 1); // clear the done if it's pending + self.csr.wfo(utra::sha512::COMMAND_HASH_PROCESS, 1); + while self.csr.rf(utra::sha512::EV_PENDING_SHA512_DONE) == 0 { + } + self.csr.wfo(utra::sha512::EV_PENDING_SHA512_DONE, 1); + + let _length_in_bits: u64 = (self.csr.r(utra::sha512::MSG_LENGTH0) as u64) | ((self.csr.r(utra::sha512::MSG_LENGTH1) as u64) << 32); + let mut hash: [u8; 64] = [0; 64]; + let digest_regs: [utralib::Register; 16] = [ + utra::sha512::DIGEST00, + utra::sha512::DIGEST01, + utra::sha512::DIGEST10, + utra::sha512::DIGEST11, + utra::sha512::DIGEST20, + utra::sha512::DIGEST21, + utra::sha512::DIGEST30, + utra::sha512::DIGEST31, + utra::sha512::DIGEST40, + utra::sha512::DIGEST41, + utra::sha512::DIGEST50, + utra::sha512::DIGEST51, + utra::sha512::DIGEST60, + utra::sha512::DIGEST61, + utra::sha512::DIGEST70, + utra::sha512::DIGEST71, + ]; + let mut i = 0; + for ® in digest_regs.iter() { + hash[i..i+4].clone_from_slice(&self.csr.r(reg).to_le_bytes()); + i += 4; + } + self.csr.wo(utra::sha512::CONFIG, 0); // clear all config bits, including EN, which resets the unit + + // two-stage copy because we're porting code over. maybe this could be merged into the copy above, but let's optimize that once things are working. + for (dest, &src) in out.chunks_exact_mut(1).zip(hash.iter()) { + dest.copy_from_slice(&[src]) + } + } +} + +impl Reset for Sha512 { + fn reset(&mut self) { + if self.csr.rf(utra::sha512::FIFO_RUNNING) != 0 { + // if it's running, call digest, then reset + let sha = self.fifo; + unsafe { sha.write_volatile(0x0); } // stuff a dummy byte, in case the hash was empty + self.csr.wfo(utra::sha512::COMMAND_HASH_PROCESS, 1); + self.csr.wfo(utra::sha512::EV_PENDING_SHA512_DONE, 1); + while self.csr.rf(utra::sha512::EV_PENDING_SHA512_DONE) == 0 { + } + } else { + // engine is already stopped, just clear the pending bits and reset the config + } + self.csr.wfo(utra::sha512::EV_PENDING_SHA512_DONE, 1); + self.csr.wo(utra::sha512::CONFIG, 0); // clear all config bits, including EN, which resets the unit + } +} + +opaque_debug::implement!(Sha512); + +digest::impl_write!(Sha512); diff --git a/loader/src/fonts.rs b/loader/src/fonts.rs old mode 100644 new mode 100755 index 4abd8bbe1..1136823c0 --- a/loader/src/fonts.rs +++ b/loader/src/fonts.rs @@ -1,7 +1,7 @@ // This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit. // The order of these modules impacts the link order, which changes the position in the binary image. -pub mod hanzi; +pub mod bold; pub mod emoji; +pub mod hanzi; pub mod regular; pub mod small; -pub mod bold; diff --git a/loader/src/fonts/bold.rs b/loader/src/fonts/bold.rs old mode 100644 new mode 100755 diff --git a/loader/src/fonts/emoji.rs b/loader/src/fonts/emoji.rs old mode 100644 new mode 100755 diff --git a/loader/src/fonts/hanzi.rs b/loader/src/fonts/hanzi.rs old mode 100644 new mode 100755 diff --git a/loader/src/fonts/regular.rs b/loader/src/fonts/regular.rs old mode 100644 new mode 100755 diff --git a/loader/src/fonts/small.rs b/loader/src/fonts/small.rs old mode 100644 new mode 100755 diff --git a/loader/src/generate_fonts.py b/loader/src/generate_fonts.py index 1662e2b38..72ef305e1 100755 --- a/loader/src/generate_fonts.py +++ b/loader/src/generate_fonts.py @@ -73,7 +73,7 @@ def main(): mapfile.write("#![allow(dead_code)]\n") # Python iterators are deterministic, right......? so if I used the same iterator to make the link order it'll be the same here....right? offset = 0 - mapfile.write("pub const FONT_BASE: usize = 0x{:08x};\n".format(0x20510000)) + mapfile.write("pub const FONT_BASE: usize = 0x{:08x};\n".format(0x20520000)) for k,v in fontdict.items(): length = int(v) * 4 mapfile.write("pub const {}_OFFSET: usize = 0x{:08x};\n".format(k.upper(), offset)) diff --git a/loader/src/main.rs b/loader/src/main.rs index 3a72890f6..0cd7fd2c9 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -1180,6 +1180,8 @@ fn boot_sequence(args: KernelArguments, _signature: u32) -> ! { // where in heap this memory will go. #[allow(clippy::cast_ptr_alignment)] // This test only works on 32-bit systems if false { + // note: memtest is "destructive" -- can't do a resume after suspend with memtest enabled + // use this mainly to trace down e.g. hardware issues with timing to the RAM. memtest(); } let mut cfg = BootConfig { diff --git a/loader/src/secboot.rs b/loader/src/secboot.rs index af2deec83..68ca8380e 100755 --- a/loader/src/secboot.rs +++ b/loader/src/secboot.rs @@ -1,19 +1,11 @@ -#![cfg_attr(target_os = "none", no_std)] -#![cfg_attr(target_os = "none", no_main)] - -#![allow(unreachable_code)] // allow debugging of failures to jump out of the bootloader +use crate::println; pub const SIGBLOCK_SIZE: usize = 0x1000; const VERSION_STR: &'static str = "Xous OS Loader v0.9.0\n\r"; -////// TODO: derive this from boot args -const KERNEL_DATA_OFFSET: u32 = 0x2098_1000; -const KERNEL_SIG_OFFSET: u32 = 0x2098_0000; - - -const STACK_LEN: u32 = 8192 - (7 * 4); // 7 words for backup kernel args -const STACK_TOP: u32 = 0x4100_0000 - STACK_LEN; +pub const STACK_LEN: u32 = 8192 - (7 * 4); // 7 words for backup kernel args +pub const STACK_TOP: u32 = 0x4100_0000 - STACK_LEN; use utralib::generated::*; @@ -52,6 +44,7 @@ impl<'a> Gfx { pub fn init(&mut self, clk_mhz: u32) { self.csr.wfo(utra::memlcd::PRESCALER_PRESCALER, (clk_mhz / 2_000_000) - 1); } + #[allow(dead_code)] pub fn update_all(&mut self) { self.csr.wfo(utra::memlcd::COMMAND_UPDATEALL, 1); } @@ -65,6 +58,14 @@ impl<'a> Gfx { false } } + pub fn flush(&mut self) { + self.update_dirty(); + while self.busy() {} + // clear the dirty bits + for lines in 0..FB_LINES { + self.fb[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] &= 0x0000_FFFF; + } + } pub fn set_devboot(&mut self) { self.csr.wfo(utra::memlcd::DEVBOOT_DEVBOOT, 1); } @@ -169,8 +170,7 @@ impl<'a> Gfx { } } pos.x += x_update; - self.update_dirty(); - while self.busy() {} + self.flush(); } pub fn draw_pixel(&mut self, pix: Point, color: Color) { let mut clip_y: usize = pix.y as usize; @@ -242,6 +242,134 @@ impl Keyrom { // returns true if the kernel is valid // side-effects the "devboot" register in the gfx engine if devkeys were detected -pub fn validate_xous_img(_xous_img_offset: *const u32) -> bool { +pub fn validate_xous_img(xous_img_offset: *const u32) -> bool { + // conjure the signature struct directly out of memory. super unsafe. + let sig_ptr = xous_img_offset as *const SignatureInFlash; + let sig: &SignatureInFlash = unsafe{sig_ptr.as_ref().unwrap()}; + let mut cursor = Point {x: LEFT_MARGIN, y: (FB_LINES as i16 / 2) + 10}; // draw on bottom half + + // clear screen to all black + let mut gfx = Gfx { + csr: CSR::new(utra::memlcd::HW_MEMLCD_BASE as *mut u32), + fb: unsafe{core::slice::from_raw_parts_mut(utralib::HW_MEMLCD_MEM as *mut u32, FB_SIZE)}, + }; + gfx.init(100_000_000); + + // extract the second half of the frame buffer with .chunks_mut(len()/2).skip(1).next().unwrap() + // then iterate through each word, along with an index .iter_mut().enumerate() + // then insert a pattern of alternating 0101/1010 to create a "gray effect" on the bottom half of the fb + // note that the gray has "stripes" every 32 bits but it's visually easier to look at than stripes every other bit + for (i, word) in + gfx.fb.chunks_mut(gfx.fb.len() / 2).skip(1).next().unwrap() + .iter_mut().enumerate() { + if i % 2 == 0 { + *word = 0xAAAA_AAAA; + } else { + *word = 0x5555_5555; + } + } + gfx.flush(); + + // now characters should actually be able to print + gfx.msg(VERSION_STR, &mut cursor); + println!("{}", VERSION_STR); + + // init the curve25519 engine + let mut engine = utralib::CSR::new(utra::engine::HW_ENGINE_BASE as *mut u32); + engine.wfo(utra::engine::POWER_ON, 1); + engine.wfo(utra::engine::WINDOW_WINDOW, 0); + engine.wfo(utra::engine::MPSTART_MPSTART, 0); + + // select the public key + let mut keyrom = Keyrom::new(); + let keyloc = + if !keyrom.key_is_zero(KeyLoc::SelfSignPub) { // self-signing key takes priority + if keyrom.key_is_dev(KeyLoc::SelfSignPub) { + println!("Self-signed key slot, but with developer public key."); + gfx.msg("DEVELOPER KEY DETECTED\n\r", &mut cursor); + gfx.set_devboot(); + } + println!("Using self-signed public key"); + KeyLoc::SelfSignPub + } else if !keyrom.key_is_zero(KeyLoc::ThirdPartyPub) { // third party key is second in line + if keyrom.key_is_dev(KeyLoc::ThirdPartyPub) { + println!("Third party public key slot, but with developer public key."); + gfx.msg("DEVELOPER KEY DETECTED\n\r", &mut cursor); + gfx.set_devboot(); + } + println!("Using third-party public key"); + KeyLoc::ThirdPartyPub + } else { + if keyrom.key_is_zero(KeyLoc::DevPub) { + gfx.msg("Can't boot: No valid keys!", &mut cursor); + loop {} + } + gfx.msg("DEVELOPER KEY DETECTED\n\r", &mut cursor); + println!("Using developer public key"); + gfx.set_devboot(); + KeyLoc::DevPub + }; + let pubkey = keyrom.read_ed25519(keyloc); + + println!("Public key bytes: {:x?}", pubkey.as_bytes()); + + if sig.version != 1 { + println!("Warning: mismatch on signature record version numbering. Ignoring and moving on...") + } + let signed_len = sig.signed_len; + let image: &[u8] = unsafe{core::slice::from_raw_parts((xous_img_offset as usize + SIGBLOCK_SIZE) as *const u8, signed_len as usize)}; + let ed25519_signature = ed25519_dalek::Signature::from(sig.signature); + + use ed25519_dalek::Verifier; + if pubkey.verify(image, &ed25519_signature).is_ok() { + gfx.msg("Signature check passed\n\r", &mut cursor); + println!("Signature check passed"); + } else { + gfx.msg("Signature check failed, powering down\n\r", &mut cursor); + println!("Signature check failed"); + let ticktimer = CSR::new(utra::ticktimer::HW_TICKTIMER_BASE as *mut u32); + let mut power = CSR::new(utra::power::HW_POWER_BASE as *mut u32); + let mut com = CSR::new(utra::com::HW_COM_BASE as *mut u32); + let mut start = ticktimer.rf(utra::ticktimer::TIME0_TIME); + loop { + // every 15 seconds, attempt to send a power down command + // any attempt to re-flash the system must halt the CPU before we time-out to this point! + if ticktimer.rf(utra::ticktimer::TIME0_TIME) - start > 15_000 { + println!("Powering down..."); + power.rmwf(utra::power::POWER_STATE, 0); + power.rmwf(utra::power::POWER_SELF, 0); + + // ship mode is the safest mode -- suitable for long-term storage (~years) + com.wfo(utra::com::TX_TX, com_rs::ComState::POWER_SHIPMODE.verb as u32); + while com.rf(utra::com::STATUS_TIP) == 1 {} + let _ = com.rf(utra::com::RX_RX); // discard the RX result + start = ticktimer.rf(utra::ticktimer::TIME0_TIME); + } + } + } + + // check the stack usage + let stack: &[u32] = unsafe{core::slice::from_raw_parts(STACK_TOP as *const u32, (STACK_LEN as usize / core::mem::size_of::()) as usize)}; + let mut unused_stack_words = 0; + for &word in stack.iter() { + if word != 0xACE0BACE { + break; + } + unused_stack_words += 1; + } + println!("Free stack after signature check: {} bytes", unused_stack_words * 4); + gfx.msg("Free stack after sigcheck: 0x", &mut cursor); + gfx.hex_word(unused_stack_words * 4, &mut cursor); + + gfx.msg("\n\r\n\rLoading kernel...\n\r", &mut cursor); + println!("Everything checks out, loading to kernel..."); + + let mut sha_csr = CSR::new(utra::sha512::HW_SHA512_BASE as *mut u32); + sha_csr.wfo(utra::sha512::POWER_ON, 0); // cut power to the SHA block; this is the expected default state after the bootloader is done. + let mut engine_csr = CSR::new(utra::engine::HW_ENGINE_BASE as *mut u32); + engine_csr.wfo(utra::engine::POWER_ON, 0); // cut power to the engine block; this is the expected default state after the bootloader is done. + // note that removing power does *not* clear the RF or microcode state -- data can leak from the bootloader + // into other areas because of this! (but I think it's OK because we just mess around with public keys here) + true } diff --git a/precursors/soc.svd b/precursors/soc.svd index 0a1f5af65..6f4d2a7ca 100755 --- a/precursors/soc.svd +++ b/precursors/soc.svd @@ -3,7 +3,7 @@ litex SOC - + 8 32 @@ -1222,10 +1222,10 @@ register to disable individual events.]]> GIT_GITREV 0x0014 - 0xa27f1fe4 + 0x9e37625a 32 @@ -1242,7 +1242,7 @@ the exact git version used to build this firmware.]]> is ``1``, then the repository this was built from has one additional commit beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]> 0x0018 - 0x39 + 0x3b 32 @@ -3485,7 +3485,7 @@ inject too fast.]]> SEED1 0x0000 - 0x6a195bb8 + 0x55bba5d1 32 @@ -3500,7 +3500,7 @@ inject too fast.]]> SEED0 0x0004 - 0xde8898d + 0x15927727 32 diff --git a/precursors/soc_csr.bin b/precursors/soc_csr.bin index 055ea814d..cd6673b4d 100755 Binary files a/precursors/soc_csr.bin and b/precursors/soc_csr.bin differ diff --git a/services/gam/src/status.rs b/services/gam/src/status.rs index 4d67e5f2c..bcb85f8c1 100644 --- a/services/gam/src/status.rs +++ b/services/gam/src/status.rs @@ -242,7 +242,8 @@ pub fn status_thread(canvas_gid_0: usize, canvas_gid_1: usize, canvas_gid_2: usi }); } } - if (stats_phase % stats_interval == 0) && ((stats_phase % (stats_interval * 2)) == stats_interval) && datetime.is_some() { + // date/time only redraws once every stats_interval period; but if needs_redraw is triggered (e.g. due to resume), force a redraw + if (needs_redraw || ((stats_phase % stats_interval == 0) && ((stats_phase % (stats_interval * 2)) == stats_interval))) && datetime.is_some() { let dt = datetime.unwrap(); let day = match dt.weekday { rtc::Weekday::Monday => "Mon", diff --git a/services/graphics-server/src/fontmap.rs b/services/graphics-server/src/fontmap.rs old mode 100644 new mode 100755 index d181fdfff..f1fc694ab --- a/services/graphics-server/src/fontmap.rs +++ b/services/graphics-server/src/fontmap.rs @@ -1,15 +1,15 @@ // This file is autogenerated by xous-core/loader/src/generate_fonts.py. Do not edit. // This makes probably bad assumptions about how link order is computed. Be suspicious of these offsets. #![allow(dead_code)] -pub const FONT_BASE: usize = 0x20510000; -pub const HANZI_OFFSET: usize = 0x00000000; -pub const HANZI_LEN: usize = 0x0010df64; -pub const EMOJI_OFFSET: usize = 0x0010df64; -pub const EMOJI_LEN: usize = 0x00059170; -pub const REGULAR_OFFSET: usize = 0x001670d4; -pub const REGULAR_LEN: usize = 0x00001610; -pub const SMALL_OFFSET: usize = 0x001686e4; -pub const SMALL_LEN: usize = 0x000010bc; -pub const BOLD_OFFSET: usize = 0x001697a0; +pub const FONT_BASE: usize = 0x20520000; +pub const BOLD_OFFSET: usize = 0x00000000; pub const BOLD_LEN: usize = 0x00001774; +pub const EMOJI_OFFSET: usize = 0x00001774; +pub const EMOJI_LEN: usize = 0x00059170; +pub const HANZI_OFFSET: usize = 0x0005a8e4; +pub const HANZI_LEN: usize = 0x0010df64; +pub const REGULAR_OFFSET: usize = 0x00168848; +pub const REGULAR_LEN: usize = 0x00001610; +pub const SMALL_OFFSET: usize = 0x00169e58; +pub const SMALL_LEN: usize = 0x000010bc; pub const FONT_TOTAL_LEN: usize = 0x0016af14; diff --git a/tools/sign_image.py b/tools/sign_image.py index c0b68489b..c4298f436 100755 --- a/tools/sign_image.py +++ b/tools/sign_image.py @@ -3,7 +3,7 @@ import argparse import sys from Crypto.IO import PEM # counter-intuitively, this is from pycryptodome: `pip3 install pycryptodome` (ubuntu) `pip install pycryptodome` (maybe others?) # note: if you did the sensible thing and tried to install the crypto or pycrypto libraries first when you hit this error -# you have to uninstall those before putting in pycryptodome. +# you have to uninstall those before putting in pycryptodome: `pip remove crypto`, and then `pip install pycryptodome` (or pip3 on ubuntu) from nacl.signing import SigningKey # from pynacl package: `pip3 install pynacl` from nacl.encoding import RawEncoder import os.path diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c5713887b..98a21c7e3 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -354,6 +354,7 @@ fn build_hw_image( kernelkey_file.as_str(), "--kernel-output", xous_img_path.to_str().unwrap(), + // "--defile", ]).status()?; if !status.success() { return Err("kernel image sign failed".into())