add code to dump the TRNG output via the DUART

gotta move on to other things, can't fully debug the USB
serial thing now. :-/
This commit is contained in:
bunnie 2024-06-16 02:07:33 +08:00
parent 28ab6ae311
commit d40e92b52d
2 changed files with 19 additions and 0 deletions

View file

@ -96,5 +96,6 @@ spi-alt-channel = []
irq-test = []
usb-test = []
trng-test = []
dump-trng = []
resume = [] # suspend/resume pathway code
default = ["board-bringup", "usb-test", "trng-test"]

View file

@ -289,6 +289,24 @@ impl SwapHal {
let mut trng = sce::trng::Trng::new(utralib::generated::HW_TRNG_BASE as usize);
trng.setup_raw_generation(32);
#[cfg(feature="dump-trng")]
{
let duart = utralib::generated::utra::duart::HW_DUART_BASE as *mut u32;
loop {
let d = trng.get_raw();
for b in d.to_le_bytes() {
unsafe {
while duart.add(utralib::generated::utra::duart::SFR_SR.offset()).read_volatile() != 0
{
}
duart
.add(utralib::generated::utra::duart::SFR_TXD.offset())
.write_volatile(b as char as u32);
}
}
}
}
// The first seed is always 0.
let mut seed = [0u8; 32];
// println!("seed: {:x?}", seed); // used to eyeball that things are working correctly