From 8c346413a363fd8f6c939daa5467128af91e8b85 Mon Sep 17 00:00:00 2001 From: Per <Per Lindgren> Date: Sun, 12 Jan 2020 19:37:00 +0100 Subject: [PATCH] with programming --- runner/Cargo.toml | 3 ++- runner/src/main.rs | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/runner/Cargo.toml b/runner/Cargo.toml index 3f8be8c..b256a54 100644 --- a/runner/Cargo.toml +++ b/runner/Cargo.toml @@ -8,4 +8,5 @@ edition = "2018" [dependencies] probe-rs = { path = "../../probe-rs/probe-rs", version = "0.3.0" } -ktest = { path = "../ktest", version = "0.1.0" } \ No newline at end of file +ktest = { path = "../ktest", version = "0.1.0" } +failure = "0.1.6" diff --git a/runner/src/main.rs b/runner/src/main.rs index a49975e..98ba13d 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -1,9 +1,12 @@ +use failure::format_err; use ktest::{read_ktest, KTEST}; use probe_rs::{ config::registry::{Registry, SelectionStrategy}, coresight::access_ports::AccessPortError, - flash::download::FileDownloadError, + flash::download::{ + download_file, download_file_with_progress_reporting, FileDownloadError, Format, + }, probe::{stlink, DebugProbe, DebugProbeError, DebugProbeType, MasterProbe, WireProtocol}, session::Session, target::info::{self, ChipInfo}, @@ -16,6 +19,8 @@ fn main() { let strategy = SelectionStrategy::ChipInfo(ChipInfo::read_from_rom_table(&mut probe).unwrap()); println!("strategy {:?}", strategy); + let strategy = SelectionStrategy::TargetIdentifier("stm32f411".into()); + let registry = Registry::from_builtin_families(); let target = registry.get_target(strategy).unwrap(); @@ -23,6 +28,19 @@ fn main() { let mut session = Session::new(target, probe); + let mm = session.target.memory_map.clone(); + + let path_str = "../target/thumbv7em-none-eabihf/debug/examples/f401_break"; + // programming + download_file( + &mut session, + std::path::Path::new(&path_str.to_string().as_str()), + Format::Elf, + &mm, + ) + .map_err(|e| format_err!("failed to flash {}: {}", path_str, e)) + .unwrap(); + // session.probe.target_reset().unwrap(); let cpu_info = session .target -- GitLab