-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
esp_partition_write doesn't work on encrypted partition (IDFGH-4423) #6254
Comments
@jarcos-al Thanks for reporting and letting us know, we will look into. |
@jarcos-al Can you please provide your test application or minimal test code that reproduces this problem? |
@mahavirj This is the function code that reproduces this problem. Is a function console command that write in the encrypted flash partition the data entered by keyboard.
|
Is something known if in future versions this problem is solved? |
In which task context you call |
The task that manage this function is console_repl. Is a function that is called by a console command. THe stack size of this task is 8000. |
Can you please try changing following config option values to their default ones:
You have value for |
I have made the changes you have told me, but the problem has not been solved yet |
It is difficult to comment without reproducible application. Problem lies somewhere in task which is keeping CPU occupied for prolonged duration without yielding. You may read more on this at https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/wdts.html#task-watchdog-timer. One question: do you observe same behavior if you reduce partition size from 5M to something smaller? |
Yes, if I reduce the spiffs partition to 2M, when I run the command to write in the encrypted partition, the device prints this error: Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled. Core 0 register dump: A2 : 0x00000008 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3ffbce10 Backtrace:0x40194019:0x3ffbd610 0x4008ac39:0x3ffbd630 0x4008a28d:0x3ffbd650 0x4008ac39: prvIdleTask at /home/baintex/esp/esp-idf/components/freertos/tasks.c:3385 (discriminator 1) 0x4008a28d: vPortTaskWrapper at /home/baintex/esp/esp-idf/components/freertos/xtensa/port.c:143 ELF file SHA256: 0e1658ed6ead31f5 Rebooting... rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) entry 0x40080704 |
@jarcos-al Can you please try https://github.com/espressif/esp-idf/tree/master/examples/security/flash_encryption at your end once and see if it works as expected? We haven't been successful in reproducing this problem so far. |
Yes, the example works fine. Backtrace:0x400D7A60:0x3FFB0770 0x40084CFD:0x3FFB0790 0x4019E09B:0x3FFBE170 0x400D7D72:0x3FFBE190 0x4008EB91:0x3FFBE1B0 0x4008E171:0x3FFBE1D0 0x40084cfd: _xt_lowint1 at C:/esp/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1105 0x4019e09b: esp_pm_impl_waiti at C:/esp/esp-idf/components/esp32/pm_esp32.c:484 0x400d7d72: esp_vApplicationIdleHook at C:/esp/esp-idf/components/esp_common/src/freertos_hooks.c:63 0x4008eb91: prvIdleTask at C:/esp/esp-idf/components/freertos/tasks.c:3385 (discriminator 1) 0x4008e171: vPortTaskWrapper at C:/esp/esp-idf/components/freertos/xtensa/port.c:143 E (50807) task_wdt: Print CPU 1 backtrace Backtrace:0x40082102:0x3FFB0D70 0x40084CFD:0x3FFB0D90 0x40062252:0x3FFDD4C0 0x4009DF4B:0x3FFDD4E0 0x4009DF86:0x3FFDD510 0x4009E139:0x3FFDD540 0x4009E1D6:0x3FFD 0x40084cfd: _xt_lowint1 at C:/esp/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1105 0x4009df4b: esp_rom_spiflash_read_status at C:/esp/esp-idf/components/spi_flash/esp32/spi_flash_rom_patch.c:215 0x4009df86: esp_rom_spiflash_wait_idle at C:/esp/esp-idf/components/spi_flash/esp32/spi_flash_rom_patch.c:42 0x4009e139: esp_rom_spiflash_write_status at C:/esp/esp-idf/components/spi_flash/esp32/spi_flash_rom_patch.c:234 0x4009e1d6: esp_rom_spiflash_unlock at C:/esp/esp-idf/components/spi_flash/esp32/spi_flash_rom_patch.c:82 0x40085e1c: spi_flash_write_encrypted_chip at C:/esp/esp-idf/components/spi_flash/esp32/flash_ops_esp32.c:43 0x40085d5d: spi_flash_write_encrypted at C:/esp/esp-idf/components/spi_flash/flash_ops.c:473 0x4010077f: esp_partition_write at C:/esp/esp-idf/components/spi_flash/partition.c:398 0x400da071: writeESP32partition at C:\sentio\ESP32_MiniHUB\build/../main/drv/NVS/NVS_driver.c:39 0x4008954f: NVS_write_partition at C:\sentio\ESP32_MiniHUB\build/../main/drv/NVS/NVS_driver.c:128 0x400d8e11: set_credentials at C:\sentio\ESP32_MiniHUB\build/../main/drv/Console/MiniHub_Console.c:271 0x400fc21d: esp_console_run at C:/esp/esp-idf/components/console/commands.c:215 0x400fc2a2: esp_console_repl_thread at C:/esp/esp-idf/components/console/esp_console_repl.c:83 0x4008e171: vPortTaskWrapper at C:/esp/esp-idf/components/freertos/xtensa/port.c:143 |
@mahavirj , I have found the problem. I have unchecked "Support for SPI-connected RAM" option, and the code works fine. I do not know the reason for this failure |
(As I had mentioned in my previous reply) This error indicates problem with tasks running for prolonged time without yielding (e.g. some task running with tight loop). Please refer to documentation available at https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/wdts.html#task-watchdog-timer. You may try with larger timeout value for this timer (default is 5sec) or disable this configuration option for testing purpose.
Do you see similar problem if you keep this configuration enabled in https://github.com/espressif/esp-idf/tree/master/examples/security/flash_encryption example? Can you please modify this example such that it can reproduce problem you are seeing? |
After checking all the settings of the sdkconfig, comparing with the example project, I have verified that what produces the error is the option "Flash SPI speed = 80 MHz" in "Serial flasher config" together with the option "Support for external, SPI -RAM connected ". With these two options set in the example https://github.com/espressif/esp-idf/tree/master/examples/security/flash_encryption, the same error is reproduced. |
@jarcos-al Thank you for sharing latest findings. I can reproduce this issue locally now, will keep you posted about updates. |
A quick fix I don't know whether can help you. in the file And then, replace the code
with
|
Sorry for the long wait, I have fixed the issue(flash_encryption failed with 80M flash and 40M psram) with the patch below, could you please have a try? Thanks! |
Ok, I have downloaded this patch but git repport a problem with it. |
Hoo, maybe I ignore something, could you please try to fix it manually with what the patch shows now?🙂 I will upload a new patch tomorrow. |
…_encryption_write, Related espressif#6322, Related espressif#6254" This reverts commit c1b41ec.
…_encryption_write, Related espressif#6322, Related espressif#6254" This reverts commit c1b41ec.
Hi @jarcos-al , We have provided the patch of this issue , could you please have a try? I saw you have some work based on it, do you have any trouble using it? Michael |
Thanks for reporting and sharing updates, feel free to reopen. |
Environment
git describe --tags
to find it): v4.3-dev-dirtyxtensa-esp32-elf-gcc --version
to find it): esp-2020r2-8.2.0Problem Description
Hello, I have a problem with the flash encryption feature in my project. I have followed the steps that appear in the example esp-idf/examples/security/flash_encryption but when the program executes the function "esp_partition_write", the task hangs and does not continue. Furthermore any exception appears, only appears logs coming from task wdt because the task is hanged.
The data length that I am trying to write is multiple of 16 (128 bytes) with a offset 0. The partition is marked with the "encrypted" flag in the partition table.
If I remove the "encrypted" flag, the process runs correctly
Other items if possible
build
folder (note this may contain all the code details and symbols of your project.)files.zip
The text was updated successfully, but these errors were encountered: