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

mcuboot: Add support for swap using offset algorithm #83893

Merged
merged 9 commits into from
Feb 10, 2025

Conversation

nordicjm
Copy link
Collaborator

@nordicjm nordicjm commented Jan 13, 2025

This new mode offers a faster update time and erase a whole round of sector erases/writes from the primary slot

Split MCUboot PR update due to commit being in #83294

@nordicjm nordicjm requested a review from de-nordic January 13, 2025 11:05
@zephyrbot
Copy link
Collaborator

zephyrbot commented Jan 13, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
mcuboot zephyrproject-rtos/mcuboot@0674798 zephyrproject-rtos/mcuboot@9a02794 (upstream-sync) zephyrproject-rtos/[email protected]

Additional metadata changed:

Name URL Submodules West cmds module.yml
mcuboot

DNM label due to: 1 project with metadata changes

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-mcuboot DNM This PR should not be merged (Do Not Merge) labels Jan 13, 2025
@nordicjm nordicjm force-pushed the swaplesserase branch 3 times, most recently from 3ad19c7 to f9224a0 Compare January 15, 2025 19:48
@nordicjm nordicjm force-pushed the swaplesserase branch 2 times, most recently from 9990c03 to feaeb92 Compare January 27, 2025 14:05
@nordicjm nordicjm marked this pull request as ready for review January 27, 2025 14:07
@nordicjm nordicjm requested review from d3zd3z and nvlsianpu January 27, 2025 14:07
@nordicjm nordicjm requested review from butok and erwango January 27, 2025 14:07
@nordicjm nordicjm requested a review from gchwier January 29, 2025 07:22
@nordicjm nordicjm removed the DNM This PR should not be merged (Do Not Merge) label Jan 29, 2025
gchwier
gchwier previously approved these changes Jan 29, 2025
Copy link
Collaborator

@gchwier gchwier left a comment

Choose a reason for hiding this comment

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

Reviewed part with tests, looks good.
Our internal regression passed (upgrade tests on nRF boards)

@zephyrbot zephyrbot added the DNM This PR should not be merged (Do Not Merge) label Jan 29, 2025
@nordicjm nordicjm removed the DNM This PR should not be merged (Do Not Merge) label Jan 29, 2025
@nordicjm nordicjm requested a review from gchwier January 29, 2025 11:36
de-nordic
de-nordic previously approved these changes Jan 31, 2025
Update Zephyr fork of MCUboot to revision:
  9a02794a14fa2e539ffe039a986360590d9e025f

Brings following Zephyr relevant fixes:
  - 9a02794a boot: bootutil: swap_offset: Skip erasing/copying
    empty sectors
  - 96b70086 zephyr: Fix image encryption configuration for
    mbedTLS.
  - e5b89529 boot: boot_serial: Add support for swap using offset
    mode
  - 18fee817 zephyr: Add support for swap using offset mode
  - 4af73169 boot: bootutil: Add swap using offset algorithm
  - 9668469f zephyr: Add Kconfig option to select PureEdDS
  - 96f01aad zephyr: Add Kconfig and configuration for SHA on
    storage
  - 30e6adfe zephyr: Allow SHA512 with TinyCrypt
  - de9bc3d0 bootutil: PureEdDSA using ED25519
  - b43b8c80 bootutil: Enable hash calculation directly on storage
  - f72158ff bootutil: Allow SHA512 with TinyCrypt
  - 4b8a37bb zephyr: Add imgtool/cbor to pip packages installed by
    west
  - 3f672134 zephyr: Fix usage of CONFIG_MBEDTLS_BUILTIN and ASN1
  - c6f5db29 bootutil: Add missing MBEDTLS_ASN1_PARSE_C

Signed-off-by: Jamie McCrae <[email protected]>
Adds a new Kconfig for selecting swap using move in MCUboot which
aligns with the proper MCUboot symbol and allows for adding
additional mode Kconfigs

Signed-off-by: Jamie McCrae <[email protected]>
Deprecates the old Kconfig and adds a new one which lines up with
the name of the Kconfig used by MCUboot

Signed-off-by: Jamie McCrae <[email protected]>
Allows using this newly introduced MCUboot algorithm

Signed-off-by: Jamie McCrae <[email protected]>
Adds a new Kconfig to allow selecting this newly introduced MCUboot
swapping algorithm

Signed-off-by: Jamie McCrae <[email protected]>
Adds details on how to select this new operating mode when using
and when not using sysbuild, also includes a note about a Kconfig
being deprecated and the name of the replacement symbol

Signed-off-by: Jamie McCrae <[email protected]>
Adds a Kconfig used for configuring MCUboot to the allow list

Signed-off-by: Jamie McCrae <[email protected]>
Adds a variation of the test which tests swap using offset mode,
based on the swap using move test

Signed-off-by: Jamie McCrae <[email protected]>
Adds a variation of the test which tests swap using offset mode,
based on the swap using move test

Signed-off-by: Jamie McCrae <[email protected]>
@nordicjm nordicjm requested a review from de-nordic February 3, 2025 10:01
@zephyrbot zephyrbot added the DNM This PR should not be merged (Do Not Merge) label Feb 3, 2025
@nordicjm nordicjm removed the DNM This PR should not be merged (Do Not Merge) label Feb 3, 2025
@nordicjm
Copy link
Collaborator Author

nordicjm commented Feb 7, 2025

@butok that issue should be fixed now, can you try again?

@butok
Copy link
Contributor

butok commented Feb 7, 2025

@butok that issue should be fixed now, can you try again?

If you are able to build it on your system, it's my local problem => ignore my issue.
west build -p always -b frdm_mcxw71 --sysbuild tests/boot/test_mcuboot -- -DSB_CONFIG_MCUBOOT_MODE_SWAP_USING_OFFSET=y

@nordicjm
Copy link
Collaborator Author

nordicjm commented Feb 7, 2025

@butok that issue should be fixed now, can you try again?

If you are able to build it on your system, it's my local problem => ignore my issue. west build -p always -b frdm_mcxw71 --sysbuild tests/boot/test_mcuboot -- -DSB_CONFIG_MCUBOOT_MODE_SWAP_USING_OFFSET=y

Builds here:

-- west build: building application
[13/24] Performing build step for 'mcuboot'
[1/285] Preparing syscall dependency handling

[4/285] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/tmp/aa/zephyr), build: v4.0.0-4431-g8f2952484dad
[285/285] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       33006 B        64 KB     50.36%
             RAM:       21880 B       104 KB     20.55%
     RetainedMem:          0 GB         8 KB      0.00%
    rpmsg_sh_mem:          0 GB         6 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /tmp/aa/zephyr/build/mcuboot/zephyr/zephyr.elf for board: frdm_mcxw71
[16/24] Performing build step for 'swapped_app'
[1/137] Preparing syscall dependency handling

[3/137] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/tmp/aa/zephyr), build: v4.0.0-4431-g8f2952484dad
[137/137] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       15348 B       432 KB      3.47%
             RAM:        4008 B       104 KB      3.76%
     RetainedMem:          0 GB         8 KB      0.00%
    rpmsg_sh_mem:          0 GB         6 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /tmp/aa/zephyr/build/swapped_app/zephyr/zephyr.elf for board: frdm_mcxw71
image.py: sign the payload
image.py: sign the payload
[19/24] Performing build step for 'test_mcuboot'
[1/153] Preparing syscall dependency handling

[3/153] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/tmp/aa/zephyr), build: v4.0.0-4431-g8f2952484dad
[153/153] Linking C executable zephyr/zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:       18414 B       424 KB      4.24%
             RAM:        4240 B       104 KB      3.98%
     RetainedMem:          0 GB         8 KB      0.00%
    rpmsg_sh_mem:          0 GB         6 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
Generating files from /tmp/aa/zephyr/build/test_mcuboot/zephyr/zephyr.elf for board: frdm_mcxw71
image.py: sign the payload
[24/24] Completed 'test_mcuboot'

Copy link
Collaborator

@d3zd3z d3zd3z left a comment

Choose a reason for hiding this comment

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

Minor issue, but doesn't warrant re-doing the patch if nothing else needs to change.

#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_USING_OFFSET)
#define BOOTLOADER_MODE MCUBOOT_MODE_SWAP_USING_OFFSET
#elif defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_USING_MOVE) || \
defined(CONFIG_MCUBOOT_BOOTLOADER_MODE_SWAP_WITHOUT_SCRATCH)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This would be a lot nicer to indent the second line. Not urgent enough, but if you have to fix it for something else.

@kartben kartben merged commit b33c87c into zephyrproject-rtos:main Feb 10, 2025
33 of 34 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.

9 participants