OTA Firmware update fails

Prasad
Posts: 48
Joined: Sun Jul 23, 2017 5:26 pm

OTA Firmware update fails

Postby Prasad » Sun Jul 04, 2021 1:31 pm

I'm attempting to update my device firmware using OTA. My current firmware version is V1 and I'm attempting to update to V2. The output of `esp_https_ota(&config)` function returns 'ESP_OK'. However, the application fails to boot after rebooting the device. Below is my log output,

Code: Select all

I (34903) FIRMWARE UPDATE: ESP_WIFI_MODE_STA >> http://www.domain.com/appv2.bin
I (34913) FIRMWARE UPDATE: Starting BLE provisioning
I (34919) FIRMWARE UPDATE: WIFI init - http://www.domain.com/appv2.bin
I (34934) wifi:wifi driver task: 3ffd5564, prio:23, stack:6656, core=0
I (34950) wifi:wifi firmware version: 91290e8
I (34950) wifi:wifi certification version: v7.0
I (34951) wifi:config NVS flash: enabled
I (34951) wifi:config nano formating: disabled
I (34956) wifi:Init data frame dynamic rx buffer num: 32
I (34960) wifi:Init management frame dynamic rx buffer num: 32
I (34966) wifi:Init management short buffer num: 32
I (34970) wifi:Init dynamic tx buffer num: 32
I (34975) wifi:Init static rx buffer size: 1600
I (34979) wifi:Init static rx buffer num: 10
I (34983) wifi:Init dynamic rx buffer num: 32
I (34988) wifi_init: rx ba win: 6
I (34991) wifi_init: tcpip mbox: 32
I (34995) wifi_init: udp mbox: 6
I (34999) wifi_init: tcp mbox: 6
I (35003) wifi_init: tcp tx win: 5744
I (35007) wifi_init: tcp rx win: 5744
I (35011) wifi_init: tcp mss: 1436
I (35016) wifi_init: WiFi IRAM OP enabled
I (35020) wifi_init: WiFi RX IRAM OP enabled
I (35029) wifi:mode : sta (30:ae:a4:f3:a9:cc)
I (35030) wifi:enable tsf
I (35033) FIRMWARE UPDATE: wifi_init_sta finished.
I (35037) FIRMWARE UPDATE: connect to ap SSID:xxxxxx password:xxxxxx
I (35057) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1
I (35059) wifi:state: init -> auth (b0)
I (35073) wifi:state: auth -> assoc (0)
I (35079) wifi:state: assoc -> run (10)
W (35096) wifi:<ba-add>idx:0 (ifx:0, 1c:8e:5c:71:19:7d), tid:5, ssn:0, winSize:64
I (35148) wifi:connected with xxxxxx, aid = 5, channel 6, BW20, bssid = 1c:8e:5c:71:19:7d
I (35149) wifi:security: WPA2-PSK, phy: bgn, rssi: -42
I (35153) wifi:pm start, type: 1

I (35227) wifi:APs beacon interval = 102400 us, DTIM period = 1
W (35457) wifi:<ba-add>idx:1 (ifx:0, 1c:8e:5c:71:19:7d), tid:0, ssn:0, winSize:64
I (36431) esp_netif_handlers: sta ip: 192.168.1.6, mask: 255.255.255.0, gw: 192.168.1.1
I (36432) FIRMWARE UPDATE: got ip:192.168.1.6
I (36435) FIRMWARE UPDATE: Starting OTA - http://www.domain.com/appv2.bin
I (37621) esp_https_ota: Starting OTA...
I (37622) esp_https_ota: Writing to partition subtype 17 at offset 0x810000
I (45911) esp_https_ota: Connection closed
I (45912) esp_image: segment 0: paddr=00810020 vaddr=3f400020 size=0770ch ( 30476) map
I (45932) esp_image: segment 1: paddr=00817734 vaddr=3ffb0000 size=02908h ( 10504) 
I (45941) esp_image: segment 2: paddr=0081a044 vaddr=40080000 size=05fd4h ( 24532) 
I (45953) esp_image: segment 3: paddr=00820020 vaddr=400d0020 size=145b0h ( 83376) map
I (46001) esp_image: segment 4: paddr=008345d8 vaddr=40085fd4 size=04a64h ( 19044) 
I (46011) esp_image: segment 5: paddr=00839044 vaddr=50000000 size=00010h (    16) 
I (46018) esp_image: segment 0: paddr=00810020 vaddr=3f400020 size=0770ch ( 30476) map
I (46038) esp_image: segment 1: paddr=00817734 vaddr=3ffb0000 size=02908h ( 10504) 
I (46044) esp_image: segment 2: paddr=0081a044 vaddr=40080000 size=05fd4h ( 24532) 
I (46058) esp_image: segment 3: paddr=00820020 vaddr=400d0020 size=145b0h ( 83376) map
I (46105) esp_image: segment 4: paddr=008345d8 vaddr=40085fd4 size=04a64h ( 19044) 
I (46116) esp_image: segment 5: paddr=00839044 vaddr=50000000 size=00010h (    16) 
E (46140) FIRMWARE UPDATE: Firmware upgrade SUCCESS
I (46141) wifi:state: run -> init (0)
I (46143) wifi:pm stop, total sleep time: 5179078 us / 10988554 us

W (46145) wifi:<ba-del>idx
W (46147) wifi:<ba-del>idx
I (46150) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
I (46207) wifi:flush txq
I (46208) wifi:stop sw txq
I (46209) wifi:lmac stop hw txq
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_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:5744
ho 0 tail 12 room 4
load:0x40078000,len:14272
load:0x40080400,len:3896
0x40080400: _init at ??:?

entry 0x4008065c
I (101) cpu_start: Pro cpu up.
I (101) cpu_start: Starting app cpu, entry point is 0x40080fd4
0x40080fd4: call_start_cpu1 at /Users/user/esp/esp-idf/components/esp_system/port/cpu_start.c:141

ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_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:5744
ho 0 tail 12 room 4
load:0x40078000,len:14272
load:0x40080400,len:3896
0x40080400: _init at ??:?

entry 0x4008065c
I (101) cpu_start: Pro cpu up.
I (101) cpu_start: Starting app cpu, entry point is 0x40080fd4
0x40080fd4: call_start_cpu1 at /Users/user/esp/esp-idf/components/esp_system/port/cpu_start.c:141

ets Jun  8 2016 00:22:57

Code: Select all

char* url = (char*)arg;
ESP_LOGI(TAG, "Starting OTA - %s", url);
        
esp_http_client_config_t config = {
	.url = url,
	.cert_pem = (char *)server_cert_pem_start,
	.event_handler = _http_event_handler,
};
        
esp_err_t ret = esp_https_ota(&config);
if (ret == ESP_OK) {
   indicate_ota_inprogress(false);
   ESP_LOGE(TAG, "Firmware upgrade SUCCESS");
   esp_restart();
} else {
   indicate_ota_inprogress(false);
   ESP_LOGE(TAG, "Firmware upgrade failed");
}
I have built firmware V1 using ESP-IDF V4.1 and firmware V2 using ESP-IDF V4.3. Could that be a problem with the bootloader? For testing purposes, I used `blink` binary file as V2

Any leads will be greatly appreciated!

Thanks in advance!

Leander
Posts: 28
Joined: Thu Sep 26, 2019 8:50 pm

Re: OTA Firmware update fails

Postby Leander » Mon Jul 05, 2021 10:34 am

What's your partition table?
Mark that the app partitions need to be aligned with 0x10000

Can you set the bootloader logging?

You should see somthing like this:

Code: Select all

I (36) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (43) qio_mode: Enabling default flash chip QIO
I (48) boot.esp32: SPI Speed      : 80MHz
I (53) boot.esp32: SPI Mode       : QIO
I (57) boot.esp32: SPI Flash Size : 16MB
I (62) boot: Enabling RNG early entropy source...
I (67) boot: Partition Table:
I (71) boot: ## Label            Usage          Type ST Offset   Length
I (78) boot:  0 nvs              WiFi data        01 02 00009000 00105000
I (86) boot:  1 otadata          OTA data         01 00 0010e000 00002000
I (93) boot:  2 ota_0            OTA app          00 10 00110000 00400000
I (101) boot:  3 ota_1            OTA app          00 11 00510000 00400000
I (108) boot:  4 storage          Unknown data     01 82 00910000 006e0000
I (116) boot:  5 coredump         Unknown data     01 03 00ff0000 00010000
I (123) boot: End of partition table
I (128) boot_comm: chip revision: 3, min. application chip revision: 0
I (135) esp_image: segment 0: paddr=0x00110020 vaddr=0x3f400020 size=0x630f4 (405748) map
I (279) esp_image: segment 1: paddr=0x0017311c vaddr=0x3ffbdb60 size=0x05f48 ( 24392) load
I (289) esp_image: segment 2: paddr=0x0017906c vaddr=0x40080000 size=0x00404 (  1028) load
I (289) esp_image: segment 3: paddr=0x00179478 vaddr=0x40080404 size=0x06ba0 ( 27552) load
I (308) esp_image: segment 4: paddr=0x00180020 vaddr=0x400d0020 size=0x13b67c (1291900) map
I (739) esp_image: segment 5: paddr=0x002bb6a4 vaddr=0x40086fa4 size=0x17ad8 ( 96984) load

I (794) boot: Loaded app from partition at offset 0x110000
I (794) boot: Disabling RNG early entropy source...
I (795) psram: This chip is ESP32-D0WD
I (799) spiram: Found 64MBit SPI RAM device
I (804) spiram: SPI RAM mode: flash 80m sram 40m
I (809) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (817) cpu_start: Pro cpu up.

Who is online

Users browsing this forum: Bing [Bot] and 86 guests