mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
Merge branch 'main' into sigchat
This commit is contained in:
commit
2684a55888
11 changed files with 86 additions and 13 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
|
@ -642,11 +642,11 @@ dependencies = [
|
|||
"trng",
|
||||
"ureq",
|
||||
"url",
|
||||
"xous 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xous 0.9.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xous-api-log",
|
||||
"xous-api-names",
|
||||
"xous-api-ticktimer",
|
||||
"xous-ipc 0.9.54 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xous-ipc 0.9.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -4576,7 +4576,7 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
|
|||
[[package]]
|
||||
name = "smoltcp"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/smoltcp-rs/smoltcp.git?branch=main#9624adf20cbeaf627e907a87b4fdf74e8f3154fb"
|
||||
source = "git+https://github.com/smoltcp-rs/smoltcp.git?branch=main#e893a17fc761a9c1b34647ff09102993336cc341"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"byteorder",
|
||||
|
|
|
|||
|
|
@ -419,6 +419,12 @@ perform the Xous firmware upgrade. This requires running manual update commands,
|
|||
- usbd-human-interface-device bumped to latest in preparation for a fork
|
||||
- Fix #446 - add support for numeric-only passwords in `vault`
|
||||
- Fork usbd-human-interface-device to xous-usb-hid
|
||||
- Harden EC against power glitches during updates (requires EC update - do not plug or unplug USB during an update until this patch is finished updating)
|
||||
- Some housekeeping on the Xous wiki. Much more work is needed.
|
||||
- Delay PDDB mount dialogs until all update checks are completed. This is done with a call named `is_ec_ready` and `set_ec_ready` in the `llio`. Nominally, it can be set/unset to indicate if the EC is going into an update state. Initially it is unset, and it is set by the status loop once all the update activities are completed. But it could be set later on by a routine that manually initiates EC updates (although there is no sanctioned way to do that at the moment).
|
||||
- Fix validator to accept `tz_offset` == 0 as valid.
|
||||
- Rust 1.74 rolled out. Xous now has much more native `std` support in mainline Rust, thanks to a huge effort by @xobs
|
||||
- Fix regressions in libstd `lend_impl` and PDDB `WriteKeyStd`
|
||||
|
||||
## Roadmap
|
||||
- Lots of testing and bug fixes
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ The tls handshake involves the host offering the client a Certificate signed for
|
|||
|
||||
It does not seem in keeping with the Precursor/Xous idea to ask users to trust any such list of Root CA Certificates.
|
||||
|
||||
This tls library enables the user to obtain and save trusted CA certificates to the PDDB as a personalised set of trusted Root CA certificates on which to establish a tls connection. This can be as simple for the user as responding to a modal, when making a first connection to an as yet un-trusted host. Just a couple of clicks. The developer need only call `Tls::trust_modal()`.
|
||||
This tls library enables the user to obtain and save trusted CA certificates to the PDDB as a personalised set of trusted Root CA certificates on which to establish a tls connection. This can be as simple for the user as responding to a modal, when making a first connection to an as yet un-trusted host. Just a couple of clicks. The developer need only call `Tls::check_trust()`.
|
||||
|
||||
Note that hosts with self-signed Certificates may be probed and trusted (e.g. [chat.signal.org](https://chat.signal.org))
|
||||
|
||||
A small set of shellchat commands are included to enact the base functionality:
|
||||
|
||||
- `net tls probe <host>` will initiate a modified tls handshake with `<host>`, obtain the certificate chain offered by `<host>`, and immediately terminate the connection. A call to Tls::trust_modal() will present the CA certificate chain in a modal to be individually selected and saved to PDDB if trusted.
|
||||
- `net tls probe <host>` will initiate a modified tls handshake with `<host>`, obtain the certificate chain offered by `<host>`, and immediately terminate the connection. A call to Tls::check_trust() will present the CA certificate chain in a modal to be individually selected and saved to PDDB if trusted.
|
||||
- `net tls test <host>` will attempt a normal tls handshake with `<host>` based on the trusted Root CA certificates in the PDDB. If the connection is successful, then a simple `get` is emitted, the response accepted, and the connection closed.
|
||||
- `net tls mozilla` trusts and saves all Root CA's in the [webpki-roots crate](https://crates.io/crates/webpki-roots) - which contains Mozilla's root certificates. (requires `--feature rootCA`)
|
||||
- `net list` lists all trusted certificates in the PDDB
|
||||
|
|
|
|||
|
|
@ -321,9 +321,10 @@ pub fn start_time_server() {
|
|||
start_rtc_secs as i64 * 1000i64
|
||||
+ (tt.elapsed_ms() - start_tt_ms) as i64;
|
||||
log::debug!("hw only UTC ms {}", t);
|
||||
// NOTE: endian swap for compatibility with `std`
|
||||
xous::return_scalar2(msg.sender,
|
||||
(((t as u64) >> 32) & 0xFFFF_FFFF) as usize,
|
||||
(t as u64 & 0xFFFF_FFFF) as usize,
|
||||
(((t as u64) >> 32) & 0xFFFF_FFFF) as usize,
|
||||
).expect("couldn't respond to GetUtcTimeMs");
|
||||
}),
|
||||
Some(TimeOp::GetLocalTimeMs) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||
|
|
@ -398,9 +399,10 @@ pub fn start_time_server() {
|
|||
utc_offset_ms = 0;
|
||||
}
|
||||
log::trace!("utc ms {}", t);
|
||||
// NOTE: endian swap for compatibility with `std`
|
||||
xous::return_scalar2(msg.sender,
|
||||
(((t as u64) >> 32) & 0xFFFF_FFFF) as usize,
|
||||
(t as u64 & 0xFFFF_FFFF) as usize,
|
||||
(((t as u64) >> 32) & 0xFFFF_FFFF) as usize,
|
||||
).expect("couldn't respond to GetUtcTimeMs");
|
||||
}),
|
||||
Some(TimeOp::GetLocalTimeMs) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||
|
|
@ -456,7 +458,7 @@ pub fn start_time_server() {
|
|||
}
|
||||
}),
|
||||
Some(TimeOp::WallClockTimeInit) => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||
if utc_offset_ms == 0 || tz_offset_ms == 0 {
|
||||
if utc_offset_ms == 0 {
|
||||
xous::return_scalar(msg.sender, 0).unwrap();
|
||||
} else {
|
||||
xous::return_scalar(msg.sender, 1).unwrap();
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ pub(crate) enum Opcode {
|
|||
AdcGpio5,
|
||||
AdcGpio2,
|
||||
|
||||
/// partially tested -- events
|
||||
/// events
|
||||
EventComSubscribe, //(String<64>),
|
||||
//EventRtcSubscribe, //(String<64>),
|
||||
EventUsbAttachSubscribe, //(String<64>),
|
||||
|
|
@ -113,6 +113,11 @@ pub(crate) enum Opcode {
|
|||
EventUsbAttachEnable, //(bool),
|
||||
EventActivityHappened,
|
||||
|
||||
/// Set EC status is ready
|
||||
EventEcSetReady,
|
||||
/// Query if EC status is ready
|
||||
EventEcIsReady,
|
||||
|
||||
/// internal from handler to main loop
|
||||
EventComHappened,
|
||||
//EventRtcHappened,
|
||||
|
|
|
|||
|
|
@ -190,6 +190,26 @@ impl Llio {
|
|||
Message::new_scalar(Opcode::EventComEnable.to_usize().unwrap(), arg, 0, 0, 0)
|
||||
).map(|_| ())
|
||||
}
|
||||
/// Called by the updater routine when EC is ready to run. Note: no authenticity check is done, anyone
|
||||
/// could call this and troll the system.
|
||||
pub fn set_ec_ready(&self, ready: bool) {
|
||||
send_message(self.conn,
|
||||
Message::new_scalar(Opcode::EventEcSetReady.to_usize().unwrap(), if ready {1} else {0}, 0, 0, 0)
|
||||
).unwrap();
|
||||
}
|
||||
/// Used to poll if the EC has been set as ready by the updating routine. Domiciled in the LLIO because
|
||||
/// this crate is already depended upon by most crates that need to poll this status, and we'd rather not
|
||||
/// expose the COM directly to generic crates.
|
||||
pub fn is_ec_ready(&self) -> bool {
|
||||
let response = send_message(self.conn,
|
||||
Message::new_blocking_scalar(Opcode::EventEcIsReady.to_usize().unwrap(), 0, 0, 0, 0)).unwrap();
|
||||
if let xous::Result::Scalar1(val) = response {
|
||||
val != 0
|
||||
} else {
|
||||
log::error!("LLIO: unexpected return value: {:#?}", response);
|
||||
false
|
||||
}
|
||||
}
|
||||
/// GPIO IRQ hook. When using this, ensure that the WFI power saving mode is turned off.
|
||||
/// Otherwise interrupts that hit during power save mode can be missed.
|
||||
pub fn hook_gpio_event_callback(&mut self, id: u32, cid: CID) -> Result<(), xous::Error> {
|
||||
|
|
|
|||
|
|
@ -285,6 +285,12 @@ fn main() -> ! {
|
|||
let mut i2c = llio::I2c::new(&xns);
|
||||
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
||||
|
||||
// a variable to track if the EC has been registered as ready. This should be set by a call from
|
||||
// whatever handles the EC updating routine: it is responsible for checking if the EC is up to date,
|
||||
// and once it is brought into an up to date state, it then sets this variable. That routine is
|
||||
// nominally domiciled in the status server.
|
||||
let mut ec_ready = false;
|
||||
|
||||
log::debug!("starting main loop");
|
||||
loop {
|
||||
let msg = xous::receive_message(llio_sid).unwrap();
|
||||
|
|
@ -507,6 +513,12 @@ fn main() -> ! {
|
|||
latest_activity %= period;
|
||||
}
|
||||
}),
|
||||
Some(Opcode::EventEcSetReady) => msg_scalar_unpack!(msg, ready, _, _, _, {
|
||||
ec_ready = ready != 0;
|
||||
}),
|
||||
Some(Opcode::EventEcIsReady) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||
xous::return_scalar(msg.sender, if ec_ready {1} else {0}).ok();
|
||||
}),
|
||||
Some(Opcode::SetWakeupAlarm) => msg_blocking_scalar_unpack!(msg, delay, _, _, _, {
|
||||
if delay > u8::MAX as usize {
|
||||
log::error!("Wakeup must be no longer than {} secs in the future", u8::MAX);
|
||||
|
|
|
|||
|
|
@ -632,8 +632,9 @@ fn wrapped_main() -> ! {
|
|||
Opcode::SuspendResume as u32, my_cid).expect("couldn't create suspend/resume object");
|
||||
loop {
|
||||
let mut msg = xous::receive_message(pddb_sid).unwrap();
|
||||
// log::error!("got msg: {:x?}", msg);
|
||||
match FromPrimitive::from_usize(msg.body.id() & 0xffff).unwrap_or(Opcode::InvalidOpcode) {
|
||||
let op: Opcode = FromPrimitive::from_usize(msg.body.id() & 0xffff).unwrap_or(Opcode::InvalidOpcode);
|
||||
log::debug!("{:x?}", op);
|
||||
match op {
|
||||
Opcode::SuspendResume => xous::msg_scalar_unpack!(msg, token, _, _, _, {
|
||||
basis_cache.suspend(&mut pddb_os);
|
||||
susres.suspend_until_resume(token).expect("couldn't execute suspend/resume");
|
||||
|
|
@ -672,6 +673,12 @@ fn wrapped_main() -> ! {
|
|||
// - code = 2 -> mount failed, because too many PINs were retried. `count` is the number of retries.
|
||||
// If we need more nuance out of this routine, consider creating a custom public enum type to help marshall this.
|
||||
Opcode::TryMount => xous::msg_blocking_scalar_unpack!(msg, _, _, _, _, {
|
||||
let llio = llio::Llio::new(&xns);
|
||||
while !llio.is_ec_ready() {
|
||||
// spin-wait while the EC is not ready -- so that a PDDB mount does not interfere with
|
||||
// on-going EC updates. Also causes the mount dialog to delay until the EC status has been checked.
|
||||
tt.sleep_ms(1000).ok();
|
||||
}
|
||||
if basis_cache.basis_count() > 0 {
|
||||
xous::return_scalar2(msg.sender, 0, 0).expect("couldn't return scalar");
|
||||
} else {
|
||||
|
|
@ -1728,7 +1735,8 @@ fn wrapped_main() -> ! {
|
|||
Opcode::SeekKeyStd => {
|
||||
let fd = (msg.body.id() >> 16) & 0xffff;
|
||||
if let Some(scalar) = msg.body.scalar_message() {
|
||||
let seek_by = (((scalar.arg2 as u32) as u64) << 32) | ((scalar.arg3 as u32) as u64);
|
||||
// NOTE: endian swap for compatibility with `std`
|
||||
let seek_by = (((scalar.arg3 as u32) as u64) << 32) | ((scalar.arg2 as u32) as u64);
|
||||
let result = libstd::seek_key(scalar.arg1, seek_by, fd_mapping.entry(msg.sender.pid()).or_default(), fd);
|
||||
if msg.body.is_blocking() {
|
||||
match result {
|
||||
|
|
|
|||
|
|
@ -1099,6 +1099,23 @@ impl<'a> ShellCmdApi<'a> for PddbCmd {
|
|||
write!(ret, "fscb test failed").ok();
|
||||
}
|
||||
}
|
||||
"seektest" => {
|
||||
use std::fs::OpenOptions;
|
||||
std::fs::create_dir_all("testdict").expect("couldn't set up test directory");
|
||||
let mut file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(true)
|
||||
.open("testdict:seek")
|
||||
.expect("couldn't open/create testdict:seek");
|
||||
let test_data: [u8; 8] = [10, 10, 10, 10, 5, 6, 20, 24];
|
||||
file.write_all(&test_data).expect("couldn't write test data");
|
||||
file.seek(SeekFrom::Start(4)).expect("couldn't seek");
|
||||
let mut check = [0u8; 4];
|
||||
file.read(&mut check).expect("couldn't read back check data");
|
||||
log::info!("check data: {:?}", check);
|
||||
assert!(check == test_data[4..]);
|
||||
}
|
||||
// note that this feature only works in hosted mode
|
||||
#[cfg(feature="pddbtest")]
|
||||
"test" => {
|
||||
|
|
|
|||
|
|
@ -616,6 +616,8 @@ fn wrapped_main() -> ! {
|
|||
if soc_updated {
|
||||
log::info!("Soc update was triggered, UX flow should be running now...");
|
||||
}
|
||||
// now that all the auto-update interaction is done, set the EC is ready flag
|
||||
llio.set_ec_ready(true);
|
||||
// now that all the auto-update interaction is done, exit the gutter server. From
|
||||
// this point forward, messages will pile up in the status queue, until the main loop starts.
|
||||
send_message(cb_cid, Message::new_blocking_scalar(
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ impl PrefHandler for DevicePrefs {
|
|||
true
|
||||
}
|
||||
_ => {
|
||||
log::error!("Got unknown message: {}", op);
|
||||
// this is "expected" - options that don't match here are matched down below.
|
||||
log::info!("Got unknown message: {}, passing to next handler.", op);
|
||||
false
|
||||
}
|
||||
} {
|
||||
|
|
|
|||
Loading…
Reference in a new issue