mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
add routines for manipulating and using the serial numbers in boot1 context
This commit is contained in:
parent
aaf1cbd2f9
commit
137c70a629
3 changed files with 25 additions and 4 deletions
|
|
@ -126,10 +126,13 @@ pub fn get_descriptor_request(this: &mut CorigineUsb, value: u16, _index: usize,
|
||||||
ep0_buf[..4].copy_from_slice(&[4, USB_DT_STRING, 9, 4]);
|
ep0_buf[..4].copy_from_slice(&[4, USB_DT_STRING, 9, 4]);
|
||||||
4
|
4
|
||||||
} else {
|
} else {
|
||||||
|
let owc = bao1x_hal::acram::OneWayCounter::new();
|
||||||
|
let slot_mgr = bao1x_hal::acram::SlotManager::new();
|
||||||
|
let sn = bao1x_hal::usb::derive_usb_serial_number(&owc, &slot_mgr);
|
||||||
let s = match id {
|
let s = match id {
|
||||||
1 => MANUFACTURER,
|
1 => MANUFACTURER,
|
||||||
2 => PRODUCT,
|
2 => PRODUCT,
|
||||||
_ => SERIAL,
|
_ => &sn,
|
||||||
};
|
};
|
||||||
let slen = 2 + s.len() * 2;
|
let slen = 2 + s.len() * 2;
|
||||||
ep0_buf[0] = slen as u8;
|
ep0_buf[0] = slen as u8;
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,6 @@ const VENDOR_ID: u16 = 0x1209;
|
||||||
const PRODUCT_ID: u16 = 0x3613; // this needs to change! this is the Precursor product ID.
|
const PRODUCT_ID: u16 = 0x3613; // this needs to change! this is the Precursor product ID.
|
||||||
const MANUFACTURER: &'static str = "Baochip";
|
const MANUFACTURER: &'static str = "Baochip";
|
||||||
const PRODUCT: &'static str = "Dabao";
|
const PRODUCT: &'static str = "Dabao";
|
||||||
// no seriously, do this
|
|
||||||
const SERIAL: &'static str = "TODO";
|
|
||||||
|
|
||||||
impl DeviceDescriptor {
|
impl DeviceDescriptor {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,22 @@ impl Repl {
|
||||||
return Err(Error::help("altboot [toggle]"));
|
return Err(Error::help("altboot [toggle]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"idmode" => {
|
||||||
|
let owc = OneWayCounter::new();
|
||||||
|
if args.len() == 0 {
|
||||||
|
crate::println!("ID mode is: {:?}", owc.get_decoded::<ExternalIdentifiers>());
|
||||||
|
self.abort_cmd();
|
||||||
|
return Ok(());
|
||||||
|
} else if args.len() != 1 {
|
||||||
|
return Err(Error::help("idmode [toggle]"));
|
||||||
|
}
|
||||||
|
if args[0] == "toggle" {
|
||||||
|
owc.inc_coded::<ExternalIdentifiers>().unwrap();
|
||||||
|
crate::println!("ID mode is now: {:?}", owc.get_decoded::<ExternalIdentifiers>());
|
||||||
|
} else {
|
||||||
|
return Err(Error::help("idmode [toggle]"));
|
||||||
|
}
|
||||||
|
}
|
||||||
"audit" => {
|
"audit" => {
|
||||||
let owc = OneWayCounter::new();
|
let owc = OneWayCounter::new();
|
||||||
let boardtype = owc.get_decoded::<BoardTypeCoding>().unwrap();
|
let boardtype = owc.get_decoded::<BoardTypeCoding>().unwrap();
|
||||||
|
|
@ -261,6 +277,10 @@ impl Repl {
|
||||||
u32::from_le_bytes(sn[4..8].try_into().unwrap()),
|
u32::from_le_bytes(sn[4..8].try_into().unwrap()),
|
||||||
u32::from_le_bytes(sn[..4].try_into().unwrap())
|
u32::from_le_bytes(sn[..4].try_into().unwrap())
|
||||||
);
|
);
|
||||||
|
crate::println!(
|
||||||
|
"Public serial number: {}",
|
||||||
|
bao1x_hal::usb::derive_usb_serial_number(&owc, &slot_mgr)
|
||||||
|
);
|
||||||
crate::println!("Revocations:");
|
crate::println!("Revocations:");
|
||||||
crate::println!("Stage key0 key1 key2 key3");
|
crate::println!("Stage key0 key1 key2 key3");
|
||||||
let key_array = [
|
let key_array = [
|
||||||
|
|
@ -517,7 +537,7 @@ impl Repl {
|
||||||
_ => {
|
_ => {
|
||||||
crate::println!("Command not recognized: {}", cmd);
|
crate::println!("Command not recognized: {}", cmd);
|
||||||
crate::print!(
|
crate::print!(
|
||||||
"Commands include: reset, echo, altboot, boot, bootwait, localecho, uf2, boardtype, audit, lockdown"
|
"Commands include: reset, echo, altboot, boot, bootwait, idmode, localecho, uf2, boardtype, audit, lockdown"
|
||||||
);
|
);
|
||||||
#[cfg(feature = "test-boot0-keys")]
|
#[cfg(feature = "test-boot0-keys")]
|
||||||
crate::print!(", publock");
|
crate::print!(", publock");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue