use litz_board::Chip;
use litz_engine::machine::{BootOptions, Images, boot};
const DIAGRAM: &str = r#"{"version":1,"parts":[
{"id":"pico2","type":"board-raspberry-pi-pico-2","attrs":{}},
{"id":"r1","type":"litz-resistor","attrs":{"value":"330"}},
{"id":"led1","type":"litz-led","attrs":{"color":"green"}}],
"connections":[
["pico2:GP15","r1:1","green",[]],
["r1:2","led1:A","green",[]],
["led1:C","pico2:GND.1","black",[]]]}"#;
#[test]
fn a_pico_2_diagram_boots_the_rp2350_backend() {
let firmware = litz_fixture::pico2_blink(15, 1);
let mut booted = boot(
DIAGRAM,
Images {
rom: &[],
bootloader: &[],
partition_table: &[],
app: &firmware,
},
&BootOptions::default(),
)
.expect("the pico 2 diagram boots");
assert_eq!(booted.chip.info().name, "rp2350");
booted.chip.run(4_000_000);
let console = String::from_utf8_lossy(&booted.chip.take_console()).into_owned();
assert!(console.contains("litz: pico2"), "{console:?}");
}
#[test]
fn a_riscv_pico_2_image_boots_the_same_backend_on_its_hazard3_sockets() {
let firmware = litz_fixture::pico2_blink_riscv(15, 1);
let mut booted = boot(
DIAGRAM,
Images {
rom: &[],
bootloader: &[],
partition_table: &[],
app: &firmware,
},
&BootOptions::default(),
)
.expect("the pico 2 diagram boots a RISC-V image");
assert_eq!(booted.chip.info().name, "rp2350");
booted.chip.run(4_000_000);
let console = String::from_utf8_lossy(&booted.chip.take_console()).into_owned();
assert!(console.contains("litz: pico2"), "{console:?}");
}