Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove almost all "unhalted reads" and make tasks display consistent #532

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions cmd/bankerase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ fn bankerasecmd(context: &mut ExecutionContext) -> Result<()> {
};

humility::msg!("attaching with chip set to {chip:x?}");
let mut c =
humility_probes_core::attach_for_flashing(probe, hubris, &chip)?;
let mut c = humility_probes_core::attach_for_flashing(probe, &chip)?;
let core = c.as_mut();

let ihex = tempfile::NamedTempFile::new()?;
Expand Down
3 changes: 1 addition & 2 deletions cmd/flash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ fn flashcmd(context: &mut ExecutionContext) -> Result<()> {
};

humility::msg!("attaching with chip set to {chip:x?}");
let mut c =
humility_probes_core::attach_for_flashing(probe, hubris, &chip)?;
let mut c = humility_probes_core::attach_for_flashing(probe, &chip)?;
let core = c.as_mut();

validate(hubris, core, &subargs)?;
Expand Down
2 changes: 1 addition & 1 deletion cmd/reset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn reset(context: &mut ExecutionContext) -> Result<()> {
"Need a chip to do a soft reset or halt after reset"
)
})?;
humility_probes_core::attach_to_chip(probe, hubris, Some(&chip))?
humility_probes_core::attach_to_chip(probe, Some(&chip))?
} else {
humility_probes_core::attach_to_probe(probe)?
};
Expand Down
12 changes: 4 additions & 8 deletions cmd/tasks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
) -> Result<()> {
let (base, task_count) = hubris.task_table(core)?;
log::debug!("task table: {:#x?}, count: {}", base, task_count);
let ticks = if core.is_net() { None } else { Some(hubris.ticks(core)?) };

let task_t = hubris.lookup_struct_byname("Task")?;
let save = task_t.lookup_member("save")?.offset;
Expand All @@ -237,6 +236,9 @@
loop {
core.halt()?;

let ticks =
if core.is_net() { None } else { Some(hubris.ticks(core)?) };

let cur = hubris.current_task(core)?;
let task_dump = hubris.task_dump();

Expand Down Expand Up @@ -308,12 +310,8 @@
}
}

let keep_halted = stack || registers || panicked;

Check warning on line 313 in cmd/tasks/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check (MSRV) (ubuntu-latest)

unused variable: `keep_halted`

Check failure on line 313 in cmd/tasks/src/lib.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused variable: `keep_halted`

Check warning on line 313 in cmd/tasks/src/lib.rs

View workflow job for this annotation

GitHub Actions / Check (MSRV) (windows-latest)

unused variable: `keep_halted`

Check warning on line 313 in cmd/tasks/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

unused variable: `keep_halted`

Check warning on line 313 in cmd/tasks/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

unused variable: `keep_halted`

if !keep_halted {
core.run()?;
}

writeln!(
w,
"system time = {}",
Expand Down Expand Up @@ -480,9 +478,7 @@
)?;
}

if keep_halted {
core.run()?;
}
core.run()?;

if task_arg.is_some() && !found {
bail!("\"{}\" is not a valid task", task_arg.unwrap());
Expand Down
8 changes: 0 additions & 8 deletions humility-core/src/hubris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3679,14 +3679,6 @@ impl HubrisArchive {
}
}

pub fn unhalted_reads(&self) -> bool {
if let Some(ref target) = self.manifest.target {
target != "thumbv6m-none-eabi"
} else {
false
}
}

/// Reads the auxiliary flash data from a Hubris archive
///
/// Returns `Ok(Some(...))` if the data is loaded, `Ok(None)` if the file
Expand Down
28 changes: 8 additions & 20 deletions humility-probes-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ pub fn attach_to_probe(probe: &str) -> Result<Box<dyn Core>> {
#[rustfmt::skip::macros(anyhow, bail)]
pub fn attach_to_chip(
probe: &str,
hubris: &HubrisArchive,
chip: Option<&str>,
) -> Result<Box<dyn Core>> {
let (probe, index) = parse_probe(probe);
Expand Down Expand Up @@ -191,7 +190,6 @@ pub fn attach_to_chip(
probe_info.vendor_id,
probe_info.product_id,
probe_info.serial_number,
hubris.unhalted_reads(),
can_flash,
)))
}
Expand All @@ -209,15 +207,15 @@ pub fn attach_to_chip(
}

"auto" => {
if let Ok(probe) = attach_to_chip("ocd", hubris, chip) {
if let Ok(probe) = attach_to_chip("ocd", chip) {
return Ok(probe);
}

if let Ok(probe) = attach_to_chip("jlink", hubris, chip) {
if let Ok(probe) = attach_to_chip("jlink", chip) {
return Ok(probe);
}

attach_to_chip("usb", hubris, chip)
attach_to_chip("usb", chip)
}

"ocdgdb" => {
Expand Down Expand Up @@ -256,31 +254,21 @@ pub fn attach_to_chip(
crate::msg!("attached to {vidpid} via {name}");

Ok(Box::new(probe_rs::ProbeCore::new(
session,
name,
vid,
pid,
serial,
hubris.unhalted_reads(),
can_flash,
session, name, vid, pid, serial, can_flash,
)))
}
Err(_) => Err(anyhow!("unrecognized probe: {probe}")),
},
}
}

pub fn attach_for_flashing(
probe: &str,
hubris: &HubrisArchive,
chip: &str,
) -> Result<Box<dyn Core>> {
attach_to_chip(probe, hubris, Some(chip))
pub fn attach_for_flashing(probe: &str, chip: &str) -> Result<Box<dyn Core>> {
attach_to_chip(probe, Some(chip))
}

pub fn attach(probe: &str, hubris: &HubrisArchive) -> Result<Box<dyn Core>> {
match hubris.chip() {
Some(s) => attach_to_chip(probe, hubris, Some(&s)),
None => attach_to_chip(probe, hubris, None),
Some(s) => attach_to_chip(probe, Some(&s)),
None => attach_to_chip(probe, None),
}
}
35 changes: 12 additions & 23 deletions humility-probes-core/src/probe_rs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub struct ProbeCore {
pub vendor_id: u16,
pub product_id: u16,
pub serial_number: Option<String>,
unhalted_reads: bool,
halted: u32,
unhalted_read: BTreeMap<u32, u32>,
can_flash: bool,
Expand All @@ -32,7 +31,6 @@ impl ProbeCore {
vendor_id: u16,
product_id: u16,
serial_number: Option<String>,
unhalted_reads: bool,
can_flash: bool,
) -> Self {
Self {
Expand All @@ -41,7 +39,6 @@ impl ProbeCore {
vendor_id,
product_id,
serial_number,
unhalted_reads,
halted: 0,
unhalted_read: humility_arch_arm::unhalted_read_regions(),
can_flash,
Expand All @@ -54,24 +51,20 @@ impl ProbeCore {
) -> Result<()> {
let mut core = self.session.core(0)?;

if self.unhalted_reads {
func(&mut core)
let halted = if self.halted == 0 && !core.core_halted()? {
core.halt(std::time::Duration::from_millis(1000))?;
true
} else {
let halted = if self.halted == 0 && !core.core_halted()? {
core.halt(std::time::Duration::from_millis(1000))?;
true
} else {
false
};

let rval = func(&mut core);
false
};

if halted {
core.run()?;
}
let rval = func(&mut core);

rval
if halted {
core.run()?;
}

rval
}
}

Expand Down Expand Up @@ -313,17 +306,13 @@ impl Core for ProbeCore {
}

fn op_start(&mut self) -> Result<()> {
if !self.unhalted_reads {
self.halt()?;
}
self.halt()?;

Ok(())
}

fn op_done(&mut self) -> Result<()> {
if !self.unhalted_reads {
self.run()?;
}
self.run()?;

Ok(())
}
Expand Down
Loading