Skip to content

Commit

Permalink
Merge pull request betrusted-io#497 from betrusted-io/readme
Browse files Browse the repository at this point in the history
bump release notes with latest PR
  • Loading branch information
bunnie authored Feb 1, 2024
2 parents c3ff947 + 053c55c commit 3885596
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 64 deletions.
20 changes: 3 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions RELEASE-v0.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 11 additions & 30 deletions apps/hidv2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_";
Expand Down Expand Up @@ -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.
Expand All @@ -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");
Expand Down Expand Up @@ -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");
}
}
Expand All @@ -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);

Expand Down Expand Up @@ -201,11 +185,9 @@ fn start_hid_thread() -> Sender<bool> {

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 {
Expand All @@ -227,8 +209,7 @@ fn start_hid_thread() -> Sender<bool> {
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;
Expand Down
2 changes: 1 addition & 1 deletion apps/vault/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
23 changes: 11 additions & 12 deletions services/usb-device-xous/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>) -> 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;
}

Expand All @@ -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),
Expand All @@ -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::<HIDReportMessage, _>().unwrap();

match &report.data {
Expand All @@ -433,8 +433,7 @@ impl UsbHid {
}

Ok(ret)

},
}
rkyv::core_impl::ArchivedOption::None => Err(xous::Error::UnknownError),
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/usb-device-xous/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions services/usb-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3885596

Please sign in to comment.