Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions crates/dsm-anchor-pico/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,18 @@ fn main() -> ! {
// ---- Phase 1: raw link probe ~3s while USB enumerates ----
let probe_until = timer.get_counter().ticks() + 3_000_000;
let mut last = timer.get_counter();
// What the chip last put on MISO for the raw probe: the halt below reports
// it, so a silent bus (all 0x00 or all 0xFF) reads apart from a chip that
// answers but is refused.
let mut probe_rx = [0u8; 4];
while timer.get_counter().ticks() < probe_until {
usb_dev.poll(&mut [&mut serial]);
if (timer.get_counter() - last).to_millis() >= 1000 {
last = timer.get_counter();
let mut rx = [0u8; 4];
let tx = [0xAAu8, 0, 0, 0];
let _ = spi_dev.transfer(&mut rx, &tx);
probe_rx = rx;
let _ = serial.flush();
}
}
Expand All @@ -493,14 +498,22 @@ fn main() -> ! {
let mut tropic = Tropic01::new(spi_dev);
let chip_id_hash = match tropic.get_info_chip_id() {
Ok(id) => anchor_core::hash::h("DSM/anchor/chip-id/v1", &[id]),
Err(_) => {
put(
&mut serial,
b"[T1] chip id: FAIL (no real identity; halting)\r\n",
Err(e) => {
// The halt names its cause, and repeats it: the banner is printed
// once at boot, before a phone or a Mac has attached to read it.
let why = alloc::format!(
"[T1] chip id: FAIL (no real identity; halting): {e:?}; raw probe MISO {probe_rx:?}\r\n"
);
put(&mut serial, why.as_bytes());
let _ = serial.flush();
let mut last = timer.get_counter();
loop {
usb_dev.poll(&mut [&mut serial]);
if (timer.get_counter() - last).to_millis() >= 2000 {
last = timer.get_counter();
put(&mut serial, why.as_bytes());
let _ = serial.flush();
}
}
}
};
Expand Down
Loading