-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
base: master
Are you sure you want to change the base?
Conversation
63b3fa5
to
814f065
Compare
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
b4e6add
to
ccc07f5
Compare
ccc07f5
to
8cd7944
Compare
7528feb
to
904d16c
Compare
d66a246
to
eaccaf7
Compare
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
38a555f
to
afeba90
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
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.
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