Skip to content

Conversation

@rubienr
Copy link

@rubienr rubienr commented Dec 1, 2025

Description

Summary

This PR implements 206 Partial Content in esp_https_ota_begin().

Issue

Currently the esp-idf implementation ignores whether the server supports or doesn't support range requests. If OTA is resumed and the server responds 200 OK instead of 206 Partial Content, the OTA will download the image starting at byte 0 but resume writing in flash (after last index when it aborted).

How to reproduce:

  1. serve the OTA image with python -m http.server 8000; at the time of writing http.server with Python 3.13 does not support range requests (lets call this server A)
  2. start OTA
  3. at approx. 15% kill the connection: sudo ss --kill --option state established "sport = :8000"
  4. observe that OTA resumes
  5. wait until OTA reaches 100%
  6. observe that OTA goes beyond 100% up to 115% and integrity check fails

Testing

Simple resumption scenario

  1. apply this PR
  2. serve the OTA image with flask: python -m flask --app server run --port 8000 --host 0.0.0.0; server.py script not provided here (lets call this server B))
  3. start OTA
  4. at approx. 15% kill the connection: sudo ss --kill --option state established "sport = :8000"
  5. observe that OTA resumes from about 15%
  6. wait until OTA reaches 100%
  7. observe that OTA does not go beyond 100% and integrity check succeeds

Hypothetic resumption scenario

  1. apply this PR
  2. serve the OTA image with server A
  3. start OTA
  4. at approx. 15% kill server A and start server B
  5. observe that OTA resumption starts again from 0%
  6. wait until OTA reaches 100%
  7. observe that OTA does not go beyond 100% and integrity check succeeds

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Note

When resuming OTA with a Range request, return ESP_ERR_HTTP_RANGE_NOT_SATISFIABLE if the server doesn’t respond with 206 Partial Content.

  • esp_https_ota:
    • In _http_handle_response_code (components/esp_https_ota/src/esp_https_ota.c), when resuming (binary_file_len > 0)
      • If not using partial download and response is not HttpStatus_PartialContent (206), log "Requested range header ignored by server" and return ESP_ERR_HTTP_RANGE_NOT_SATISFIABLE to abort OTA.

Written by Cursor Bugbot for commit cac95eb. This will update automatically on new commits. Configure here.

@CLAassistant
Copy link

CLAassistant commented Dec 1, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Warnings
⚠️

Some issues found for the commit messages in this PR:

  • the commit message "fix esp_https_ota_begin(): implements handling of HttpStatus_PartialContent-code 206":
    • summary looks empty
    • type/action looks empty

Please fix these commit messages - here are some basic tips:

  • follow Conventional Commits style
  • correct format of commit message should be: <type/action>(<scope/component>): <summary>, for example fix(esp32): Fixed startup timeout issue
  • allowed types are: change,ci,docs,feat,fix,refactor,remove,revert,test
  • sufficiently descriptive message summary should be between 20 to 72 characters and start with upper case letter
  • avoid Jira references in commit messages (unavailable/irrelevant for our customers)

TIP: Install pre-commit hooks and run this check when committing (uses the Conventional Precommit Linter).

👋 Hello rubienr, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Resolve all warnings (⚠️ ) before requesting a review from human reviewers - they will appreciate it.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by 🚫 dangerJS against cac95eb

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 1, 2025
@github-actions github-actions bot changed the title esp_https_ota_begin(): handle HttpStatus_PartialContent-code 206 esp_https_ota_begin(): handle HttpStatus_PartialContent-code 206 (IDFGH-16894) Dec 1, 2025
@rubienr rubienr force-pushed the ota-resumption_partial-download-code-206 branch 2 times, most recently from 3f51ed8 to 70f29c0 Compare December 1, 2025 17:43
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
/ * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
Copy link

Choose a reason for hiding this comment

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

Bug: Accidental character introduced in copyright comment line

The block comment continuation on line 2 was changed from * SPDX-FileCopyrightText... to / * SPDX-FileCopyrightText.... A / character was accidentally inserted where a space should be, breaking the conventional block comment formatting style. While this doesn't affect compilation (it's still valid inside the /* */ block), it appears to be an unintended keystroke that should be reverted.

Fix in Cursor Fix in Web

@rubienr rubienr force-pushed the ota-resumption_partial-download-code-206 branch from 70f29c0 to 4e41e8c Compare December 2, 2025 08:34
@rubienr
Copy link
Author

rubienr commented Dec 3, 2025

I signed the license/cla at least 12 times.
When is enough enough? 😠
image

@rubienr rubienr force-pushed the ota-resumption_partial-download-code-206 branch from 4e41e8c to cac95eb Compare December 3, 2025 12:17
@nileshkale123
Copy link
Collaborator

sha=cac95eb984fbea21ba3defaf1411ecb10bf646ca

@nileshkale123 nileshkale123 added the PR-Sync-Merge Pull request sync as merge commit label Dec 4, 2025
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Sync-Merge Pull request sync as merge commit Status: In Progress Work is in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants