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",
"xous-ipc 0.9.7", "xous-ipc 0.9.7",
"xous-names", "xous-names",
"xous-semver",
] ]
[[package]] [[package]]
@ -3843,6 +3844,7 @@ dependencies = [
"xous", "xous",
"xous-ipc 0.9.7", "xous-ipc 0.9.7",
"xous-names", "xous-names",
"xous-semver",
] ]
[[package]] [[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} num-traits = {version = "0.2.14", default-features = false}
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]} rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
xous-semver = "0.1.2"
[target.'cfg(not(any(windows,unix)))'.dependencies] [target.'cfg(not(any(windows,unix)))'.dependencies]
utralib = {path = "../../utralib"} utralib = {path = "../../utralib"}

View file

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

View file

@ -182,8 +182,8 @@ impl CmdEnv {
//let memtest = Memtest::new(&xns, &mut common); //let memtest = Memtest::new(&xns, &mut common);
// print our version info // print our version info
let (maj, min, rev, extra, gitrev) = common.llio.soc_gitrev().unwrap(); let soc_ver = common.llio.soc_gitrev().unwrap();
log::info!("SoC git rev {}.{}.{}+{} commit {:x}", maj, min, rev, extra, gitrev); log::info!("SoC git rev {}", soc_ver.to_string());
log::info!("SoC DNA: 0x{:x}", common.llio.soc_dna().unwrap()); log::info!("SoC DNA: 0x{:x}", common.llio.soc_dna().unwrap());
let (rev, dirty) = common.com.get_ec_git_rev().unwrap(); let (rev, dirty) = common.com.get_ec_git_rev().unwrap();
let dirtystr = if dirty { "dirty" } else { "clean" }; 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(); 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(); let soc_ver = env.llio.soc_gitrev().unwrap();
write!(ret, "Version {}.{}.{}+{}, commit {:x}\n", maj, min, rev, extra, gitrev).unwrap(); write!(ret, "Version {}\n", soc_ver.to_string()).unwrap();
log::info!("finished status update"); log::info!("finished status update");
break; break;
} }

View file

@ -31,9 +31,9 @@ impl<'a> ShellCmdApi<'a> for Ver {
write!(ret, "Wf200 fw rev {}.{}.{}", maj, min, rev).unwrap(); write!(ret, "Wf200 fw rev {}.{}.{}", maj, min, rev).unwrap();
} }
"soc" => { "soc" => {
let (maj, min, rev, extra, gitrev) = env.llio.soc_gitrev().unwrap(); let soc_rev = env.llio.soc_gitrev().unwrap();
write!(ret, "SoC git rev {}.{}.{}+{}, commit {:x}", maj, min, rev, extra, gitrev).unwrap(); write!(ret, "SoC git rev {}", soc_rev.to_string()).unwrap();
log::info!("{}VER.SOC,{},{},{},{},{}", xous::BOOKEND_START, maj, min, rev, gitrev, xous::BOOKEND_END); log::info!("{}VER.SOC,{},{},{},{},{}", xous::BOOKEND_START, soc_rev.maj, soc_rev.min, soc_rev.rev, soc_rev.extra, xous::BOOKEND_END);
} }
"dna" => { "dna" => {
write!(ret, "SoC silicon DNA: 0x{:x}", env.llio.soc_dna().unwrap()).unwrap(); 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"} keyboard = {path = "../keyboard"}
bitfield = "0.13.2" bitfield = "0.13.2"
vcell = "0.1.3" vcell = "0.1.3"
xous-semver = "0.1.2"
usbd-human-interface-device = "0.2.1" usbd-human-interface-device = "0.2.1"
embedded-time = "0.12.1" # required by the keyboard interface 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"))] #[cfg(any(target_os = "none", target_os = "xous"))]
use usbd_human_interface_device::device::fido::RawFidoInterface; use usbd_human_interface_device::device::fido::RawFidoInterface;
use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack}; use xous::{msg_scalar_unpack, msg_blocking_scalar_unpack};
use xous_semver::SemVer;
use core::num::NonZeroU8; use core::num::NonZeroU8;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -87,55 +88,53 @@ fn main() -> ! {
#[cfg(any(target_os = "none", target_os = "xous"))] #[cfg(any(target_os = "none", target_os = "xous"))]
let serial_number = format!("{:x}", llio.soc_dna().unwrap()); let serial_number = format!("{:x}", llio.soc_dna().unwrap());
let (maj, min, rev, extra, _gitrev) = llio.soc_gitrev().unwrap(); let minimum_ver = SemVer {maj: 0, min: 9, rev: 8, extra: 20, commit: None};
if maj == 0 && min <= 9 && rev <= 8 { let soc_ver = llio.soc_gitrev().unwrap();
if (min == 9 && rev == 8 && extra < 20) || if soc_ver < minimum_ver {
(min < 9) || (min == 9 && rev < 8) { if soc_ver.min != 0 { // don't show during hosted mode, which reports 0.0.0+0
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
tt.sleep_ms(1500).ok(); // wait for some system boot to happen before popping up the modal let modals = modals::Modals::new(&xns).unwrap();
let modals = modals::Modals::new(&xns).unwrap(); modals.show_notification(
modals.show_notification( &format!("SoC version >= 0.9.8+20 required for USB HID. Detected rev: {}. Refusing to start USB driver.",
&format!("SoC version >= 0.9.8+20 required for USB HID. Detected rev: {}.{}.{}+{}. Refusing to start USB driver.", soc_ver.to_string()
maj, min, rev, extra ),
), None
None ).unwrap();
).unwrap(); }
} let mut fido_listener: Option<xous::MessageEnvelope> = None;
let mut fido_listener: Option<xous::MessageEnvelope> = None; loop {
loop { let msg = xous::receive_message(usbdev_sid).unwrap();
let msg = xous::receive_message(usbdev_sid).unwrap(); match FromPrimitive::from_usize(msg.body.id()) {
match FromPrimitive::from_usize(msg.body.id()) { Some(Opcode::DebugUsbOp) => msg_blocking_scalar_unpack!(msg, _update_req, _new_state, _, _, {
Some(Opcode::DebugUsbOp) => msg_blocking_scalar_unpack!(msg, _update_req, _new_state, _, _, { xous::return_scalar2(msg.sender, 0, 1).expect("couldn't return status");
xous::return_scalar2(msg.sender, 0, 1).expect("couldn't return status"); }),
}), Some(Opcode::U2fRxDeferred) => {
Some(Opcode::U2fRxDeferred) => { // block any rx requests forever
// block any rx requests forever fido_listener = Some(msg);
fido_listener = Some(msg); }
} Some(Opcode::IsSocCompatible) => msg_blocking_scalar_unpack!(msg, _, _, _, _, {
Some(Opcode::IsSocCompatible) => msg_blocking_scalar_unpack!(msg, _, _, _, _, { xous::return_scalar(msg.sender, 0).expect("couldn't return compatibility status")
xous::return_scalar(msg.sender, 0).expect("couldn't return compatibility status") }),
}), Some(Opcode::Quit) => {
Some(Opcode::Quit) => { break;
break; }
} _ => {
_ => { log::warn!("SoC not compatible with HID, ignoring USB message: {:?}", msg);
log::warn!("SoC not compatible with HID, ignoring USB message: {:?}", msg); // make it so blocking scalars don't block
// make it so blocking scalars don't block if let xous::Message::BlockingScalar(xous::ScalarMessage {
if let xous::Message::BlockingScalar(xous::ScalarMessage { id: _,
id: _, arg1: _,
arg1: _, arg2: _,
arg2: _, arg3: _,
arg3: _, arg4: _,
arg4: _, }) = msg.body {
}) = msg.body { log::warn!("Returning bogus result");
log::warn!("Returning bogus result"); xous::return_scalar(msg.sender, 0).unwrap();
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); let usbdev = SpinalUsbDevice::new(usbdev_sid);