diff --git a/bao1x-boot/boot1/src/repl.rs b/bao1x-boot/boot1/src/repl.rs index 8de0130b8..e10d31f13 100644 --- a/bao1x-boot/boot1/src/repl.rs +++ b/bao1x-boot/boot1/src/repl.rs @@ -458,6 +458,16 @@ impl Repl { crate::println!("Boot1 has no valid signature, lockdown would brick the chip.") } }, + "self_destruct" => { + if !matches!(args.as_slice(), [s] if s == "void_my_warrantee") { + return Err(Error::help( + "Usage: 'self_destruct void_my_warrantee'. This PERMANENTLY wipes the chip and bricks it. No returns or exchanges are allowed after executing this command.", + )); + } + let mut rram = bao1x_hal::rram::Reram::new(); + unsafe { rram.self_destruct() } + // ... and all was null and void! + } "baosec-init" => { if !matches!(args.as_slice(), [s] if s == "confirm") { return Err(Error::help( @@ -645,7 +655,7 @@ impl Repl { _ => { crate::println!("Command not recognized: {}", cmd); crate::print!( - "Commands include: reset, echo, altboot, boot, bootwait, idmode, localecho, uf2, boardtype, audit, lockdown, paranoid" + "Commands include: reset, echo, altboot, boot, bootwait, idmode, localecho, uf2, boardtype, audit, lockdown, paranoid, self_destruct" ); #[cfg(feature = "test-boot0-keys")] crate::print!(", publock"); diff --git a/libs/bao1x-hal/src/rram.rs b/libs/bao1x-hal/src/rram.rs index 5a1e7e29e..d32207a29 100644 --- a/libs/bao1x-hal/src/rram.rs +++ b/libs/bao1x-hal/src/rram.rs @@ -164,6 +164,13 @@ impl<'a> Reram { rram } + /// This is unsafe because it erases the entire system. Only call this if you want to self destruct. + pub unsafe fn self_destruct(&mut self) -> ! { + self.csr.wo(utra::rrc::SFR_RRCAR, 0x2468); + // busy-wait the CPU so that the suicide flow can complete. There is no return. + loop {} + } + #[cfg(feature = "std")] /// `base` specifies the actual offset from the beginning of the RRAM array /// to where this range maps to. This is necessary because `range` is virtually