-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
esp32: Add esp32.Partition class to interface to OTA functions. #4910
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
Conversation
I'll upgrade to v1.11 and pull this PR to replace my own partition code and see if it works. I'll post the results here in a few days... |
AttributeError: 'Partition' object has no attribute 'metadata' part.info() is working!
0? #define PART_TYPE_DATA 0x01 #define PART_TYPE_END 0xff 65535 is the offset, correct. 2621440 is the size of the partition, correct again. So far, it's working. But how to get a list of all partitions? |
Yes, sorry, I updated the API without updating the comment (which is now updated).
I'm don't think #3576 had a way to list all partitions, so that's which I didn't implement it. I thought that the user would anyway know all partitions (eg by name) so could use But if listing all partitions is necessary there's an API in the IDF which could be exposed, eg to get an iterator which iterates over the partitions, like: for part in Partition.ifind(type=..., subtype=..., label=...):
print(part)
|
I just pushed a commit to add To use: app_parts = Partition.find(Partition.TYPE_APP)
data_parts = Partition.find(Partition.TYPE_DATA)
nvs_parts = Partition.find(Partition.TYPE_DATA, label='nvs') |
@dpgeorge: I have also reworked the flashdbev.py file so that it's using the newly created Partition class and the flashdrive is mounted on a named Partition that can be put anywhere: ** class FlashBdev:
size = esp.flash_size() Using this, PR #4987 isn't really necessary anymore. |
API is: from esp32 import Partition # Constructors Partition(Partition.FIRST, type=Partition.TYPE_APP) Partition(Partition.FIRST, type=Partition.TYPE_DATA) Partition(Partition.FIRST, type=Partition.TYPE_DATA, subtype=2, label='nvs') Partition(Partition.BOOT) Partition(Partition.RUNNING) # Methods part.metadata() # returns a 6-tuple of (type, subtype, addr, size, label, encr) part.readinto(offset, buf) part.write(offset, buf) part.erase(addr, size) part.set_boot() part.get_next_update() # returns new Partition
The argument is either an interger (BOOT/RUNNING) or a string label.
fba304c
to
058c74d
Compare
Thanks @Lisa999 for testing. I agree it'd be good to replace the existing flashbdev code to use this new Partition class. I've just pushed some small changes to the Partition constructor to simplify it now that the from esp32 import Partition
bootpart = Partition(Partition.BOOT)
runningpart = Partition(Partition.RUNNING)
fatfs = Partition('fatfs') For any more complex Partition lookup use I'm happy to merge this PR as it is now, then proceed to update flashbdev.py and partitions.csv in a separate PR. |
Ok, this was merged in 05eb897, with docs added, and also |
See #5027 for follow up. |
How were the OTA-related methods tested, e.g. esp32_partition_set_boot? As far as I know they require an ota_boot partition and none of the provided partition tables includes one, so I wonder... |
I did not test |
I did test 'set_boot()' and it's working just fine in my project... |
For me it is not working: #5471 Partition table and partitions look good but calling set_boot() gives me the error ESP_ERR_INVALID_ARG. EDIT: Working now =) I used ota_1 as first ota partition slot instead of ota_0 =/ |
…n-main Translations update from Weblate
Following on from the comment #3576 (comment) here is a proposal for a wrapper class for the ESP32 OTA/partition functions.
The API is based around a single Partition class. The constructor is used to create new Partition objects, and methods manipulate such objects.
I didn't yet test the OTA functionality
Edit: updated signatures for partition methods.