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

boot: add NuttX bootloader with update and recovery support #2809

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

michallenc
Copy link
Contributor

Summary

This commit adds NuttX based bootloader with the support for image update and recovery if not confirmed. The algorithm utilizes three flash partitions: primary (image runs from this area), secondary and tertiary. Secondary and tertiary areas are used for update upload and recovery.

The update is performed by simple copy from update area to primary area with recovery being created in recovery area if not already present. Once image is confirmed by the user, the image in update area is confirmed as well, update area becomes recovery area and vice versa. This means the recovery is always present (except for the first update) and subsequent updates just copy image from update to primary. This makes the update significantly faster and more considerable to flash wear while keeping the recovery/revert possibility.

A header (aligned to flash's erase size) must be added to the beginning of the image. Python script nximage.py can be used to prepend this header to built binary. The algorithm also uses one erase page at the end of a partition (partition, not image!) to store flags used to indicate image confirm status and to detect update/recovery partitions. Any program uploading update image to the update partition has to erase this page for the boot to work correctly!

The algorithm implementation is based on a patch initially developed for MCUboot project but rejected by the project's maintainers

mcu-tools/mcuboot#1902

Impact

New bootloader that can be used with NuttX. Implemented as a standalone application, does not affect current upstream (both core and apps) if not configured.

Testing

Tested on SAMv7 MCU.

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@michallenc
Copy link
Contributor Author

The complete documentation is in a separate pull request to main repository, see docs: add nxboot documentation entry

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

This commit adds NuttX based bootloader with the support for image
update and recovery if not confirmed. The algorithm utilizes three
flash partitions: primary (image runs from this area), secondary
and tertiary. Secondary and tertiary areas are used for update upload
and recovery.

The update is performed by simple copy from update area to primary
area with recovery being created in recovery area if not already present.
Once image is confirmed by the user, the image in update area is
confirmed as well, update area becomes recovery area and vice versa.
This means the recovery is always present (except for the first update)
and subsequent updates just copy image from update to primary. This
makes the update significantly faster and more considerable to flash
wear while keeping the recovery/revert possibility.

A header (aligned to flash's erase size) must be added to the beginning
of the image. Python script nximage.py can be used to prepend this
header to built binary. The algorithm also uses one erase page at the
end of a partition (partition, not image!) to store flags used to
indicate image confirm status and to detect update/recovery partitions.
Any program uploading update image to the update partition has to erase
this page for the boot to work correctly!

The algorithm implementation is based on a patch initially developed
for MCUboot project but rejected by the project's maintainers

mcu-tools/mcuboot#1902

Signed-off-by: Michal Lenc <[email protected]>
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@xiaoxiang781216
Copy link
Contributor

please correct the style issue

@michallenc
Copy link
Contributor Author

please correct the style issue

I am not sure if this is a style issue.

 e45cec88c boot: add NuttX bootloader with update and recovery support
../nuttx/tools/checkpatch.sh -m -g 34ca696b869366de87ff2ab06a21bd1858b527a0..HEAD
../nuttx/tools/checkpatch.sh: line 87: black: command not found
../nuttx/tools/checkpatch.sh: line 88: flake8: command not found
../nuttx/tools/checkpatch.sh: line 89: isort: command not found
../nuttx/tools/checkpatch.sh: line 92: isort: command not found

This seems more like an incorrect configuration of checkpatch that is missing python modules. Local checkpatch passes fine on my PC.

@acassis acassis merged commit 61fec07 into apache:master Nov 1, 2024
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants