Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Merge #129
Browse files Browse the repository at this point in the history
129: reject use of defmt and --no-flash (again) r=japaric a=japaric

before PR #105 using defmt required the `--defmt` flag. At that time it was not possible to use the `--defmt` and `--no-flash` flags together. The rationale for that restriction is that without it `cargo run` can invoke `probe-run` with a newer version of the ELF different from the ELF that was last flashed on the device and that can result in log messages that make no sense and/or decoder errors.

After PR 105 landed it unintentionally became possible to use defmt with --no-flash due to the auto-detection (auto-enable) mechanism. This PR corrects that and makes the use of `--no-flash` flag and defmt an error again.

Co-authored-by: Jorge Aparicio <[email protected]>
  • Loading branch information
bors[bot] and japaric authored Jan 7, 2021
2 parents 7d1b420 + 9356c94 commit f59c74a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,6 @@ fn notmain() -> Result<i32, anyhow::Error> {
core.run()?;
}

// Print a separator before the device messages start.
eprintln!("{}", "─".repeat(80).dimmed());

let exit = Arc::new(AtomicBool::new(false));
let sig_id = signal_hook::flag::register(signal_hook::SIGINT, exit.clone())?;

Expand All @@ -399,6 +396,12 @@ fn notmain() -> Result<i32, anyhow::Error> {
.as_ref()
.map_or(false, |ch| ch.name() == Some("defmt"));

if use_defmt && opts.no_flash {
bail!(
"attempted to use `--no-flash` and `defmt` logging -- this combination is not allowed. Remove the `--no-flash` flag"
);
}

if use_defmt && table.is_none() {
bail!("\"defmt\" RTT channel is in use, but the firmware binary contains no defmt data");
}
Expand All @@ -407,6 +410,9 @@ fn notmain() -> Result<i32, anyhow::Error> {
table = None;
}

// Print a separator before the device messages start.
eprintln!("{}", "─".repeat(80).dimmed());

// wait for breakpoint
let stdout = io::stdout();
let mut stdout = stdout.lock();
Expand Down

0 comments on commit f59c74a

Please sign in to comment.