OTA with binary copied from partition on external flash added at runtime

JayAhr
Posts: 3
Joined: Mon Mar 25, 2024 9:31 pm

OTA with binary copied from partition on external flash added at runtime

Postby JayAhr » Sat Oct 19, 2024 11:30 am

Hello again :)

I am working on a system where the half of the external flash memory was not assigned to a partition. That shall be changed now. But there are already some devices in the field, so I cannot just simply change the partition table via OTA update. At least that ist my understanding. Maybe that is wrong, and the partition table can be updated via OTA?

I was able to register a partition on the external flash via esp_partition_register_external(). I can read and write from that partition. The system runs the official micropython and calls the required IDF functions from micropython via user code.

But I have a problem when copying a new firmware image from that partition. I can successfully copy it to the OTA partition, but as soon as I call esp_ota_set_boot_partition(), the device hangs for the configured duration of the INT WDT and then reboots. So something is blocking the device from setting the boot partition and also from feeding the INT WDT.

Funny thing is: if the partition is not added at runtime but in the partition table, the WDT does not trigger a reboot.

I already have read the following issues:
https://github.com/thingsboard/thingsbo ... issues/158
-> here the problem was a dead lock in user code. The user code for OTA is almost directly used from an IDF example and does not involve mutexes.

viewtopic.php?t=5842
-> here the problem was insufficient stack for the underlying FreeRTOS. I have checked that the heap just before calling esp_partition_register_external:

Code: Select all

free heap               : 4277944
free heap DRAM          : 4309975
free heap SPI RAM       : 4134464
largest block on DRAM   : 4309975
largest block on SPI RAM: 4134464
So the problem seems to be somewhere else. Below you can find the log output. Are there any other things I can check?

Code: Select all

airq_ota_write()
V (189956) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
V (189956) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
V (189956) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
V (189966) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
V (189976) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
V (189976) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
V (189986) spi_flash: allocate temp buffer: 0x3ffdc234 (128)
airq_ota_write()
finished copying to OTA partition
calling ota_finish
airq_ota_finish()
INT WDT active: 1
INT WDT after reconfiguring : 5000
reconfiguring task WDT
airq_ota_finish: calling esp_ota_end...
D (190066) esp_image: reading image header @ 0x210000
D (190076) esp_image: image header: 0xe9 0x08 0x02 0x00 40081308
V (190076) esp_image: loading segment header 0 at offset 0x210018
V (190086) esp_image: segment data length 0xa2c00 data starts 0x210020
V (190096) esp_image: segment 0 map_segment 1 segment_data_offs 0x210020 load_addr 0x3f400020
I (190106) esp_image: segment 0: paddr=00210020 vaddr=3f400020 size=a2c00h (666624) map
D (190106) esp_image: free data page_count 0x00000035
V (190126) mmap: actual_mapped_len is 0xb0000
V (190326) esp_image: loading segment header 1 at offset 0x2b2c20
V (190326) esp_image: segment data length 0x52bc data starts 0x2b2c28
V (190326) esp_image: segment 1 map_segment 0 segment_data_offs 0x2b2c28 load_addr 0x3ffbdb60
I (190336) esp_image: segment 1: paddr=002b2c28 vaddr=3ffbdb60 size=052bch ( 21180)
D (190346) esp_image: free data page_count 0x00000035
V (190356) mmap: actual_mapped_len is 0x10000
V (190366) esp_image: loading segment header 2 at offset 0x2b7ee4
V (190366) esp_image: segment data length 0x400 data starts 0x2b7eec
V (190366) esp_image: segment 2 map_segment 0 segment_data_offs 0x2b7eec load_addr 0x40080000
I (190376) esp_image: segment 2: paddr=002b7eec vaddr=40080000 size=00400h (  1024)
D (190386) esp_image: free data page_count 0x00000035
V (190396) mmap: actual_mapped_len is 0x10000
V (190396) esp_image: loading segment header 3 at offset 0x2b82ec
V (190396) esp_image: segment data length 0x7d1c data starts 0x2b82f4
V (190406) esp_image: segment 3 map_segment 0 segment_data_offs 0x2b82f4 load_addr 0x40080400
I (190416) esp_image: segment 3: paddr=002b82f4 vaddr=40080400 size=07d1ch ( 32028)
D (190426) esp_image: free data page_count 0x00000035
V (190436) mmap: actual_mapped_len is 0x20000
V (190446) esp_image: loading segment header 4 at offset 0x2c0010
V (190446) esp_image: segment data length 0xfc47c data starts 0x2c0018
V (190446) esp_image: segment 4 map_segment 1 segment_data_offs 0x2c0018 load_addr 0x400d0018
I (190456) esp_image: segment 4: paddr=002c0018 vaddr=400d0018 size=fc47ch (1033340) map
D (190466) esp_image: free data page_count 0x00000035
V (190486) mmap: actual_mapped_len is 0x100000
V (190786) esp_image: loading segment header 5 at offset 0x3bc494
V (190786) esp_image: segment data length 0xa614 data starts 0x3bc49c
V (190796) esp_image: segment 5 map_segment 0 segment_data_offs 0x3bc49c load_addr 0x4008811c
I (190796) esp_image: segment 5: paddr=003bc49c vaddr=4008811c size=0a614h ( 42516)
D (190806) esp_image: free data page_count 0x00000035
V (190826) mmap: actual_mapped_len is 0x20000
V (190836) esp_image: loading segment header 6 at offset 0x3c6ab0
V (190836) esp_image: segment data length 0x64 data starts 0x3c6ab8
V (190836) esp_image: segment 6 map_segment 0 segment_data_offs 0x3c6ab8 load_addr 0x400c0000
I (190846) esp_image: segment 6: paddr=003c6ab8 vaddr=400c0000 size=00064h (   100)
D (190856) esp_image: free data page_count 0x00000035
V (190866) mmap: actual_mapped_len is 0x10000
V (190876) esp_image: loading segment header 7 at offset 0x3c6b1c
V (190876) esp_image: segment data length 0x810 data starts 0x3c6b24
V (190876) esp_image: segment 7 map_segment 0 segment_data_offs 0x3c6b24 load_addr 0x50000000
I (190886) esp_image: segment 7: paddr=003c6b24 vaddr=50000000 size=00810h (  2064)
D (190896) esp_image: free data page_count 0x00000035
V (190906) mmap: actual_mapped_len is 0x10000
V (190916) esp_image: image start 0x00210000 end of last section 0x003c7334
airq_ota_finish: calling esp_ota_end: 0
free heap               : 4277944
free heap DRAM          : 4309975
free heap SPI RAM       : 4134464
largest block on DRAM   : 4309975
largest block on SPI RAM: 4134464
airq_ota_finish: calling esp_ota_set_boot_partition...
D (190936) esp_image: reading image header @ 0x210000
D (190936) esp_image: image header: 0xe9 0x08 0x02 0x00 40081308
V (190946) esp_image: loading segment header 0 at offset 0x210018
V (190956) esp_image: segment data length 0xa2c00 data starts 0x210020
V (190956) esp_image: segment 0 map_segment 1 segment_data_offs 0x210020 load_addr 0x3f400020
I (190966) esp_image: segment 0: paddr=00210020 vaddr=3f400020 size=a2c00h (666624) map
D (190976) esp_image: free data page_count 0x00000035
V (190986) mmap: actual_mapped_len is 0xb0000
V (191186) esp_image: loading segment header 1 at offset 0x2b2c20
V (191186) esp_image: segment data length 0x52bc data starts 0x2b2c28
V (191196) esp_image: segment 1 map_segment 0 segment_data_offs 0x2b2c28 load_addr 0x3ffbdb60
I (191196) esp_image: segment 1: paddr=002b2c28 vaddr=3ffbdb60 size=052bch ( 21180)
D (191206) esp_image: free data page_count 0x00000035
V (191226) mmap: actual_mapped_len is 0x10000
V (191226) esp_image: loading segment header 2 at offset 0x2b7ee4
V (191236) esp_image: segment data length 0x400 data starts 0x2b7eec
V (191236) esp_image: segment 2 map_segment 0 segment_data_offs 0x2b7eec load_addr 0x40080000
I (191246) esp_image: segment 2: paddr=002b7eec vaddr=40080000 size=00400h (  1024)
D (191246) esp_image: free data page_count 0x00000035
V (191266) mmap: actual_mapped_len is 0x10000
V (191266) esp_image: loading segment header 3 at offset 0x2b82ec
V (191266) esp_image: segment data length 0x7d1c data starts 0x2b82f4
V (191276) esp_image: segment 3 map_segment 0 segment_data_offs 0x2b82f4 load_addr 0x40080400
I (191276) esp_image: segment 3: paddr=002b82f4 vaddr=40080400 size=07d1ch ( 32028)
D (191286) esp_image: free data page_count 0x00000035
V (191306) mmap: actual_mapped_len is 0x20000
V (191316) esp_image: loading segment header 4 at offset 0x2c0010
V (191316) esp_image: segment data length 0xfc47c data starts 0x2c0018
V (191316) esp_image: segment 4 map_segment 1 segment_data_offs 0x2c0018 load_addr 0x400d0018
I (191326) esp_image: segment 4: paddr=002c0018 vaddr=400d0018 size=fc47ch (1033340) map
D (191336) esp_image: free data page_count 0x00000035
V (191346) mmap: actual_mapped_len is 0x100000
V (191656) esp_image: loading segment header 5 at offset 0x3bc494
V (191656) esp_image: segment data length 0xa614 data starts 0x3bc49c
V (191656) esp_image: segment 5 map_segment 0 segment_data_offs 0x3bc49c load_addr 0x4008811c
I (191666) esp_image: segment 5: paddr=003bc49c vaddr=4008811c size=0a614h ( 42516)
D (191676) esp_image: free data page_count 0x00000035
V (191686) mmap: actual_mapped_len is 0x20000
V (191706) esp_image: loading segment header 6 at offset 0x3c6ab0
V (191706) esp_image: segment data length 0x64 data starts 0x3c6ab8
V (191706) esp_image: segment 6 map_segment 0 segment_data_offs 0x3c6ab8 load_addr 0x400c0000
I (191716) esp_image: segment 6: paddr=003c6ab8 vaddr=400c0000 size=00064h (   100)
D (191726) esp_image: free data page_count 0x00000035
V (191736) mmap: actual_mapped_len is 0x10000
V (191736) esp_image: loading segment header 7 at offset 0x3c6b1c
V (191736) esp_image: segment data length 0x810 data starts 0x3c6b24
V (191746) esp_image: segment 7 map_segment 0 segment_data_offs 0x3c6b24 load_addr 0x50000000
I (191756) esp_image: segment 7: paddr=003c6b24 vaddr=50000000 size=00810h (  2064)
D (191766) esp_image: free data page_count 0x00000035
V (191776) mmap: actual_mapped_len is 0x10000
V (191776) esp_image: image start 0x00210000 end of last section 0x003c7334
V (191786) mmap: actual_mapped_len is 0x10000
ets Jun  8 2016 00:22:57

rst:0x8 (TG1WDT_SYS_RESET),boot:0x33 (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:1
load:0x3fff8020,len:8
load:0x3fff8028,len:2128
load:0x4009fa00,len:19844
entry 0x400a05c4
I (561) cpu_start: Multicore app
V (561) mmap: after coalescing, 3 regions are left
I (561) quad_psram: This chip is ESP32-D0WD
I (564) esp_psram: Found 4MB PSRAM device
I (568) esp_psram: Speed: 40MHz
I (572) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode.
V (579) mmap: found laddr is 0x1800000
V (583) esp_psram: 8bit-aligned-range: 0x400000 B, starting from: 0x3f800000
I (590) cpu_start: Pro cpu up.
I (594) cpu_start: Starting app cpu, entry point is 0x400812cc
I (0) cpu_start: App cpu up.
I (1487) esp_psram: SPI SRAM memory test OK
D (1494) clk: RTC_SLOW_CLK calibration value: 3337306
I (1500) cpu_start: Pro cpu start user code
I (1500) cpu_start: cpu freq: 160000000 Hz
I (1500) cpu_start: Application information:
I (1505) cpu_start: Compile time:     Oct 17 2024 22:34:13
I (1511) cpu_start: ELF file SHA256:  efd5f43fda17ba53...
I (1517) cpu_start: ESP-IDF:          v5.1.2
I (1522) cpu_start: Min chip rev:     v0.0
I (1527) cpu_start: Max chip rev:     v3.99
I (1532) cpu_start: Chip rev:         v1.0
V (1537) memory_layout: reserved range is 0x3f4a30a0 - 0x3f4a30f0

Who is online

Users browsing this forum: No registered users and 71 guests