Skip to content

boot: add delta DFU support - #2743

Open
hlord2000 wants to merge 2 commits into
mcu-tools:mainfrom
hlord2000:delta-dfu-mcuboot
Open

boot: add delta DFU support#2743
hlord2000 wants to merge 2 commits into
mcu-tools:mainfrom
hlord2000:delta-dfu-mcuboot

Conversation

@hlord2000

@hlord2000 hlord2000 commented May 28, 2026

Copy link
Copy Markdown

Summary

Adds overwrite-only delta DFU support.

A signed reversible delta image in the secondary slot can patch the current primary image. MCUboot verifies the expected base, recovers interrupted updates using the stored old bytes, and validates the reconstructed target. Unconfirmed test updates can be reverted.

Changes

  • Add imgtool support with --delta-base and --delta-block-size.
  • Generate reversible deltas containing both new and old bytes.
  • Add bootutil support for validation, application, and reset-safe recovery.
  • Defer security-counter updates for test images until confirmation.
  • Add Zephyr configuration, documentation, simulator tests, and CI coverage.

Testing

  • uv run pytest scripts/tests/test_delta.py
  • Simulator tests for unsigned, ECDSA-signed, and rollback-protected configurations.

@d3zd3z d3zd3z left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So a few high level things:

  • First to be clear: this is a non-robust upgrade, much worse than overwrite only. Whereas overwrite only will effectively restart the operation, this doesn't appear to be recoverable if power is lost, effectively bricking the device. Correct me if my understand is not right, but that isn't really a mode we want to have in MCUboot.
  • Second, it isn't tested (which would point out that it doesn't work with power loss).

So, in order to get this through, it is going to need to be added to the simulator for testing. And, more importantly the robustness needs to be addressed. There either needs to be an argument for a use case where bricking a device on an upgrade interruption is acceptable, or the code needs to be made robust (it needs to be able to recover, and continue the upgrade when interrupted at any point.

@d3zd3z d3zd3z added the [DNM] Do Not Merge label Jun 3, 2026
@hlord2000

Copy link
Copy Markdown
Author

So a few high level things:

  • First to be clear: this is a non-robust upgrade, much worse than overwrite only. Whereas overwrite only will effectively restart the operation, this doesn't appear to be recoverable if power is lost, effectively bricking the device. Correct me if my understand is not right, but that isn't really a mode we want to have in MCUboot.
  • Second, it isn't tested (which would point out that it doesn't work with power loss).

So, in order to get this through, it is going to need to be added to the simulator for testing. And, more importantly the robustness needs to be addressed. There either needs to be an argument for a use case where bricking a device on an upgrade interruption is acceptable, or the code needs to be made robust (it needs to be able to recover, and continue the upgrade when interrupted at any point.

Thanks for the feedback!

On your first point: yes, there is a non-robust upgrade path. This is what I started with, just overwriting the existing application w/o maintaining a diff of delta->current firmware. Gated behind "MCUBOOT_DELTA_DFU_RESTORE" is a flow where this diff is generated before anything is overwritten. I'll remove the non-robust upgrade path, that's fine as this still represents significant NVM savings for mature applications.

I'll work on getting this working w/ the simulator.

@hlord2000
hlord2000 force-pushed the delta-dfu-mcuboot branch from 10138cf to 53ff542 Compare June 4, 2026 23:41

@d3zd3z d3zd3z left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good, thank you for the work. Just a few questions:

  • First, this will need to be rebased to be able to merge.
  • Does the security counter properly update when the reversible delta is confirmed.
  • Please update the description, which still describes --delta-revertible as optional, and doesn't mention the robustness rework.
  • The per-record bounds are validate in a pass separate from where records are re-read and applied. A flash change between the two passes could smuggle an out-of-range offset/size. This isn't exploitable remotely, and I think this requires physically changing the flash between verified flash, so probably isn't covered by our threat model, but something to keep in mind.
  • Please update docs/design.md to describe the new flag and TLFv.
  • It might be worth mentioning in docs/delta_dfu.md that since each changed region costs 2x bytes, a delta that touches scattered regions could exceed a plain overwrite in size.

@hlord2000
hlord2000 force-pushed the delta-dfu-mcuboot branch 2 times, most recently from 0e64f5e to bba518b Compare July 30, 2026 03:15
@nordicjm
nordicjm requested a review from d3zd3z July 30, 2026 06:25

@d3zd3z d3zd3z left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From my perspective, the only thing remaining is to update the description of the pr to match what the change now does.

@hlord2000

Copy link
Copy Markdown
Author

From my perspective, the only thing remaining is to update the description of the pr to match what the change now does.

Just updated

Comment thread boot/bootutil/include/bootutil/image.h Outdated
Comment on lines +138 to +139
#define IMAGE_TLV_DELTA_BASE_SHA 0x76 /* SHA of image the delta applies to */
#define IMAGE_TLV_DELTA_TARGET_SHA 0x77 /* SHA of image produced by the delta */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we already have TLVs for output and input SHA, see decomp, I dont think we should add more when we can just reuse those (they can be renamed)

@nordicjm nordicjm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

incredibly quick scan

Comment thread docs/delta_dfu.md Outdated
Comment on lines +36 to +37
uint8_t new_data[size];
uint8_t old_data[size];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

1 space

Add protocol-v1 signed reversible delta images for overwrite-only upgrades. Store old and new bytes for each changed region, reserve recovery sectors in both slots, and resume forward apply or restore safely after power loss.

Revalidate record bounds while applying them, validate reconstructed images before committing metadata, and defer rollback-counter advancement for test updates until confirmation. Extend imgtool, Zephyr integration, documentation, and simulator coverage for the complete flow.

Assisted-by: GPT-5.5
Signed-off-by: hlord2000 <kellyhlord@gmail.com>
Run unsigned, ECDSA-signed, and hardware rollback-protected delta DFU configurations in the simulator matrix.

Assisted-by: GPT-5.5
Signed-off-by: hlord2000 <kellyhlord@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[DNM] Do Not Merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants