Use BOOTED_IMAGE to warn when using wrong A/B image#712
Conversation
| if deltas > 0 || id.len() != self.imageid.1.len() { | ||
| if id != self.imageid.1 { |
There was a problem hiding this comment.
I can't think of any reason why the original code would need to do that manual comparison instead of just using !=. Hope I'm not missing something.
|
|
||
| if n == ntasks as u32 { | ||
| // | ||
| // Check the CURRENT_TASK_PTR; it's non-zero iff we have booted |
There was a problem hiding this comment.
We could start using BOOTED_IMAGE for this too. But maybe it's better to use CURRENT_TASK_PTR because that's set at the end of kernel startup, while BOOTED_IMAGE is set at the beginning of kernel startup.
| "can't detect booted image, reading image ID from FLASH ({})", | ||
| err | ||
| ); | ||
| self.read_image_id_from_flash(core)? |
There was a problem hiding this comment.
It might be worth checking the PC location here as part of the fallback when we can't read BOOTED_IMAGE. In addition to requiring the flash ID to match, we could either fail or warn if the PC suggests this is the wrong image slot.
|
I think this is more complete than just the PC check which is a bit hacky. It also occurs to me this is reimplementing the bootleby decision log for the RoT https://github.com/oxidecomputer/bootleby/blob/bdf56dd950b934360df596ed5b2d8b8813c92168/src/bin/bootleby.rs#L201-L207 , https://github.com/oxidecomputer/bootleby/blob/bdf56dd950b934360df596ed5b2d8b8813c92168/memory.x#L39 (see oxidecomputer/hubris#2066 as well). Didn't think of this until I finished reviewing this work! We don't have a problem with the SP so part of me says that we should just read the decision log in humility. Do you see any value in having the same information for the SP even though everything is just "default"? |
Oh cool, it would be nice to reuse an existing feature. Questions / concerns:
But if none of those seem like a big deal, then I think it would be fine to use the bootleby log instead of |
The companion hubris PR is oxidecomputer/hubris#2591.
Both this and Laura's PR #711 are trying to address issue #709 - we can choose to merge one or combine both approaches in some way.
This PR's approach is to make the hubris kernel record the image ID and name in the
BOOTED_IMAGEvariable so that humility can tell which A/B image is actually running on the RoT. Humility now uses that image ID to check whether an archive matches what's running on the target, and uses the image name to warn when flashing an image to the inactive slot.New behavior:
If you run
humility tasksetc with an A archive and a target running a B image, it will:If you're flashing an A image and a target running a B image, it will:
Note that it never blocks you from flashing and doesn't change the logic of whether an archive needs to be re-flashed.
Tradeoffs
Testing:
Lightly tested on a grapefruit's RoT and SP. If folks like this approach then I'll keep testing more combos and edge cases. Also CI tests will fail because I haven't yet added the line
humility: can't detect booted image, reading image ID from FLASH (BOOTED_IMAGE not in archive's symbol table)to 415 unit tests.