I've a custom OTA update code which successfully downloads firmware over mqtt and writes to flash.
However, on calling to system_upgrade_reboot() at last, it either hangs or does not switch to the correct image (user1/user2) even though it attempt to do that at the end of system_upgrade_reboot() call.
I use latest 'esp-open-sdk' with nonos-sdk_v1.5.4, and ESP-12E (NodeMCU) with 32Mbit(1024KB+1024KB) flash map.
Here is what I see on the serial monitor:
1. on user2 as currently active
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x40100000, len 2408, room 16
tail 8
chksum 0xe5
load 0x3ffe8000, len 776, room 0
tail 8
chksum 0x84
load 0x3ffe8310, len 632, room 0
tail 8
chksum 0xd8
csum 0xd8
2nd boot version : 1.6
SPI Speed : 80MHz
SPI Mode : DIO
SPI Flash Size & Map: 32Mbit(1024KB+1024KB)
jump to run user2 @ 101000
rf[112] : 03
rf[113] : 00
rf[114] : 01
SDK ver: 1.5.4(baaeaebb) compiled @ May 17 2016 19:23:54
phy ver: 972, pp ver: 10.1
<my code here - that shows system info>
SDK version: 1.5.4(baaeaebb)
data : 0x3ffe8000 ~ 0x3ffec640, len: 17984
rodata: 0x3ffec640 ~ 0x3ffedfbc, len: 6524
bss : 0x3ffedfc0 ~ 0x3fff8060, len: 41120
heap : 0x3fff8060 ~ 0x3fffc000, len: 16288
Boot Version: 6
boot_mode: 1
Current userbin: user2.bin
Current userbin_addr: 0x101000
Free Heap: 16040
flash_size_map - FLASH_SIZE_32M_MAP_1024_1024
user_bin1_start = 1
user_bin2_start = 257
fw_bin_sec_num = 251
trying to connect to wifi with ssid: tritium
mode : sta(5c:cf:7f:1b:7a:5f)
add if0
.....
2. after firmware download and written to the flash, then trying to reboot:
....
Firmware upgrade success !
Agent is going to reboot into new firmware ...
...
reboot to use1 <--- attempt to reboot to user1 here
state: 5 -> 0 (0)
rm 0
pm close 7
connect to server lost !!! (my lwip implementation)
3fff8650 already freed <-- not sure why this appears?
del if0
usl
¦?K
¦D ¦\%¦¦u¦@¦Y+¦uB -))¦C )¦¦¦
¦LPA¦ I¦V¦-¦¦t¦¦ )l¦ 5Y
¦NRA¦
¦?^¦
R¦¦eE@¦T¦*5¦P)NRA¦
¦?
J¦
T p-¦Y5¦¦^Pj)5
5?!+a
A¦¦+¦qIsB¦ ? ¦¦VP¦V¦? 7¦+¦¦5B%I
! ¦I?
%
?B¦¦Y9AZ%.¦¦Z))@¦Z-nP¦Mt'?¦ %[
)Q
¦O¦¦T5¦¦)¦N9E )dP¦
5y¦
¦L¦C¦
I¦T1¦
¦¦TR¦¦¦C¦B¦Y
¦NPA¦ I¦^X-¦N9¦¦F )dP5¦Y(
NRA¦ i¦^t
J¦ -¦Y5¦MY
AEamB@¦A¦A 7¦5¦ a@H¦
+¦X[I
¦Ib¦VPV5\3¦P¦ ¦rf[112] : 03
rf[113] : 00
rf[114] : 01
SDK ver: 1.5.4(baaeaebb) compiled @ May 17 2016 19:23:54
phy ver: 972, pp ver: 10.1
SDK version: 1.5.4(baaeaebb)
data : 0x3ffe8000 ~ 0x3ffec640, len: 17984
rodata: 0x3ffec640 ~ 0x3ffedfbc, len: 6524
bss : 0x3ffedfc0 ~ 0x3fff8060, len: 41120
heap : 0x3fff8060 ~ 0x3fffc000, len: 16288
Boot Version: 6
boot_mode: 1
Current userbin: user2.bin <--- still on user2
Current userbin_addr: 0x101000
Free Heap: 16040
....
It showing garbage on the serial monitor (I use 74880 as baud rate) - is this due to wdt reset or something else?
Sequence of action on the code is as follows:
system_upgrade_userbin_check()
<calculate address to write new firmware i.e. 0x101000 or 0x01000>
system_upgrade_init();
system_upgrade_flag_set(UPGRADE_FLAG_START);
<write image here using spi_flash_erase_sector() & spi_flash_write() - 4bytes aligned>
<if success call system_upgrade_flag_set(UPGRADE_FLAG_FINISH)>
and call system_upgrade_reboot()
Any help on figuring out the cause would be really appreciated!
Thanks in advance
-Navin