rework SoC semver reporting to use xous-semver

This commit is contained in:
bunnie 2022-07-11 15:39:42 +08:00
parent 24c10dcfb2
commit af1013a1f3
8 changed files with 65 additions and 60 deletions

2
Cargo.lock generated
View file

@ -1900,6 +1900,7 @@ dependencies = [
"xous",
"xous-ipc 0.9.7",
"xous-names",
"xous-semver",
]
[[package]]
@ -3843,6 +3844,7 @@ dependencies = [
"xous",
"xous-ipc 0.9.7",
"xous-names",
"xous-semver",
]
[[package]]

View file

@ -23,6 +23,8 @@ num-derive = {version = "0.3.3", default-features = false}
num-traits = {version = "0.2.14", default-features = false}
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
xous-semver = "0.1.2"
[target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = {path = "../../utralib"}

View file

@ -3,6 +3,7 @@ use xous_ipc::Buffer;
use num_traits::{ToPrimitive, FromPrimitive};
use core::sync::atomic::Ordering;
use crate::api::*;
use xous_semver::SemVer;
use core::sync::atomic::AtomicU32;
static REFCOUNT: AtomicU32 = AtomicU32::new(0);
@ -284,18 +285,18 @@ impl Llio {
Err(xous::Error::InternalError)
}
}
pub fn soc_gitrev(&self) -> Result<(u8, u8, u8, u8, u32), xous::Error> {
pub fn soc_gitrev(&self) -> Result<SemVer, xous::Error> {
let response = send_message(self.conn,
Message::new_blocking_scalar(Opcode::InfoGit.to_usize().unwrap(), 0, 0, 0, 0))?;
if let xous::Result::Scalar2(val1, val2) = response {
Ok(
(
((val1 >> 24) as u8), // major
((val1 >> 16) as u8), // minor
((val1 >> 8) as u8), // rev
(val1 >> 0) as u8, // gitextra
val2 as u32 // gitrev
)
SemVer {
maj: (val1 >> 24) as u16,
min: (val1 >> 16) as u16,
rev: (val1 >> 8) as u16,
extra: (val1 >> 0) as u16,
commit: Some(val2 as u32),
}
)
} else {
log::error!("LLIO: unexpected return value: {:#?}", response);

View file

@ -182,8 +182,8 @@ impl CmdEnv {
//let memtest = Memtest::new(&xns, &mut common);
// print our version info
let (maj, min, rev, extra, gitrev) = common.llio.soc_gitrev().unwrap();
log::info!("SoC git rev {}.{}.{}+{} commit {:x}", maj, min, rev, extra, gitrev);
let soc_ver = common.llio.soc_gitrev().unwrap();
log::info!("SoC git rev {}", soc_ver.to_string());
log::info!("SoC DNA: 0x{:x}", common.llio.soc_dna().unwrap());
let (rev, dirty) = common.com.get_ec_git_rev().unwrap();
let dirtystr = if dirty { "dirty" } else { "clean" };

View file

@ -508,8 +508,8 @@ impl<'a> ShellCmdApi<'a> for Test {
}
}
write!(ret, "CHECK: was backlight on?\ndid keyboard vibrate?\nwas there sound?\n",).unwrap();
let (maj, min, rev, extra, gitrev) = env.llio.soc_gitrev().unwrap();
write!(ret, "Version {}.{}.{}+{}, commit {:x}\n", maj, min, rev, extra, gitrev).unwrap();
let soc_ver = env.llio.soc_gitrev().unwrap();
write!(ret, "Version {}\n", soc_ver.to_string()).unwrap();
log::info!("finished status update");
break;
}

View file

@ -31,9 +31,9 @@ impl<'a> ShellCmdApi<'a> for Ver {
write!(ret, "Wf200 fw rev {}.{}.{}", maj, min, rev).unwrap();
}
"soc" => {
let (maj, min, rev, extra, gitrev) = env.llio.soc_gitrev().unwrap();
write!(ret, "SoC git rev {}.{}.{}+{}, commit {:x}", maj, min, rev, extra, gitrev).unwrap();
log::info!("{}VER.SOC,{},{},{},{},{}", xous::BOOKEND_START, maj, min, rev, gitrev, xous::BOOKEND_END);
let soc_rev = env.llio.soc_gitrev().unwrap();
write!(ret, "SoC git rev {}", soc_rev.to_string()).unwrap();
log::info!("{}VER.SOC,{},{},{},{},{}", xous::BOOKEND_START, soc_rev.maj, soc_rev.min, soc_rev.rev, soc_rev.extra, xous::BOOKEND_END);
}
"dna" => {
write!(ret, "SoC silicon DNA: 0x{:x}", env.llio.soc_dna().unwrap()).unwrap();

View file

@ -22,6 +22,7 @@ modals = {path = "../modals"}
keyboard = {path = "../keyboard"}
bitfield = "0.13.2"
vcell = "0.1.3"
xous-semver = "0.1.2"
usbd-human-interface-device = "0.2.1"
embedded-time = "0.12.1" # required by the keyboard interface

View file

@ -29,6 +29,7 @@ use usbd_human_interface_device::device::fido::RawFidoMsg;
#[cfg(any(target_os = "none", target_os = "xous"))]
use usbd_human_interface_device::device::fido::RawFidoInterface;
use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
use xous_semver::SemVer;
use core::num::NonZeroU8;
use std::collections::BTreeMap;
@ -87,55 +88,53 @@ fn main() -> ! {
#[cfg(any(target_os = "none", target_os = "xous"))]
let serial_number = format!("{:x}", llio.soc_dna().unwrap());
let (maj, min, rev, extra, _gitrev) = llio.soc_gitrev().unwrap();
if maj == 0 && min <= 9 && rev <= 8 {
if (min == 9 && rev == 8 && extra < 20) ||
(min < 9) || (min == 9 && rev < 8) {
if min != 0 { // don't show during hosted mode, which reports 0.0.0+0
tt.sleep_ms(1500).ok(); // wait for some system boot to happen before popping up the modal
let modals = modals::Modals::new(&xns).unwrap();
modals.show_notification(
&format!("SoC version >= 0.9.8+20 required for USB HID. Detected rev: {}.{}.{}+{}. Refusing to start USB driver.",
maj, min, rev, extra
),
None
).unwrap();
}
let mut fido_listener: Option<xous::MessageEnvelope> = None;
loop {
let msg = xous::receive_message(usbdev_sid).unwrap();
match FromPrimitive::from_usize(msg.body.id()) {
Some(Opcode::DebugUsbOp) => msg_blocking_scalar_unpack!(msg, _update_req, _new_state, _, _, {
xous::return_scalar2(msg.sender, 0, 1).expect("couldn't return status");
}),
Some(Opcode::U2fRxDeferred) => {
// block any rx requests forever
fido_listener = Some(msg);
}
Some(Opcode::IsSocCompatible) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
xous::return_scalar(msg.sender, 0).expect("couldn't return compatibility status")
}),
Some(Opcode::Quit) => {
break;
}
_ => {
log::warn!("SoC not compatible with HID, ignoring USB message: {:?}", msg);
// make it so blocking scalars don't block
if let xous::Message::BlockingScalar(xous::ScalarMessage {
id: _,
arg1: _,
arg2: _,
arg3: _,
arg4: _,
}) = msg.body {
log::warn!("Returning bogus result");
xous::return_scalar(msg.sender, 0).unwrap();
}
let minimum_ver = SemVer {maj: 0, min: 9, rev: 8, extra: 20, commit: None};
let soc_ver = llio.soc_gitrev().unwrap();
if soc_ver < minimum_ver {
if soc_ver.min != 0 { // don't show during hosted mode, which reports 0.0.0+0
tt.sleep_ms(1500).ok(); // wait for some system boot to happen before popping up the modal
let modals = modals::Modals::new(&xns).unwrap();
modals.show_notification(
&format!("SoC version >= 0.9.8+20 required for USB HID. Detected rev: {}. Refusing to start USB driver.",
soc_ver.to_string()
),
None
).unwrap();
}
let mut fido_listener: Option<xous::MessageEnvelope> = None;
loop {
let msg = xous::receive_message(usbdev_sid).unwrap();
match FromPrimitive::from_usize(msg.body.id()) {
Some(Opcode::DebugUsbOp) => msg_blocking_scalar_unpack!(msg, _update_req, _new_state, _, _, {
xous::return_scalar2(msg.sender, 0, 1).expect("couldn't return status");
}),
Some(Opcode::U2fRxDeferred) => {
// block any rx requests forever
fido_listener = Some(msg);
}
Some(Opcode::IsSocCompatible) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
xous::return_scalar(msg.sender, 0).expect("couldn't return compatibility status")
}),
Some(Opcode::Quit) => {
break;
}
_ => {
log::warn!("SoC not compatible with HID, ignoring USB message: {:?}", msg);
// make it so blocking scalars don't block
if let xous::Message::BlockingScalar(xous::ScalarMessage {
id: _,
arg1: _,
arg2: _,
arg3: _,
arg4: _,
}) = msg.body {
log::warn!("Returning bogus result");
xous::return_scalar(msg.sender, 0).unwrap();
}
}
}
log::info!("consuming listener: {:?}", fido_listener);
}
log::info!("consuming listener: {:?}", fido_listener);
}
let usbdev = SpinalUsbDevice::new(usbdev_sid);