Skip to content
Open
Changes from 1 commit
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
12 changes: 10 additions & 2 deletions humility-core/src/hubris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2103,11 +2103,19 @@
);
}

if criteria == HubrisValidate::ArchiveMatch {
if self.task_dump().is_some() {
return Ok(());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@labbott What does it mean for an archive to be "a dump from a single task"? I'm wondering if it's intentional/correct that if you pass in HubrisValidate::Booted in that case, it returns early here and skips the boot check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's possible to take a dump from only a single task's memory range (e.g. a "single task dump"), but not an "entire system" dump. Laura can confirm though :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

James is correct. We have the notion of single task dumps vs a wholes system dump. You can run many of the same commands like e.g. humility tasks and humility ringbuf and things should work as expected. I don't think we capture the boot information in a single task dump which is why it gets skipped.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I added a comment about it.

} else {
core.halt()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do core.run()? again after checking the PC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely yes this got lost in some refactoring 😬

if let Ok(pc) = core.read_reg(ARMRegister::PC) {

Check failure on line 2110 in humility-core/src/hubris.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed
if self.instr_mod(pc).is_none() {
bail!("PC at 0x{pc:x} is not part of any module. This is \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unimportant turbo nitpick: if we write

Suggested change
bail!("PC at 0x{pc:x} is not part of any module. This is \
bail!("PC at {pc:#x} is not part of any module. This is \

that tells the formatter to emit the 0x prefix itself. which...changes absolutely nothing here so it doesn't matter...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way this interacts with flashing is not ideal. If you try to re-flash an A image that's already been flashed to the A slot while the RoT is running a B image:

  • the old behavior was to fail with "archive appears to be already flashed on attached device; use -F ("--force") to force re-flash"
  • this PR's behavior is to re-flash the A image
  • the ideal behavior is probably to warn the user that they probably meant to flash the other image, then fail with the "archive appears to be already flashed" error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah you're right that's confusing behavior. I think that would point to needing to fix validate to return a more specific error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or don't use validate for the pre-flash check. In my PR, I considered a bunch of different return types then gave up trying to make the same validate function work for flashing and for both of the HubrisValidate options.

likely an incorrect archive.");
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe clippy would like you to have written something more like:

Suggested change
if let Ok(pc) = core.read_reg(ARMRegister::PC) {
if self.instr_mod(pc).is_none() {
bail!("PC at 0x{pc:x} is not part of any module. This is \
likely an incorrect archive.");
}
}
if let Ok(pc) = core.read_reg(ARMRegister::PC)
&& self.instr_mod(pc).is_none() {
bail!("PC at 0x{pc:x} is not part of any module. \
This is likely an incorrect archive.");
}

}

if self.task_dump().is_some() {
if criteria == HubrisValidate::ArchiveMatch {
return Ok(());
}

Expand Down
Loading