Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2267dd0bab | |||
| fbf741e589 | |||
| ee41d245c8 | |||
| d32e99f6a5 | |||
| 55c815fa5e |
@@ -11,7 +11,7 @@ rustflags = [
|
||||
# If this is not enabled, debugging / stepping can become problematic.
|
||||
"-Cforce-frame-pointers=yes",
|
||||
# Can be useful for debugging.
|
||||
# "-Clink-args=-Map=app.map"
|
||||
"-Clink-args=-Map=app.map"
|
||||
]
|
||||
|
||||
[build]
|
||||
|
||||
@@ -9,7 +9,7 @@ repository = "https://egit.irs.uni-stuttgart.de/rust/zynq7000-rs"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
aarch32-cpu = { version = "0.1" }
|
||||
aarch32-cpu = { version = "0.1", features = ["critical-section-single-core"] }
|
||||
zynq7000-rt = { path = "../../zynq7000-rt" }
|
||||
zynq7000 = { path = "../../zynq7000" }
|
||||
zynq7000-hal = { path = "../../zynq7000-hal", features = ["defmt"] }
|
||||
|
||||
@@ -3,8 +3,8 @@ MEMORY
|
||||
/* Zedboard: 512 MB DDR3. Only use 63 MB for now, should be plenty for a bare-metal app.
|
||||
Leave 1 MB of memory which will be configured as uncached device memory by the MMU. This is
|
||||
recommended for something like DMA descriptors. */
|
||||
/*CODE(rx) : ORIGIN = 0x00100000, LENGTH = 63M*/
|
||||
CODE(rx) : ORIGIN = 0x00000000, LENGTH = 192K
|
||||
CODE(rx) : ORIGIN = 0x00100000, LENGTH = 63M
|
||||
/*CODE(rx) : ORIGIN = 0x00000000, LENGTH = 192K*/
|
||||
UNCACHED(rx): ORIGIN = 0x4000000, LENGTH = 1M
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ fn main() -> ! {
|
||||
let mut led = Output::new_for_mio(mio_pins.mio7, PinState::High);
|
||||
loop {
|
||||
defmt::info!("toggling LED!");
|
||||
zynq7000_hal::cache::clean_and_invalidate_data_cache();
|
||||
led.toggle().unwrap();
|
||||
cpu_tim.delay_ms(1000);
|
||||
}
|
||||
|
||||
@@ -56,4 +56,5 @@ run binary:
|
||||
python3 {{justfile_directory()}}/scripts/zynq7000-init.py
|
||||
|
||||
# Run the GDB debugger in GUI mode.
|
||||
gdb-multiarch -q -x {{justfile_directory()}}/zynq/gdb.gdb {{binary}} -tui
|
||||
# gdb-multiarch -q -x {{justfile_directory()}}/zynq/gdb.gdb {{binary}} -tui
|
||||
probe-rs run --chip X7Z --protocol jtag --verify --skip-reset {{binary}}
|
||||
|
||||
Generated
+2121
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "probe-rs-test"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
probe-rs = { path = "../../probe-rs/probe-rs" }
|
||||
defmt-decoder = { version = "1" }
|
||||
anyhow = { version = "1" }
|
||||
@@ -0,0 +1,20 @@
|
||||
source [find interface/ftdi/digilent_jtag_smt2.cfg]
|
||||
source [find target/zynq_7000.cfg]
|
||||
|
||||
init
|
||||
|
||||
# Halt the target
|
||||
halt
|
||||
|
||||
# Load the ELF file
|
||||
load_image ../firmware/target/armv7a-none-eabihf/release/defmt
|
||||
verify_image ../firmware/target/armv7a-none-eabihf/release/defmt
|
||||
|
||||
# Set PC to entrypoint
|
||||
reg pc 0x100000
|
||||
|
||||
# Resume
|
||||
resume
|
||||
|
||||
# Optional: Exit OpenOCD if running in batch mode
|
||||
shutdown
|
||||
@@ -0,0 +1,88 @@
|
||||
use std::{path::Path, time::Duration};
|
||||
|
||||
use probe_rs::{
|
||||
Permissions,
|
||||
architecture::arm::dp::DpAddress,
|
||||
flashing::{self, DownloadOptions, ElfOptions, Format},
|
||||
probe::{WireProtocol, list::Lister},
|
||||
rtt,
|
||||
};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
// Initialize the subscriber with an environment filter.
|
||||
// This allows you to control log levels using the `RUST_LOG` environment variable.
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(
|
||||
// Reads the RUST_LOG environment variable.
|
||||
// Defaults to "info" if not set.
|
||||
EnvFilter::from_default_env(),
|
||||
)
|
||||
.init();
|
||||
|
||||
let lister = Lister::new();
|
||||
let probes = lister.list_all();
|
||||
|
||||
let mut probe = probes[0].open()?;
|
||||
probe.select_protocol(WireProtocol::Jtag).unwrap();
|
||||
|
||||
let mut session = probe.attach("X7Z", Permissions::default()).unwrap();
|
||||
println!("target: {:?}", session.target().memory_ports);
|
||||
let arm_if = session.get_arm_interface()?;
|
||||
arm_if.select_debug_port(DpAddress::Default)?;
|
||||
let elf_path = Path::new("../firmware/target/armv7a-none-eabihf/release/defmt");
|
||||
let format = Format::Elf(ElfOptions::default());
|
||||
let mut download_opts = DownloadOptions::default();
|
||||
download_opts.verify = true;
|
||||
download_opts.skip_reset = true;
|
||||
|
||||
println!("flashing ELF file");
|
||||
let loader = flashing::build_loader(&mut session, elf_path, format.clone(), None)?;
|
||||
|
||||
let elf_file = std::fs::read(elf_path).unwrap();
|
||||
let rtt_addr = rtt::find_rtt_control_block_in_raw_file(&elf_file)?.unwrap();
|
||||
let vector_table_addr = loader.vector_table_addr().unwrap();
|
||||
|
||||
loader.commit(&mut session, download_opts)?;
|
||||
|
||||
println!("attaching RTT");
|
||||
|
||||
let mut memory = session.memory_access_port(0)?;
|
||||
let mut rtt = rtt::Rtt::attach_at(&mut memory, rtt_addr)?;
|
||||
drop(memory);
|
||||
session.prepare_running_on_ram(vector_table_addr, 0)?;
|
||||
let mut core = session.core(0)?;
|
||||
|
||||
println!("running core");
|
||||
core.run()?;
|
||||
|
||||
let defmt_table = defmt_decoder::Table::parse(&elf_file)?.unwrap();
|
||||
let mut stream_decoder = defmt_table.new_stream_decoder();
|
||||
drop(core);
|
||||
|
||||
// Read from a channel
|
||||
loop {
|
||||
let mut memory = session.memory_access_port(0)?;
|
||||
for channel in rtt.up_channels() {
|
||||
let mut buf = [0u8; 1024];
|
||||
let count = channel.read(&mut memory, &mut buf[..])?;
|
||||
|
||||
if count > 0 {
|
||||
stream_decoder.received(&buf[..count]);
|
||||
// decode the received data
|
||||
match stream_decoder.decode() {
|
||||
Ok(frame) => {
|
||||
println!("defmt frame: {}", frame.display_message())
|
||||
}
|
||||
Err(defmt_decoder::DecodeError::UnexpectedEof) => {
|
||||
println!("unexpected EOF");
|
||||
}
|
||||
Err(defmt_decoder::DecodeError::Malformed) => {
|
||||
println!("malformed defmt frame");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user