Over-the-air update: Panic happens when esp_ota_end() is called

henrysshunt
Posts: 10
Joined: Thu Jun 22, 2023 10:30 am

Re: Over-the-air update: Panic happens when esp_ota_end() is called

Postby henrysshunt » Mon Oct 16, 2023 2:50 pm

We managed to fix our issue.

In one of the modules of our application, we had a uint8_t* global that was initialised to point to a const string. We were then modifying that variable, meaning we were modifying constant program data. Changing the variable to an array that is initialised to the value of the const string was the fix.

Though, we're still not clear why exactly that would be causing an issue with the verifiction of a new firmware image, nor why it would panic instead of just returning an error code. If anyone has any thoughts on that it would be nice to know.

zeboxer
Posts: 5
Joined: Wed Aug 23, 2023 8:25 am

Re: Over-the-air update: Panic happens when esp_ota_end() is called

Postby zeboxer » Sun Oct 22, 2023 11:38 am

@henrysshunt,
You are right. Main cause in firmware or sizing of partition.
I tried use simple_ota_example and OTA work fine. The example sizing partitions automatically:

Code: Select all

# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
ota_0,app,ota_0,0x110000,1M,
ota_1,app,ota_1,0x210000,1M,
OTA update work properly, in example:

Code: Select all

I (9725) esp_https_ota: Starting OTA...
I (9725) esp_https_ota: Writing to partition subtype 16 at offset 0x110000
I (32215) esp_image: segment 0: paddr=00110020 vaddr=3c0a0020 size=2b630h (177712) map
I (32235) esp_image: segment 1: paddr=0013b658 vaddr=3fc96d00 size=0445ch ( 17500) 
I (32245) esp_image: segment 2: paddr=0013fabc vaddr=40374000 size=0055ch (  1372) 
I (32245) esp_image: segment 3: paddr=00140020 vaddr=42000020 size=98934h (624948) map
I (32335) esp_image: segment 4: paddr=001d895c vaddr=4037455c size=1276ch ( 75628) 
--> try to free handler (it):
--> free handler (it): done!
I (32345) esp_image: segment 0: paddr=00110020 vaddr=3c0a0020 size=2b630h (177712) map
I (32375) esp_image: segment 1: paddr=0013b658 vaddr=3fc96d00 size=0445ch ( 17500) 
I (32375) esp_image: segment 2: paddr=0013fabc vaddr=40374000 size=0055ch (  1372) 
I (32385) esp_image: segment 3: paddr=00140020 vaddr=42000020 size=98934h (624948) map
I (32475) esp_image: segment 4: paddr=001d895c vaddr=4037455c size=1276ch ( 75628) 
I (32525) simple_ota_example: OTA Succeed, Rebooting...

But when I try update firmware in my app i get error in verify step.
I think main cause in partition size, but I can't figure out where exactly(

This my app partitions size:

Code: Select all

# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,16K,
otadata,data,ota,0xd000,8K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1700K,
ota_0,app,ota_0,0x1c0000,1700K,
ota_1,app,ota_1,0x370000,1700K,
data_fs,data,spiffs,0x519000,300K,
Update process panic at esp_image segmentation step:

Code: Select all

I (30714) esp_image: segment 0: paddr=001c0020 vaddr=3c0a0020 size=2b630h (177712) map

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0x28 (SPI_FAST_FLASH_BOOT)
Saved PC:0x420044eb
0x420044eb: panic_handler at P:/Programming/ESP/esp-idf/components/esp_system/port/panic_handler.c:145 (discriminator 3)

SPIWP:0xee
mode:DIO, clock div:2
load:0x3fce3810,len:0x18ec
load:0x403c9700,len:0x4
load:0x403c9704,len:0xf24
load:0x403cc700,len:0x2fcc
SHA-256 comparison failed:
Calculated: 4f5e7e96f0b41a0c8501c0d3b475a6b3b2c5a96615098922c23b81cf319800aa
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
Anybody know how to determine main problem?

zeboxer
Posts: 5
Joined: Wed Aug 23, 2023 8:25 am

Re: Over-the-air update: Panic happens when esp_ota_end() is called

Postby zeboxer » Mon Nov 06, 2023 3:04 pm

@henrysshunt, thank you very much! I fixed issue with the same way as you said.
I reviewed and refactored each line of code and find issue with my global vars.

I have gpio_fn.h where declared prototypes of global vars:

Code: Select all

extern QueueHandle_t gpio_event_queue;
extern QueueHandle_t gpio_mqtt_event_queue;
and gpio_fn.c

Code: Select all

QueueHandle_t gpio_event_queue;
QueueHandle_t gpio_mqtt_event_queue;
after change gpio_fn.c to default init values:

Code: Select all

QueueHandle_t gpio_event_queue=NULL;
QueueHandle_t gpio_mqtt_event_queue=NULL;
OTA update works

Code: Select all

....
....
....
I (63784) esp-rest: HTTP_EVENT_ON_DATA, len=512
I (63784) esp-rest: HTTP_EVENT_ON_DATA, len=512
I (63784) esp-rest: HTTP_EVENT_ON_DATA, len=320
I (63804) esp_image: segment 0: paddr=001c0020 vaddr=3c110020 size=4ae70h (306800) map
I (63844) esp_image: segment 1: paddr=0020ae98 vaddr=3fc9b400 size=04d80h ( 19840) 
I (63844) esp_image: segment 2: paddr=0020fc20 vaddr=40374000 size=003f8h (  1016) 
I (63854) esp_image: segment 3: paddr=00210020 vaddr=42000020 size=10cd78h (1101176) map
I (64004) esp_image: segment 4: paddr=0031cda0 vaddr=403743f8 size=16f9ch ( 94108) 
--> try to free handler (it):
--> free handler (it): done!
I (64014) esp-rest: HTTP_EVENT_DISCONNECTED
I (64014) esp-rest: HTTP_EVENT_DISCONNECTED
I (64024) esp_image: segment 0: paddr=001c0020 vaddr=3c110020 size=4ae70h (306800) map
I (64064) esp_image: segment 1: paddr=0020ae98 vaddr=3fc9b400 size=04d80h ( 19840) 
I (64074) esp_image: segment 2: paddr=0020fc20 vaddr=40374000 size=003f8h (  1016) 
I (64074) esp_image: segment 3: paddr=00210020 vaddr=42000020 size=10cd78h (1101176) map
I (64234) esp_image: segment 4: paddr=0031cda0 vaddr=403743f8 size=16f9ch ( 94108) 
I (64294) esp-rest: OTA Succeed, Rebooting...

Who is online

Users browsing this forum: No registered users and 261 guests