Ordering problem with flash encryption
Posted: Mon Dec 27, 2021 11:39 pm
Having a problem performing operations with parttool.py after doing encrypted-flash. The error I get is as follows:
It seems like parttool.py is reading encrypted data and failing since it isn't decrypted before reading. More details:
I can reproduce this problem using the flash_encryption demo:
Thanks for suggestions.
Code: Select all
Traceback (most recent call last):
File "/Users/bschick/esp/esp-idf/components/partition_table/parttool.py", line 365, in <module>
main()
File "/Users/bschick/esp/esp-idf/components/partition_table/parttool.py", line 334, in main
target = ParttoolTarget(**target_args)
File "/Users/bschick/esp/esp-idf/components/partition_table/parttool.py", line 116, in __init__
partition_table = gen.PartitionTable.from_binary(f.read())
File "/Users/bschick/esp/esp-idf/components/partition_table/gen_esp32part.py", line 281, in from_binary
result.append(PartitionDefinition.from_binary(data))
File "/Users/bschick/esp/esp-idf/components/partition_table/gen_esp32part.py", line 433, in from_binary
res.name = res.name.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf4 in position 0: invalid continuation byte
Code: Select all
% idf.py --version
ESP-IDF v4.4-beta1-177-ge104dd7f27-dirty
MacOSx 12.1
target = esp32c3
- Enable development mode flash encryption withg defaults (secure boot not enabled)
- Did a normal plaintext "idf.py flash", rebooted, went through onchip generated key encryption process
- App runs, everything works (except my user NVS partition is empty)
- Update application code and run "idf.py encrypted-flash"
- Boot and running the app still works fine (but no user NVS partition)
- Run "iparttool.py -o 0x9000 erase_partition --partition-name storage" (or any other parttool command) (get the error above)
- Update just the partition table with "idf.py partition-table-flash" (I assume this write unencrypted part table)
- "parttool.py -o 0x9000 erase_partition --partition-name storage" now works as expected, but application will not boot due to "partition 0 invalid magic number" which I assume happens because the partition table is not encrypted
- If I run "idf.py encrypted-flash" the app starts, but the parttool.py fails with the error above.
Thanks for suggestions.