Skip to content

[ESP32-P4 v1.3][ESP-IDF v6.0] flash encryption hangs h264 hardware encoder (IDFGH-17476) #18427

@mrigi

Description

@mrigi

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v6.0 release

Espressif SoC revision.

ESP32-P4 v1.3

Operating System used.

Linux

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

None

Development Kit.

Waveshare ESP32-P4-ETH

Power Supply used.

USB

What is the expected behavior?

I expect that after enabling flash encryption device will continue to work the way it been perfectly working without.

What is the actual behavior?

After enabling flash encryption device becomes literally unusable.
It triggers WDT here and there. With WDT disabled it just hangs.
But one step at a time. The main point of concern so far is h264 hw encoder.
On 5.5.1 it was dying within esp_h264_enc_process after some time.
On new v6.0 release it just dies at first call to esp_h264_enc_hw_new. Can't even get through it.

Steps to reproduce.

  1. enable flash encryption
  2. grab some video data into PSRAM buffer of let's say 800x600 UYVY at 30fps
  3. try to encode that buffer with hardware h264 encoder
  4. repeat for few mins

I use custom dvp board to grab frames, maybe it is related. But doubt.

Debug Logs.

Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
MEPC    : 0x4fc10a94  RA      : 0x4fc10d1e  SP      : 0x4ff2ba70  GP      : 0x4ff1e580  
--- 0x4fc10a94: ROM_Boot_Cache_WriteBack in ROM
--- 0x4fc10d1e: Cache_Config_L1_CORE0_ICache_Autoload in ROM
TP      : 0x4ff2c800  T0      : 0x4fc10cc4  T1      : 0xfffffff0  T2      : 0x0000ffff  
--- 0x4fc10cc4: Cache_Start_L2_Cache_Preload in ROM
S0/FP   : 0x0001e980  S1      : 0x485f8000  A0      : 0x00000010  A1      : 0x00000014  
A2      : 0x00000020  A3      : 0x485f8000  A4      : 0x3ff10000  A5      : 0x00000000  
A6      : 0x08000000  A7      : 0x4fc10a5c  S2      : 0x0001e980  S3      : 0x08000000  
--- 0x4fc10a5c: Cache_WriteBack_All_Gid in ROM
S4      : 0x00000000  S5      : 0x4fc10a5c  S6      : 0x00000004  S7      : 0x00000020  
--- 0x4fc10a5c: Cache_WriteBack_All_Gid in ROM
S8      : 0x4ff3ffdc  S9      : 0xf8000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x00000080  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
MSTATUS : 0x00011880  MTVEC   : 0x4ff00003  MCAUSE  : 0x00000018  MTVAL   : 0x00000000  
--- 0x4ff00003: _vector_table at ??:?
MHARTID : 0x00000000  

Stack memory:
4ff2ba70: 0x00000000 0x00000000 0x00000000 0x00000020 0x00000004 0x0001e980 0x00000000 0x485f8000
4ff2ba90: 0x00000080 0x00000020 0x4ff3ffd8 0x4fc10e5a 0x00000000 0x00000000 0x00000000 0x00000000
--- 0x4fc10e5a: Cache_Config_L1_CORE1_ICache_Autoload in ROM
4ff2bab0: 0x00000080 0x00000000 0x00000001 0x00000002 0x0001e980 0x485f8000 0x00000001 0x4fc10ec2
--- 0x4fc10ec2: Cache_Config_L1_CORE1_ICache_Autoload in ROM
4ff2bad0: 0x0001e980 0x485f8000 0x00000001 0x4ff127f4 0x4fc1a048 0x40003d0c 0x00000003 0x00000002
--- 0x4ff127f4: cache_ll_l2_writeback_cache_addr at /home/igi/.espressif/v6.0/esp-idf/components/hal/esp32p4/include/hal/cache_ll.h:662
--- (inlined by) cache_ll_writeback_addr at /home/igi/.espressif/v6.0/esp-idf/components/hal/esp32p4/include/hal/cache_ll.h:691
--- (inlined by) cache_hal_writeback_addr at /home/igi/.espressif/v6.0/esp-idf/components/hal/cache_hal.c:289
--- 0x4fc1a048: _printf_i in ROM
--- 0x40003d0c: heap_caps_aligned_calloc at /home/igi/.espressif/v6.0/esp-idf/components/heap/heap_caps.c:588
4ff2baf0: 0x00000080 0x00000000 0x48598000 0x00000001 0x0007e980 0x0001e980 0x00060000 0x4ff0a72a
--- 0x4ff0a72a: s_c2m_ops at /home/igi/.espressif/v6.0/esp-idf/components/esp_mm/esp_cache_msync.c:56
4ff2bb10: 0x00000000 0x48616980 0x00000002 0x00000001 0x0007e980 0x00000006 0x48598000 0x4ff0aa90
--- 0x4ff0aa90: esp_cache_msync at /home/igi/.espressif/v6.0/esp-idf/components/esp_mm/esp_cache_msync.c:151
4ff2bb30: 0x00000004 0x48597d98 0x00000003 0x00000002 0x0000001e 0x48597d98 0x00000004 0x0007e910
4ff2bb50: 0x00000001 0x4ff2bbcc 0x48598000 0x4001d054 0x0000001e 0x4ff2bbcc 0x00000400 0x4001cff2
--- 0x4001d054: esp_h264_cache_check_and_writeback at /home/igi/dev/esp32p4-test-1/firmware/managed_components/espressif__esp_h264/port/src/esp_h264_cache.c:13
--- 0x4001cff2: esp_h264_aligned_calloc at /home/igi/dev/esp32p4-test-1/firmware/managed_components/espressif__esp_h264/port/src/esp_h264_alloc.c:23
4ff2bb70: 0x00000001 0x4ff2bbcc 0x4ff5da00 0x00000080 0x0000000a 0x4ff2bbcc 0x0000002d 0x00000400
4ff2bb90: 0x4ff2bbcc 0x0007e910 0x00000001 0x4001d044 0x0000001e 0x48597d98 0x0000002d 0x48597d90
--- 0x4001d044: esp_h264_calloc_prefer at /home/igi/dev/esp32p4-test-1/firmware/managed_components/espressif__esp_h264/port/src/esp_h264_alloc.c:31
4ff2bbb0: 0x4ff2bd34 0x4ff2bbfc 0x48597e80 0x4001d980 0x4ff2bbf8 0x0000003c 0x00000001 0x0007e980
--- 0x4001d980: esp_h264_enc_hw_new_param at /home/igi/dev/esp32p4-test-1/firmware/managed_components/espressif__esp_h264/hw/src/esp_h264_enc_hw_param.c:366
4ff2bbd0: 0x00000000 0x00000000 0x00000001 0x48597d9c 0x4ff2bd34 0x48597d80 0x4ff2bd38 0x4001b506
--- 0x4001b506: esp_h264_enc_hw_new at /home/igi/dev/esp32p4-test-1/firmware/managed_components/espressif__esp_h264/hw/src/esp_h264_enc_single_hw.c:351
4ff2bbf0: 0x00000000 0x00000067 0x00000080 0x50084008 0x01e002d0 0x001e331a 0x0016e360 0x5645554f
4ff2bc10: 0x00000000 0x00000000 0xffffffff 0xffffffff 0x00000000 0x00000000 0xffffffff 0xffffffff
4ff2bc30: 0x00010002 0x00000002 0x00000002 0x00000002 0x00000002 0x00000000 0x00000000 0x00000000
4ff2bc50: 0x00000000 0x00000000 0x00000000 0x00000004 0x07002d01 0x00000006 0x00000000 0x00000000
4ff2bc70: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x4ff23848
4ff2bc90: 0x4ff2bd60 0x4ff2be10 0x4ff2bcc0 0x400152e6 0x0000001e 0x000007aa 0x00000004 0x00000002
--- 0x400152e6: frame_stream_loop_prepare at /home/igi/dev/esp32p4-test-1/firmware/main/frame_stream.c:135
4ff2bcb0: 0x00000000 0x00000000 0x4ff2be10 0x40011edc 0x48006500 0x480d1d80 0x00000000 0x00000000
--- 0x40011edc: app_main at /home/igi/dev/esp32p4-test-1/firmware/main/main.c:195
4ff2bcd0: 0x00000000 0x00000000 0x00000000 0x00000000 0x4353544e 0x00294d28 0x00000000 0x00000000
4ff2bcf0: 0x00000000 0x000002d0 0x000001e0 0x0000001e 0x00000000 0x000002d0 0x000001e0 0x480d1d80
4ff2bd10: 0x000cb800 0x00000000 0x00000000 0x48006500 0x000cb800 0x00000000 0x00000000 0x00000000
4ff2bd30: 0x480064ac 0x00000000 0x5645554f 0x02d01e2d 0x000001e0 0x0016e360 0x0000331a 0x00000000
4ff2bd50: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000200 0x00000000 0x00000000 0x00000000
4ff2bd70: 0x00000200 0x00000000 0x00000000 0x00000000 0x00000200 0x00000000 0x00000000 0x00000000
4ff2bd90: 0x00000200 0x00000000 0x00000000 0x00000000 0x00000200 0x00000000 0x00000000 0x00000000
4ff2bdb0: 0x00000200 0x00000000 0x00000000 0x00000000 0x00000200 0x00000000 0x00000000 0x00000000
4ff2bdd0: 0x00000200 0x00000000 0x00000000 0x00000000 0x00000027 0x00000000 0x00000000 0x00000000
4ff2bdf0: 0x0000001e 0x00000000 0xa7a03add 0x00000060 0x4ff4b8bc 0x48006488 0x480064ac 0x4800600c
4ff2be10: 0x53425643 0x5f504932 0x65303335 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4ff2be30: 0x00000000 0x00000000 0x00000000 0x00000000 0x05780000 0x473b4e8c 0x302e3031 0x332e302e
4ff2be50: 0x00000035 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x0001c200 0x00000001

Core  1 register dump:
MEPC    : 0x4ff07326  RA      : 0x4ff07314  SP      : 0x4ff2d890  GP      : 0x4ff1e580  
--- 0x4ff07326: esp_cpu_wait_for_intr at /home/igi/.espressif/v6.0/esp-idf/components/esp_hw_support/cpu.c:64
--- 0x4ff07314: esp_cpu_wait_for_intr at /home/igi/.espressif/v6.0/esp-idf/components/esp_hw_support/cpu.c:57
TP      : 0x4ff2d8f0  T0      : 0x00000000  T1      : 0x00000000  T2      : 0x00000000  
S0/FP   : 0x00000008  S1      : 0x00000001  A0      : 0x00000000  A1      : 0x4ff2d87f  
A2      : 0x7f000000  A3      : 0x00000004  A4      : 0x0000003c  A5      : 0x3ff06000  
A6      : 0x00000000  A7      : 0x00000000  S2      : 0x00000001  S3      : 0x00000000  
S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x00000000  T4      : 0x00000000  T5      : 0x00000000  T6      : 0x00000000  
MSTATUS : 0x00011880  MTVEC   : 0x4ff00003  MCAUSE  : 0x00000018  MTVAL   : 0x00000000  
--- 0x4ff00003: _vector_table at ??:?
MHARTID : 0x00000001  

Stack memory:
4ff2d890: 0x00000000 0x00000000 0x00000000 0x40055d80 0x00000000 0x00000000 0x00000000 0x4ff0f040
--- 0x40055d80: esp_vApplicationIdleHook at /home/igi/.espressif/v6.0/esp-idf/components/esp_system/freertos_hooks.c:58
--- 0x4ff0f040: prvIdleTask at /home/igi/.espressif/v6.0/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4297
4ff2d8b0: 0x00000000 0x00000000 0x00000000 0x4ff11150 0x00000000 0x00000000 0x00000000 0x00000000
--- 0x4ff11150: vPortTaskWrapper at /home/igi/.espressif/v6.0/esp-idf/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:262
4ff2d8d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
4ff2d8f0: 0x00000000 0x4ff2d31c 0x4ff2d31c 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5
4ff2d910: 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000170 0x4ff2d810 0x00000000 0x4ff21cd8 0x4ff2d1ac
4ff2d930: 0x4ff2d920 0x4ff21cd0 0x00000019 0x00000000 0x00000000 0x4ff2d920 0x00000000 0x00000000
4ff2d950: 0x4ff2d31c 0x454c4449 0x00000031 0x00000000 0x00000000 0x00000001 0x4ff2d910 0x00000006
4ff2d970: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00283ad3 0x00000000
4ff2d990: 0x00000000 0x4ff2567c 0x4ff256e4 0x4ff2574c 0x00000000 0x00000000 0x00000001 0x00000000
4ff2d9b0: 0x00000000 0x00000000 0x40009282 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
--- 0x40009282: esp_cleanup_r at /home/igi/.espressif/v6.0/esp-idf/components/esp_libc/src/newlib_init.c:42
4ff2d9d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4ff2d9f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4ff2da10: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4ff2da30: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4ff2da50: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
4ff2da70: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000200 0xd85ada56 0x4ff2d918
4ff2da90: 0x00000010 0x0006010a 0x00000035 0x00000000 0x4ff3b2f0 0x00000010 0x0001010a 0x00000050
4ff2dab0: 0x00000000 0x4ff2db1c 0x0000005c 0x00000000 0x4ff2dabc 0x00000000 0x00000000 0x00000000
4ff2dad0: 0x4ff2dad4 0xffffffff 0x4ff2dad4 0x4ff2dad4 0x00000000 0x4ff2dae8 0xffffffff 0x4ff2dae8
4ff2daf0: 0x4ff2dae8 0x00000001 0x00000001 0x00000000 0x06fb0000 0x00000000 0x5d7010ef 0x87660801
4ff2db10: 0xb33fffff 0x00000000 0x00000010 0x0003010a 0x00000036 0x00000000 0x00000000 0x00000080
4ff2db30: 0x34282049 0x29323335 0x70766420 0x696e695f 0x63203a74 0x6c706d6f 0x64657465 0x6472610a
4ff2db50: 0x53544e20 0x294d2843 0x3d772820 0x2c303237 0x343d6820 0x202c3038 0x3d737066 0x0a293033
4ff2db70: 0x63617020 0x2074656b 0x73746573 0x72617420 0x29746567 0x0a39310a 0x854a85d2 0xffcd2097
4ff2db90: 0x5cc080e7 0x842a4589 0x10ef852e 0x85225ad0 0x40b64426 0x49064496 0x5a6259f2 0x4ff2db28
4ff2dbb0: 0x0000005c 0x00000000 0x4ff2dbb4 0x00000000 0x00000000 0x00000000 0x4ff2dbcc 0xffffffff
4ff2dbd0: 0x4ff2dbcc 0x4ff2dbcc 0x00000000 0x4ff2dbe0 0xffffffff 0x4ff2dbe0 0x4ff2dbe0 0x00000001
4ff2dbf0: 0x00000001 0x00000000 0x06138600 0x00000000 0x2097e185 0x80e7ff04 0xb33fffff 0x00000000
4ff2dc10: 0x0000005c 0x00000000 0x4ff2dc14 0x00000000 0x00000000 0x00000000 0x4ff2dc2c 0xffffffff
4ff2dc30: 0x4ff2dc2c 0x4ff2dc2c 0x00000000 0x4ff2dc40 0xffffffff 0x4ff2dc40 0x4ff2dc40 0x00000001
4ff2dc50: 0x00000001 0x00000000 0x80e7ff00 0x00000000 0xc432c636 0xf0efc204 0xb33fffff 0x00000000
4ff2dc70: 0x00000048 0x4ff38304 0x4ff38328 0x4ff37ed4 0x4ff37a84 0x4ff37aac 0x4ff37664 0x4ff3721c

Diagnostic report archive.

idf-diag-439d837e-e276-4906-a7bb-4945ad4461ee.zip

More Information.

I suspect you encrypt PSRAM as well while flash encryption enabled. That would explain why it behaves so poorly and unreliably with encryption enabled. If so I hope you can add option to disable this for PSRAM to get back the performance as a trade off. For some people it is enough just to make flash unreadable. Runtime memory safety is not important. It is ok to decrypt firmware into memory and run from there unencrypted if that will restore performance and remove glitches.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions