-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
esp32/ota: Implement ESP-IDF OTA functionality. #7048
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
Open
ekondayan
wants to merge
1
commit into
micropython:master
Choose a base branch
from
ekondayan:feature/ota
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+423
−34
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63b3fa5 to
814f065
Compare
Author
|
Anybody? |
e98f531 to
a9ba869
Compare
23025f2 to
5fc57a9
Compare
e353cfd to
cdd760c
Compare
baa1249 to
8d0268c
Compare
3ce6443 to
bb49a3f
Compare
ffbdab7 to
e4d981c
Compare
e4d981c to
ab34d54
Compare
f22e3b0 to
62d0e86
Compare
62d0e86 to
0ed6e29
Compare
5348855 to
8126752
Compare
73418ec to
4db74d3
Compare
4db74d3 to
e3e894a
Compare
a8c8447 to
05eff2f
Compare
ce4f33c to
2c8b347
Compare
594f8b9 to
d4a2619
Compare
f21f8cc to
1db1889
Compare
7ce7787 to
012f95d
Compare
012f95d to
91a0a00
Compare
Implemented new functions: * mark_app_invalid_rollback_and_reboot() * check_rollback_is_possible() * app_description() * app_state() * ota_begin() * ota_write() * ota_write_with_offset() for ESP-IDF version >= 4.2 * ota_end() * ota_abort() for ESP-IDF version >= 4.3 * create tests * update documentation esp32/ota: Implement ESP-IDF OTA functionality.
91a0a00 to
777fca7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
UPDATE: The test completed successfully on NodeMCU ESP32 by ai-thinker with ESP-IDF v4.0, v4.1, v4.2, v4.3
Implemented new functions in esp32.Partition:
mark_app_invalid_rollback_and_reboot()
check_rollback_is_possible()
app_description()
app_state()
ota_begin()
ota_write()
ota_write_with_offset() for ESP-IDF version >= 4.2
ota_end()
ota_abort() for ESP-IDF version >= 4.3
create tests
update documentation
For many commercial products, Over The Air updates are a very important and critical part. It must be reliable and should not brick the device. Writing a good OTA from scratch is a daunting task. For that reason the use of well tested and proven reliable libraries is much more preferable than the ones developed in the house.
USECASE
I'm developing an industrial device where the OTA is an essential part of it. Since only a few functions from esp-idf are
implemented (enough for hobby project but not enough for commercial project), I ended up duplicating the esp-idf ota functionality in python.
The result was a module with a questionable quality. I tried to predict all the possible places where it could crash, but my gut was
telling me that I could be missing something. So I decided to implement more of the the OTA functions from esp-idf and to use them in my OTA module.
I've rewritten my OTA module and replaced the redundant code with the implemented functions from esp-idf. This allowed me to reduced the size of the module significantly, increase the robustness of the code and on top of that now the code got much simpler and easier to maintain.
The total increase in size of the compiled app image is 2432 bytes.
IMPLEMENTATION
Extend the esp32.Partition class where all the OTA related functions are
prefixed with "ota_" and app related functions are prefixed with "app_".
Example:
from esp32 import Partition
app_part = Partition(Partition.RUNNING)
app_part.app_description()
app_part.app_state()
handle = app_part.ota_begin()
app_part.ota_end(handle)
New functions:
Partition.mark_app_invalid_rollback_and_reboot(cls)
Partition.check_rollback_is_possible(cls)
Partition.app_description(self)
Partition.app_state(self)
Partition.ota_begin(self, image_size = 0)
Partition.ota_write(self, handle_in, data_in)
Partition.ota_write_with_offset(self, handle_in, data_in, offset)
Partition.ota_end(self, handle_in)
Partition.ota_abort(self, handle_in) only for ESP-IDF version >= 4.3
BENEFITS
CONS