mcuboot icon indicating copy to clipboard operation
mcuboot copied to clipboard

RFC: boot: bootutil: Swap offset: Do not fail on header in wrong sector

Open de-nordic opened this issue 10 months ago • 3 comments

Swap offset does not expect header in first sector/page of secondary slot, rather in secondary, and only attempts to swap an image that starts at second sector. This commit demotes condition when header is found in first page to just a warning and allows boot to proceed, as long as there is a header is second slot.

de-nordic avatar Feb 08 '25 13:02 de-nordic

this should delete it as it currently does because the what has been uploaded is invalid, no different than if you upload a corrupt image to a slot then mark it for upgrade

OK, but wouldn't it suffice to just remove the first page then? I have stumbled to this issue when I had leftover header in slot from previous usage and the mcuboot refused to boot image programmed to the next page. I know it should never happen, but it is like you have stuck something irrelevant to the first page, that will not be used for anything, but MCUboot refuses to work.

de-nordic avatar Feb 11 '25 11:02 de-nordic

this should delete it as it currently does because the what has been uploaded is invalid, no different than if you upload a corrupt image to a slot then mark it for upgrade

OK, but wouldn't it suffice to just remove the first page then? I have stumbled to this issue when I had leftover header in slot from previous usage and the mcuboot refused to boot image programmed to the next page. I know it should never happen, but it is like you have stuck something irrelevant to the first page, that will not be used for anything, but MCUboot refuses to work.

needs to clear first 2 sectors and trailer sector at least, in original implementation just used the existing clear image erase code that was already present in the file. Hmm do you mean like with https://github.com/mcu-tools/mcuboot/pull/2199 ?

nordicjm avatar Feb 11 '25 11:02 nordicjm

this should delete it as it currently does because the what has been uploaded is invalid, no different than if you upload a corrupt image to a slot then mark it for upgrade

OK, but wouldn't it suffice to just remove the first page then? I have stumbled to this issue when I had leftover header in slot from previous usage and the mcuboot refused to boot image programmed to the next page. I know it should never happen, but it is like you have stuck something irrelevant to the first page, that will not be used for anything, but MCUboot refuses to work.

needs to clear first 2 sectors and trailer sector at least, in original implementation just used the existing clear image erase code that was already present in the file.

So, in my case there was a sequence on the same board:

  1. I have tested offset
  2. I had to do some work on swam-move
  3. I have nrfjproged the same set I have used in 1), at once
  4. reset and I got the error, even though the set from 1) worked fine, just that this time I have leftover header from 2).

So why to clear two sectors? The header in the second sector is what I have expected

Hmm do you mean like with #2199 ?

Yeah, maybe. But that had to be a lot of bad things happening for the magic to appear properly.

But there is also a chance that some write started (can it?) during swap-offset, and there is already crap in the first sector, or something else managed to write there magic.

de-nordic avatar Feb 11 '25 12:02 de-nordic

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

github-actions[bot] avatar Aug 11 '25 02:08 github-actions[bot]