mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
rework semver returns and fix flash verify bugs in COM
This commit is contained in:
parent
6e7798ff6c
commit
25e8da849e
3 changed files with 22 additions and 15 deletions
|
|
@ -23,7 +23,7 @@ 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.1"
|
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"}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ use xous_ipc::{String, Buffer};
|
||||||
use num_traits::{ToPrimitive, FromPrimitive};
|
use num_traits::{ToPrimitive, FromPrimitive};
|
||||||
|
|
||||||
pub use com_rs_ref::serdes::Ipv4Conf;
|
pub use com_rs_ref::serdes::Ipv4Conf;
|
||||||
|
use xous_semver::SemVer;
|
||||||
|
|
||||||
/// mapping of the callback function to the library user
|
/// mapping of the callback function to the library user
|
||||||
/// this exists in the library user's memory space, so we can have up to one
|
/// this exists in the library user's memory space, so we can have up to one
|
||||||
|
|
@ -136,17 +137,18 @@ impl Com {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// this is the rev of the firmware, as (maj, min, rev, +commit)
|
/// this is the rev of the firmware
|
||||||
pub fn get_ec_sw_tag(&self) -> Result<(u8, u8, u8, u8), Error> {
|
pub fn get_ec_sw_tag(&self) -> Result<SemVer, Error> {
|
||||||
let response = send_message(self.conn,
|
let response = send_message(self.conn,
|
||||||
Message::new_blocking_scalar(Opcode::EcSwTag.to_usize().unwrap(), 0, 0, 0, 0))?;
|
Message::new_blocking_scalar(Opcode::EcSwTag.to_usize().unwrap(), 0, 0, 0, 0))?;
|
||||||
if let xous::Result::Scalar1(rev) = response {
|
if let xous::Result::Scalar1(rev) = response {
|
||||||
Ok((
|
Ok(SemVer {
|
||||||
((rev >> 24) & 0xff) as u8,
|
maj: ((rev >> 24) & 0xff) as u16,
|
||||||
((rev >> 16) & 0xff) as u8,
|
min: ((rev >> 16) & 0xff) as u16,
|
||||||
((rev >> 8) & 0xff) as u8,
|
rev: ((rev >> 8) & 0xff) as u16,
|
||||||
((rev >> 0) & 0xff) as u8,
|
extra: ((rev >> 0) & 0xff) as u16,
|
||||||
))
|
commit: None,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
panic!("unexpected return value: {:#?}", response);
|
panic!("unexpected return value: {:#?}", response);
|
||||||
}
|
}
|
||||||
|
|
@ -426,8 +428,8 @@ impl Com {
|
||||||
};
|
};
|
||||||
let mut buf = Buffer::into_buf(flashop).or(Err(xous::Error::InternalError))?;
|
let mut buf = Buffer::into_buf(flashop).or(Err(xous::Error::InternalError))?;
|
||||||
buf.lend_mut(self.conn, Opcode::FlashOp.to_u32().unwrap()).expect("couldn't send flash program command");
|
buf.lend_mut(self.conn, Opcode::FlashOp.to_u32().unwrap()).expect("couldn't send flash program command");
|
||||||
let ret = buf.to_original::<api::FlashOp, _>().unwrap();
|
let ret = buf.to_original::<api::FlashRecord, _>().unwrap();
|
||||||
match ret {
|
match ret.op {
|
||||||
FlashOp::Verify(_a, d) => {
|
FlashOp::Verify(_a, d) => {
|
||||||
page.copy_from_slice(&d);
|
page.copy_from_slice(&d);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -640,6 +642,11 @@ impl Com {
|
||||||
rxlen = Some(maybe_rxlen as u16);
|
rxlen = Some(maybe_rxlen as u16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Trip an error if we had an invalid interrupt. This should force the caller
|
||||||
|
// to re-initialize the interrupt subsystem.
|
||||||
|
log::warn!("Invalid interrupt set");
|
||||||
|
return Err(xous::Error::Timeout);
|
||||||
}
|
}
|
||||||
mask_bit <<= 1;
|
mask_bit <<= 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -559,11 +559,11 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
com.txrx(ComState::FLASH_UNLOCK.verb);
|
com.txrx(ComState::FLASH_UNLOCK.verb);
|
||||||
},
|
},
|
||||||
api::FlashOp::Verify(&addr, data) => {
|
api::FlashOp::Verify(addr, data) => {
|
||||||
if ec_tag >= u32::from_be_bytes(ComState::FLASH_VERIFY.apilevel) {
|
if ec_tag >= u32::from_be_bytes(ComState::FLASH_VERIFY.apilevel) {
|
||||||
com.txrx(ComState::FLASH_VERIFY.verb);
|
com.txrx(ComState::FLASH_VERIFY.verb);
|
||||||
com.txrx((addr >> 16) as u16);
|
com.txrx((*addr >> 16) as u16);
|
||||||
com.txrx(addr as u16);
|
com.txrx(*addr as u16);
|
||||||
|
|
||||||
for word in data.chunks_mut(2) {
|
for word in data.chunks_mut(2) {
|
||||||
let read = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)).to_le_bytes();
|
let read = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT)).to_le_bytes();
|
||||||
|
|
@ -585,7 +585,7 @@ fn main() -> ! {
|
||||||
}
|
}
|
||||||
match flash_op.op {
|
match flash_op.op {
|
||||||
api::FlashOp::Verify(_a, data) => {
|
api::FlashOp::Verify(_a, data) => {
|
||||||
log::info!("verify returning {:x?}", &data[..32]);
|
log::debug!("verify returning {:x?}", &data[..32]);
|
||||||
buffer.replace(flash_op).expect("couldn't return result on FlashOp");
|
buffer.replace(flash_op).expect("couldn't return result on FlashOp");
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue