Back to OTA partition fails
Posted: Thu May 24, 2018 12:56 pm
Im using small factory+bigger OTA partitions.
I can switch to factory partition from OTA very easy (using the function posted somewhere here in the forum) but board resets when im trying the opposite. So to be able to boot to factory im using first: which works as expected and i boot to factory.
This is my function it the factory which im using to set again OTA as next boot:
I've added additional prints for debug. Here is the output:
So it crashes on esp_ota_set_boot_partition(). My understanding is that if i erase otadata but keep ota i could set it as next boot again. Everything is working good except this error. Is there anything i am missing?
I can switch to factory partition from OTA very easy (using the function posted somewhere here in the forum) but board resets when im trying the opposite. So to be able to boot to factory im using first:
Code: Select all
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_region 0xd000 0x2000
This is my function it the factory which im using to set again OTA as next boot:
Code: Select all
void back_to_ota()
{
const esp_partition_t *next_partition = esp_ota_get_next_update_partition(NULL);
const esp_partition_t *configured = esp_ota_get_boot_partition();
const esp_partition_t *running = esp_ota_get_running_partition();
if (configured != running) {
ESP_LOGW(TAG, "Configured OTA boot partition at offset 0x%08x, but running from offset 0x%08x",
configured->address, running->address);
ESP_LOGW(TAG, "(This can happen if either the OTA boot data or preferred boot image become corrupted somehow.)");
}
ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08x)", running->type, running->subtype, running->address);
if (next_partition == NULL) {
ESP_LOGE(TAG, "next_partition is NULL!!");
vTaskDelay(2000 / portTICK_PERIOD_MS);
return;
}
ESP_LOGW(TAG, "esp_ota_set_boot_partition: %s...", next_partition->label);
esp_err_t err = esp_ota_set_boot_partition(next_partition);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_ota_set_boot_partition failed! err=0x%x", err);
return;
}
ESP_LOGI(TAG, "Done!");
esp_restart() ;
}
My partition table:I (13016) OTA: Running partition type 0 subtype 0 (offset 0x00010000)
W (13016) OTA: esp_ota_set_boot_partition: ota...
ets Jun 8 2016 00:22:57
rst:0x8 (TG1WDT_SYS_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:0x3fff0018,len:4
load:0x3fff001c,len:5640
load:0x40078000,len:0
ho 12 tail 0 room 4
load:0x40078000,len:15356
entry 0x4007862c
W (30) boot: PRO CPU has been reset by WDT.
W (30) boot: WDT reset info: PRO CPU PC=0x400822ed
0x400822ed: esp_intr_noniram_enable at /home/ubuntu/esp/esp-idf/components/esp32/intr_alloc.c:773
W (31) boot: WDT reset info: APP CPU PC=0x4008e66f
0x4008e66f: multi_heap_assert at /home/ubuntu/esp/esp-idf/components/heap/multi_heap.c:377
(inlined by) merge_adjacent at /home/ubuntu/esp/esp-idf/components/heap/multi_heap.c:239
I (37) boot: ESP-IDF v3.1-dev-1130-g92c469b5 2nd stage bootloader
I (43) boot: compile time 23:51:16
I (48) boot: Enabling RNG early entropy source...
I (53) boot: SPI Speed : 40MHz
I (57) boot: SPI Mode : DIO
I (61) boot: SPI Flash Size : 4MB
I (65) boot: Partition Table:
I (69) boot: ## Label Usage Type ST Offset Length
I (76) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (83) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (91) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (98) boot: 3 factory factory app 00 00 00010000 00100000
I (106) boot: 4 ota OTA app 00 10 00110000 00170000
I (113) boot: 5 storage Unknown data 01 82 00280000 00100000
I (121) boot: End of partition table
I (125) boot: Defaulting to factory image
I (130) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x2c18c (180620) map
I (202) esp_image: segment 1: paddr=0x0003c1b4 vaddr=0x3ffb0000 size=0x038ec ( 14572) load
I (208) esp_image: segment 2: paddr=0x0003faa8 vaddr=0x40080000 size=0x00400 ( 1024) load
0x40080000: _WindowOverflow4 at /home/ubuntu/esp/esp-idf/components/freertos/xtensa_vectors.S:1685
I (209) esp_image: segment 3: paddr=0x0003feb0 vaddr=0x40080400 size=0x00160 ( 352) load
I (218) esp_image: segment 4: paddr=0x00040018 vaddr=0x400d0018 size=0x8f68c (587404) map
0x400d0018: _flash_cache_start at ??:?
I (432) esp_image: segment 5: paddr=0x000cf6ac vaddr=0x40080560 size=0x0ffc4 ( 65476) load
I (460) esp_image: segment 6: paddr=0x000df678 vaddr=0x400c0000 size=0x00000 ( 0) load
I (460) esp_image: segment 7: paddr=0x000df680 vaddr=0x50000000 size=0x00008 ( 8) load
I (477) boot: Loaded app from partition at offset 0x10000
I (477) boot: Disabling RNG early entropy source...
I (478) cpu_start: Pro cpu up.
I (482) cpu_start: Starting app cpu, entry point is 0x40080ffc
0x40080ffc: start_cpu0_default at /home/ubuntu/esp/esp-idf/components/esp32/cpu_start.c:379 (discriminator 9)
I (0) cpu_start: App cpu up.
I (493) heap_init: Initializing. RAM available for dynamic allocation:
I (499) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (505) heap_init: At 3FFBC410 len 00023BF0 (142 KiB): DRAM
I (512) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (518) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (524) heap_init: At 40090524 len 0000FADC (62 KiB): IRAM
I (531) cpu_start: Pro cpu start user code
I (554) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Start ESP32 OTA: /factory. NVS: espmain
UUID: 31:be:a4:44:4f:ff. Version: 20180524131056/factory
Code: Select all
nvs,data,nvs,0x9000,0x4000,
otadata,data,ota,0xd000,0x2000,
phy_init,data,phy,0xf000,0x1000,
factory,app,factory,0x10000,1M,
ota,app,ota_0,,0x170000,
storage,data,spiffs,,1M,