diff --git a/Cargo.lock b/Cargo.lock index 9131dc65a..10488ead8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5354,7 +5354,7 @@ dependencies = [ "xous-api-ticktimer", "xous-ipc 0.9.57 (registry+https://github.com/rust-lang/crates.io-index)", "xous-semver", - "xous-usb-hid 0.4.3 (git+https://github.com/betrusted-io/xous-usb-hid.git?branch=main)", + "xous-usb-hid", ] [[package]] @@ -5377,7 +5377,7 @@ dependencies = [ "xous-api-names", "xous-api-susres", "xous-api-ticktimer", - "xous-usb-hid 0.4.3 (git+https://github.com/betrusted-io/xous-usb-hid.git)", + "xous-usb-hid", ] [[package]] @@ -5560,7 +5560,7 @@ dependencies = [ "xous-api-susres", "xous-api-ticktimer", "xous-ipc 0.9.57 (registry+https://github.com/rust-lang/crates.io-index)", - "xous-usb-hid 0.4.3 (git+https://github.com/betrusted-io/xous-usb-hid.git)", + "xous-usb-hid", ] [[package]] @@ -6351,20 +6351,6 @@ dependencies = [ "usb-device", ] -[[package]] -name = "xous-usb-hid" -version = "0.4.3" -source = "git+https://github.com/betrusted-io/xous-usb-hid.git#eba35e886d08e504cf10026221aec0fbfc63e201" -dependencies = [ - "frunk", - "fugit", - "heapless 0.7.16", - "num_enum 0.6.1", - "option-block", - "packed_struct", - "usb-device", -] - [[package]] name = "xtask" version = "0.1.0" diff --git a/RELEASE-v0.9.md b/RELEASE-v0.9.md index 072d9f1a1..1b99701f3 100644 --- a/RELEASE-v0.9.md +++ b/RELEASE-v0.9.md @@ -467,6 +467,7 @@ perform the Xous firmware upgrade. This requires running manual update commands, - The repo has gone through a "flag day" where all the crates have been formatted, which means commits before the flag day may be more difficult to undo. The changes are committed on a crate-by-crate basis, so if something is really broken we can undo the formatting for the crate and add an exception to the rustfmt rules. - Implement #478: backlight should turn on automatically when a U2F/FIDO packet comes in from the host, allowing users in dark conditions to see the screen and know what they are approving. - the `sha2` API has been upgraded from 0.9.9 to 0.10.8. In the process of upgrading this, the `sha2` code is now domiciled in a fork of the `RustCrypto/hashes` repo. This should hopefully make tracking changes on RustCrypto somewhat easier, at the price of some difficulty in maintaining external crate pins (but I think that can be solved with some scripting). In the process of conversion, crates that depend on the 0.9.9 API for acceleration are now not accelerated. In particular, the ed25519-dalek signature check on the gateware at boot now runs with software SHA-512, which means that boot is much slower. This should be fixed before the release is live, but users testing the bleeding edge should be aware of this temporary regression in performance. +- @gsora has added the `hidapi` - apps can now register a HID descriptor for custom interactions over USB. See `apps/hidv2` for democumentation. ## Roadmap diff --git a/apps/hidv2/src/main.rs b/apps/hidv2/src/main.rs index 965907be3..c2e2ad01e 100644 --- a/apps/hidv2/src/main.rs +++ b/apps/hidv2/src/main.rs @@ -2,10 +2,11 @@ #![cfg_attr(target_os = "none", no_main)] use core::fmt::Write; +use std::sync::mpsc::{self, Receiver, Sender}; + use graphics_server::api::GlyphStyle; use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView}; use num_traits::*; -use std::sync::mpsc::{self, Receiver, Sender}; use usb_device_xous::UsbHid; pub(crate) const SERVER_NAME_HIDV2: &str = "_HIDv2_"; @@ -68,18 +69,9 @@ impl HIDv2Demo { .expect("Could not register GAM UX") .unwrap(); - let content = gam - .request_content_canvas(gam_token) - .expect("Could not get content canvas"); - let screensize = gam - .get_canvas_bounds(content) - .expect("Could not get canvas dimensions"); - Self { - gam, - _gam_token: gam_token, - content, - screensize, - } + let content = gam.request_content_canvas(gam_token).expect("Could not get content canvas"); + let screensize = gam.get_canvas_bounds(content).expect("Could not get canvas dimensions"); + Self { gam, _gam_token: gam_token, content, screensize } } /// Clear the entire screen. @@ -90,11 +82,7 @@ impl HIDv2Demo { Rectangle::new_with_style( Point::new(0, 0), self.screensize, - DrawStyle { - fill_color: Some(PixelColor::Light), - stroke_color: None, - stroke_width: 0, - }, + DrawStyle { fill_color: Some(PixelColor::Light), stroke_color: None, stroke_width: 0 }, ), ) .expect("can't clear content area"); @@ -123,9 +111,7 @@ impl HIDv2Demo { write!(text_view.text, "{}", "Echoing whatever on HID USB stack...") .expect("Could not write to text view"); - self.gam - .post_textview(&mut text_view) - .expect("Could not render text view"); + self.gam.post_textview(&mut text_view).expect("Could not render text view"); self.gam.redraw().expect("Could not redraw screen"); } } @@ -140,9 +126,7 @@ fn main() -> ! { let mut allow_redraw = true; // Register the server with xous - let sid = xns - .register_name(SERVER_NAME_HIDV2, None) - .expect("can't register server"); + let sid = xns.register_name(SERVER_NAME_HIDV2, None).expect("can't register server"); let mut hidv2_demo = HIDv2Demo::new(&xns, sid); @@ -201,11 +185,9 @@ fn start_hid_thread() -> Sender { let usbd = UsbHid::new(); - usbd.connect_hid_app(FIDO_REPORT_DESCRIPTOR.to_vec()) - .unwrap(); + usbd.connect_hid_app(FIDO_REPORT_DESCRIPTOR.to_vec()).unwrap(); - usbd.switch_to_core(usb_device_xous::UsbDeviceType::HIDv2) - .unwrap(); + usbd.switch_to_core(usb_device_xous::UsbDeviceType::HIDv2).unwrap(); std::thread::spawn(move || { loop { @@ -227,8 +209,7 @@ fn start_hid_thread() -> Sender { std::thread::sleep(std::time::Duration::from_millis(50)); } - usbd.switch_to_core(usb_device_xous::UsbDeviceType::Debug) - .unwrap(); + usbd.switch_to_core(usb_device_xous::UsbDeviceType::Debug).unwrap(); }); return tx; diff --git a/apps/vault/Cargo.toml b/apps/vault/Cargo.toml index 898488659..0619c8642 100644 --- a/apps/vault/Cargo.toml +++ b/apps/vault/Cargo.toml @@ -19,7 +19,7 @@ graphics-server = { path = "../../services/graphics-server" } locales = { path = "../../locales" } tts-frontend = { path = "../../services/tts" } usb-device-xous = { path = "../../services/usb-device-xous" } -xous-usb-hid = { git = "https://github.com/betrusted-io/xous-usb-hid.git" } +xous-usb-hid = { git = "https://github.com/betrusted-io/xous-usb-hid.git", branch = "main" } pddb = { path = "../../services/pddb" } modals = { path = "../../services/modals" } trng = { path = "../../services/trng" } diff --git a/publish.py b/publish.py index a7f1154c6..088fe5bb7 100644 --- a/publish.py +++ b/publish.py @@ -310,7 +310,7 @@ def main(): # small quirk: if you're doing a utralib update, just use -u only. # there is some order-sensitivity in how the dictionaries are accessed # but of course dictionaries are unordered. I think we need to re-do - # the specifier from a dictionary to an ordered list, to gurantee that + # the specifier from a dictionary to an ordered list, to guarantee that # publishing happens in the correct operation order. wet_cmd = ["cargo", "publish"] dry_cmd = ["cargo", "publish", "--dry-run", "--allow-dirty"] diff --git a/services/usb-device-xous/src/lib.rs b/services/usb-device-xous/src/lib.rs index 7ec658373..aa7c1e872 100644 --- a/services/usb-device-xous/src/lib.rs +++ b/services/usb-device-xous/src/lib.rs @@ -382,18 +382,18 @@ impl UsbHid { } /// Sets the userland application HID device descriptor. - /// It cannot be longer than 1024 bytes. + /// It cannot be longer than 1024 bytes. pub fn connect_hid_app(&self, descriptor: Vec) -> Result<(), xous::Error> { if descriptor.len() > MAX_HID_REPORT_DESCRIPTOR_LEN { - return Err(xous::Error::OutOfMemory) + return Err(xous::Error::OutOfMemory); } - let mut container = HIDReportDescriptorMessage{ + let mut container = HIDReportDescriptorMessage { descriptor: [0u8; MAX_HID_REPORT_DESCRIPTOR_LEN], len: descriptor.len(), - }; + }; - for (place, element) in container.descriptor.iter_mut().zip(descriptor.iter()) { + for (place, element) in container.descriptor.iter_mut().zip(descriptor.iter()) { *place = *element; } @@ -403,12 +403,12 @@ impl UsbHid { Ok(()) } - /// Unset the userland application HID device descriptor and discards the cached + /// Unset the userland application HID device descriptor and discards the cached /// reports. pub fn disconnect_hid_app(&self) -> Result<(), xous::Error> { - match send_message(self.conn, Message::new_blocking_scalar( - Opcode::HIDUnsetDescriptor.to_usize().unwrap(), - 0, 0, 0, 0) + match send_message( + self.conn, + Message::new_blocking_scalar(Opcode::HIDUnsetDescriptor.to_usize().unwrap(), 0, 0, 0, 0), ) { Ok(_) => Ok(()), Err(err) => Err(err), @@ -421,7 +421,7 @@ impl UsbHid { let mut buf = Buffer::into_buf(report).or(Err(xous::Error::InternalError))?; buf.lend_mut(self.conn, Opcode::HIDReadReport.to_u32().unwrap()).map(|_| ())?; - + let report = buf.as_flat::().unwrap(); match &report.data { @@ -433,8 +433,7 @@ impl UsbHid { } Ok(ret) - - }, + } rkyv::core_impl::ArchivedOption::None => Err(xous::Error::UnknownError), } } diff --git a/services/usb-device-xous/src/main.rs b/services/usb-device-xous/src/main.rs index 7c74a493c..9c3f4faa8 100644 --- a/services/usb-device-xous/src/main.rs +++ b/services/usb-device-xous/src/main.rs @@ -24,7 +24,7 @@ use spinal_udc::*; #[cfg(all(any(feature = "precursor", feature = "renode"), feature = "mass-storage"))] mod apps_block_device; -#[cfg(any(feature="precursor", feature="renode"))] +#[cfg(any(feature = "precursor", feature = "renode"))] mod hid; #[cfg(not(target_os = "xous"))] mod hosted; diff --git a/services/usb-test/Cargo.toml b/services/usb-test/Cargo.toml index c4bccf8ed..ef8581779 100644 --- a/services/usb-test/Cargo.toml +++ b/services/usb-test/Cargo.toml @@ -20,8 +20,8 @@ bitfield = "0.13.2" vcell = "0.1.3" utralib = { version = "0.1.24", optional = true, default-features = false } -xous-usb-hid = { git = "https://github.com/betrusted-io/xous-usb-hid.git" } -embedded-time = "0.12.1" # required by the keyboard interface +xous-usb-hid = { git = "https://github.com/betrusted-io/xous-usb-hid.git", branch = "main" } +embedded-time = "0.12.1" # required by the keyboard interface [dependencies.usb-device] # see top level Cargo.toml for patch.crates-io directive to help with dev work