-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Change the partition table and bootloader by OTA (IDFGH-14686) #15428
Comments
Hi @fernandoeqc! Yes, the OTA update bootloader and partition table are not safe operations. You can do it if only necessary. If the goal is to update the partition table then it is necessary to update the bootloader. The old bootloader should be able to load the new app and partition table. If you still think that the bootloader should be updated too then you can split it into two tasks if the partition table is left at the same address.
Supporting it in the 4.x version will require some effort to backport these commits. It is not a simple task. I think it would be difficult to achieve that.
I also want to note that the partition table has an MD5 checksum but early versions do not have it. Please be aware of it, it has to be compatible with both versions. https://docs.espressif.com/projects/esp-idf/en/v4.2/esp32/api-guides/partition-tables.html#md5-checksum. The partition table offset is hardcoded in the bootloader and its address defines the max size of bootloader, so the part table can not be moved and have something in between. (Your image does not show the position of the partition table). The bootloader with secure version V1 can not be updated (the SB digest is allocated in front of the bootloader image). The commits above do not care about this case.
We do not have a hash for each partition. If the secure boot feature is enabled the app has an appended signature block at the end image. It is part of app images only. I do not see in issue with that. This approach can be also considered, use the intermediate parttition table, at least applies to your case.
|
It's still possible to overwrite the SB digest + Bootloader in case of host-based Secure Boot, right? Also, are there any other hard requirements similar to the ones about partition table offset update implicitly demanding bootloader updates (which, in turn, if I'm right in the question above, also implicitly requires updating the SB digest)? Or it's only a matter of shuffling them around (other than the risk of bricking the device)? |
@KonstantinKondrashov, Stage 0
Stage 1
Stage 2
Stage 3
I needed to change the 2º stage bootloader because some settings in my project changed from the old version to the new one. |
Hello @KonstantinKondrashov, I have many devices in the field running ESP-IDF v4.0.1, and I would like to change the bootloader and partition table in these devices. I am aware that changing the partition table or bootloader via OTA is not safe.
Setup specifications
Goal
Increase the 'nvs' partition add the 'log' partition at the end of the flash and change bootloader to make field devices compatible with a new design structure
Old partition table:
64K
128K
New partition table:
128K
800K
Steps
I think of two main workflows:
1:
2:
Possible partition re-writing methods:
Adapt ESP-IDF partitions_ota to change the partition table and bootloader. In my opinion, the biggest challenge is adapting functions, structs and enums from ESP-IDF v5.4 to ESP-IDF v4.0. For example, the struct
esp_https_ota_config_t
changed a lot and is used byesp_https_ota()
to specify the range to write the new OTA. The old structure does not have the data of where to start writing.Another method is using esp-idf-repartitioner as a reference to make the change. It uses the function
spi_flash_erase_range()
to erase the partition table andspi_flash_write()
to write the new partition table, which are functions that exist in IDF v4.0.In summary, I have some questions:
spi_flash_write()
, would I have a problem with the hash of each partition? Or maybe with the hash of the flash itself? Is there a way I can get around this?The text was updated successfully, but these errors were encountered: