-
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
OTA update panic when flash encryption is enabled (IDFGH-3512) #5467
Comments
I got below messages if I download image to ota_1 before start testing ota: I (27921) esp_https_ota: Starting OTA... rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) entry 0x40080648 W (185) boot.esp32: WDT reset info: APP CPU PC=0x400879e6 |
I just tried simple_ota_example with SECURE_FLASH_ENC_ENABLED=y, the panic is reproduceable but with different exception. I (3747) simple_ota_example: Starting OTA example Core 0 register dump: A2 : 0x3ffb7b34 A3 : 0x00000000 A4 : 0x3ffbb588 A5 : 0x00400000 Backtrace:0x4011bf7c:0x3ffc19c0 0x4008e82f:0x3ffc1a20 0x4008faca:0x3ffc1a50 0x4008c1c4:0x3ffc1a70 0x400901dd:0x3ffc1b00 0x400877b1:0x3ffc1b30 0x4008e82f: lmacTxFrame at ??:? 0x4008faca: ppProcessTxQ at ??:? 0x4008c1c4: ieee80211_output_process at ??:? 0x400901dd: ppTask at ??:? 0x400877b1: vPortTaskWrapper at /home/axel/esp/esp-idf/components/freertos/xtensa/port.c:143 ELF file SHA256: 984948d004f6930c Rebooting... rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) |
Hi @AxelLin, Is there any change in configuration which is causing crash? Can you share sdkconfig file? |
Hi @shubhamkulkarni97 $ idf.py encrypted-flash monitor I (4697) simple_ota_example: Starting OTA example Core 0 register dump: A2 : 0x00018cc3 A3 : 0xff5f99ce A4 : 0x00000002 A5 : 0x3ffbb134 A10 : 0x3ffbb13a A11 : 0x3ffc1806 A12 : 0x00000004 A13 : 0x00000013 Backtrace:0x4010ba1c:0x3ffc1810 0x008255fd:0x3ffc1830 |<-CORRUPTED ELF file SHA256: abbbb2bbd0e79f8d Rebooting... thanks, |
Hi @shubhamkulkarni97 |
Hi @AxelLin, |
Hi @shubhamkulkarni97 |
@AxelLin, Also can you run |
Hi @shubhamkulkarni97 |
D (8034) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=289, ridx=0 Core 0 register dump: A2 : 0x00000000 A3 : 0x00000ab4 A4 : 0x00019000 A5 : 0x3ffcb073 Backtrace:0x4012015e:0x3ffc1b60 0x40091dc1:0x3ffc1bd0 0x40091eb1:0x3ffc1bf0 0x40090237:0x3ffc1c30 0x400877f1:0x3ffc1c60 0x40091dc1: ppRxProtoProc at ??:? 0x40091eb1: ppRxPkt at ??:? 0x40090237: ppTask at ??:? 0x400877f1: vPortTaskWrapper at /home/axel/esp/esp-idf/components/freertos/xtensa/port.c:143 ELF file SHA256: 46ec82bc772be69b Rebooting... |
D (9126) HTTP_CLIENT: http_on_body 289 Core 0 register dump: A2 : 0x007323cd A3 : 0x3ffcb720 A4 : 0x3ffcb7f3 A5 : 0x829b2305 Backtrace:0x4011ffdf:0x3ffc1b60 0x40091dc1:0x3ffc1bd0 0x40091eb1:0x3ffc1bf0 0x40090237:0x3ffc1c30 0x400877f1:0x3ffc1c60 0x40091dc1: ppRxProtoProc at ??:? 0x40091eb1: ppRxPkt at ??:? 0x40090237: ppTask at ??:? 0x400877f1: vPortTaskWrapper at /home/axel/esp/esp-idf/components/freertos/xtensa/port.c:143 ELF file SHA256: 46ec82bc772be69b Rebooting... |
Just found redirect idf.monitor output does not show backtrace. |
I tried the other device and it does not hit panic. I attached the efuse summary output for comparison. Do you find anything wrong? |
Hi @shubhamkulkarni97 |
Hi @AxelLin, EFUSE summary looks good to me in both the cases, there is only change in order summary is displayed. The commands you used to enable flash encryption are also correct. We think there might be a race condition in hardware acceleration when flash encryption is enabled. Can you disable all hardware accelerators in mbedtls and try performing OTA on board which resulted in a crash? You can disable following options in sdkconfig:
Please share console logs after disabling mbedtls hardware acceleration. |
I have disabled all hw acceleratiors:
But still got panic, see attached log |
I run git bisec and found: dbdce93 is the first bad commit
components/spi_flash/CMakeLists.txt | 1 + Please check what's wrong in above commit. Note this issue also happen on release/v4.2 branch. BTW, seems you cannot reproduce this issue on your device. |
We have tried on multiple boards/modules on our side but so far have not been able to reproduce this issue. eFuse summary looks pretty similar for both devices that you had provided. Ordering issue in
Thanks. |
Hi @mahavirj
BTW, I tried revert commit dbdce93 on current master tree, then it works no matter SPI_FLASH_USE_LEGACY_IMPL is set or not. |
Hi @mahavirj @shubhamkulkarni97 I'm wondering if esp32 also needs similar fix as esp32s2 (commit bb0a95b) |
@AxelLin Thanks for sharing pointers, I am checking on this, will revert back soon. |
@AxelLin Update: Fix that you shared looks correct. It is not safe to invoke ROM API for disabling flash write protection whilst cache is enabled (it was regression that happened sometimes back). We are in process to add this fix (and backport upto |
When using set(), categories print in a non-deterministic order. As reported espressif/esp-idf#5467 (comment)
Just FYI, this issue was closed because the fix is in master tree. |
Backport fixes have been merged in |
In commit 309376f, it seems like regression was added to use ROM level API for disabling flash write protection. This started random firmware crashes (on specific modules) with exception `IllegalInstruction` during encrypted flash writes. Fix here removes relevant ROM API call, since disabling flash write protection is already ensured by caller of this API. Closes #5467
In commit 309376f, it seems like regression was added to use ROM level API for disabling flash write protection. This started random firmware crashes (on specific modules) with exception `IllegalInstruction` during encrypted flash writes. Fix here removes relevant ROM API call, since disabling flash write protection is already ensured by caller of this API. Closes #5467
Environment
Problem Description
I (44614) esp_https_ota: Starting OTA...
I (44616) esp_https_ota: Writing to partition subtype 17 at offset 0x260000
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x40197338: 17193723 00909990 7641dc07
0x40197338: rcUpdateRxDone at ??:?
Core 0 register dump:
PC : 0x4019733f PS : 0x00060f30 A0 : 0x800923da A1 : 0x3ffc66a0
0x4019733f: rcUpdateRxDone at ??:?
A2 : 0x3ffbab70 A3 : 0x0000007f A4 : 0x00000000 A5 : 0x00000001
A6 : 0xffffffff A7 : 0x00000001 A8 : 0x0000003b A9 : 0x000000ab
A10 : 0x0000003b A11 : 0x0000003b A12 : 0x00000006 A13 : 0x00000000
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x00000020 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x40082371 LEND : 0x40082379 LCOUNT : 0x00000027
0x40082371: esp_timer_impl_get_counter_reg at /home/axel/esp/esp-idf/components/esp_timer/src/esp_timer_impl_lac.c:126 (discriminator 2)
0x40082379: esp_timer_impl_get_counter_reg at /home/axel/esp/esp-idf/components/esp_timer/src/esp_timer_impl_lac.c:136 (discriminator 1)
Backtrace:0x4019733c:0x3ffc66a0 0x400923d7:0x3ffc66c0 0x400924b1:0x3ffc66e0 0x40090837:0x3ffc6720
0x4019733c: rcUpdateRxDone at ??:?
0x400923d7: ppRxProtoProc at ??:?
0x400924b1: ppRxPkt at ??:?
0x40090837: ppTask at ??:?
ELF file SHA256: b23a527b4da3c8f2
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6020
load:0x40078000,len:13524
ho 0 tail 12 room 4
load:0x40080400,len:3768
0x40080400: _init at ??:?
entry 0x40080648
Expected Behavior
It should just work.
Actual Behavior
panic.
Steps to reproduce
Just do OTA firmware update.
Code to reproduce this issue
I cannot share my application code, but what I did is the same as simple_ota_example or advanced_https_ota which calls esp_https_ota().
I have enabled flash encryption in development mode.
The firmware I'm updating is about 1.2M size.
Also note OTA was working fine when flash encryption is disabled.
The text was updated successfully, but these errors were encountered: