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

Version number extraction #1

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Conversation

lefebvresam
Copy link
Collaborator

@lefebvresam lefebvresam commented Dec 21, 2024

After some investigation it's possible to extract the version number by calling boot_read_image_header() with the boot status fetched with swap_read_status(). According to the demo of George Beckstein with utility function and the fetch function I did some improvements to avoid having the wrong decisions in the calls with hanging code or reading from the wrong slot as result.

Changes:

  • Introducing function int boot_get_current_version(struct image_version *version) in /mcuboot/boot/bootutil/scr/bootutil_misc.c
  • Merged with upstream master

multiplemonomials and others added 17 commits December 4, 2024 00:44
Twister now expects a yaml list of plaforms.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Updates to a newer version of the zephyr docker image

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Limits the modules that are checked out as part of zephyr to
reduce storage space needed and CI run time

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Ensure that bootloader info and measurements are saved to retained
memory when using mcuboot in single-image mode.

Signed-off-by: Dane Wagner <dane.wagner@gmail.com>
passing user_sha parameters while creating compressed image

Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
Adds default configuration for the frdm-mcxa156 board.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
After a partial swap has been resumed and completed, the image headers
are reloaded. The idea is that we want to update the bootloader state
(boot_data) to properly reflect the new state of the slots: the image
headers in the primary and secondary slots are now respectively the
headers of the new and previous active image.

However, the implementation was doing the exact opposite when
swap-scratch was used, which could lead to erroneous behaviors such as a
failure when validating the primary slot.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
Let's suppose after an upgrade you have a non-functional image in the
primary slot. The image won't be confirmed, leading to a revert at next
boot. At the beginning of the revert process, fixup_revert is invoked,
which rewrites the trailer in the secondary slot so that the revert
looks like a permanent upgrade. Normally, after the execution of this
routine, the secondary slot has a valid trailer, in particular with a
valid magic number.

Let's imagine a power failure occurs during the writing of the trailer's
magic, i.e. in boot_write_magic. The magic number in the secondary slot
is in an undefined state and might be partially written, which implies
at next boot it will be considered in BOOT_MAGIC_BAD state.

So, at next boot, we have the following state:
Primary slot: magic=good, copy-done=set, image-ok=unset
Secondary slot: magic=bad, copy-done=unset, image-ok=set

This doesn't match any state leading to an upgrade or revert process to
be initiated, which means MCUboot will not perform the revert and
attempt to boot from the primary slot, containing a non-functional
image. Hence, the device is bricked unless it is possible to reflash the
secondary slot without a functional image.

To avoid this issue, a revert is performed no matter the state of the
magic number in the secondary slot's trailer, provided the copy-done
flag is set in the primary slot but the image-ok flag is not. The
copy-done flag is set only after having completed an upgrade or
revert process so if the copy-done flag is set but the image-ok is
unset, it is guaranteed an upgrade has been performed but the new image
has not been confirmed, which implies a revert is needed.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
Adds NXP platforms, sorted alphabetically,
to the boot zephyr allow list.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
Add ctcc/nrf52840 and ctcc/nrf9161 board targets.

Signed-off-by: Jan Kowalewski <jkowalewski@cthings.co>
Signed-off-by: Zachary Crockett <zachary.crockett@sofarocean.com>
…te change

Before pushing MCUBOOT_STATUS_UPGRADING, check if has_upgrade is true to ensure this is not pushed at every boot and only when needed.

Signed-off-by: Joseph Todd <joseph.todd@lascar.co.uk>
Configured CONFIG_NRF_RRAM_WRITE_BUFFER_SIZE=32
Which ensure the fastest bulk RRAM write operations.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
@lefebvresam
Copy link
Collaborator Author

Is there any news on this? Should this pull request be on the upstream project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.