Chat freely about anything...

User avatar
By rekod
#5157 I wrote a custom FW (not based on "AT commands firmware", but it uses code snippets from there) and it does OTA download and upgrade without errors.
Here is old topic: http://www.esp8266.com/viewtopic.php?f=6&t=860

FW OTA upgrade logic is simple:
1. FW checks what SPI Flash user bank (see memory map with OTA support: https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map) currently used by FW with system_upgrade_userbin_check() which returns current bank UPGRADE_FW_BIN1 or UPGRADE_FW_BIN2
2. FW executes system_upgrade_start(struct upgrade_server_info *server) with a file to download opposite to current bank, i.e. if current bank is UPGRADE_FW_BIN1, then it downloads User2.bin, and vice versa.
3. On FW upgrade download and upgrade complete, it executes a callback where cheks if download was OK and then executes system_upgrade_reboot() to boot new FW.

Expected result:
If old FW was in UPGRADE_FW_BIN1 and downlads User2.bin - it should boot from UPGRADE_FW_BIN2 bank after restart.

Actual result:
FW always boots from UPGRADE_FW_BIN1 SPI Flash bank.

Code: Select all+MSG: fw_upgrade
 +OK: FW upgrade started.
 +OK: FW upgrade success.

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x40100000, len 612, room 16
tail 4
chksum 0x12
load 0x3ffe8000, len 788, room 4
tail 0
chksum 0x50
load 0x3ffe8314, len 264, room 8
tail 0
chksum 0x4a
csum 0x4a

2nd boot version : 1.1
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size : 4Mbit
jump to run user1

 +OK: ESP8266 platform started!


Questions:
1. Has anybody the source code of boot_v1.1.bin file from Espressif SDK ?
2. How boot_v1.1.bin decides which user bank (1 or 2) to boot at startup? any settings in SPI Flash?
User avatar
By Athena
#5593 server->check_cb = user_esp_platform_upgrade_rsp; // regist a callback
server->check_times = 120000; // set timeout

If upgrade download succeed or timeout, it goes to the callback (user_esp_platform_upgrade_rsp),
in user_esp_platform_upgrade_rsp, check if upgrade download succeed: if (server->upgrade_flag == true)
if upgrade download succeed, call system_upgrade_reboot() to boot and run user2.

Next time, the same flow, run user1.
User avatar
By reaper7
#5600 @Athena - this method works correctly for me

small example in attachment (support SMARTLINK for config sta mode too)
(debug only on uart1!!!, ota server IP definition and selecion of sdk inside include/user_config.h )
(16.24 KiB) Downloaded 487 times


when esp connect to ap try to open internet browser and type:
- http://YourEspIP/ for simple page (reload every 30s.)
- http://YourEspIP/ota for execute ota upgrade

this is very fast method and I like it :D
but the same example do not work anymore on SDK 0.9.4 :?: :?:
simple change Your sdk to 0.9.4 and replace definition inside include/user_config.h and check it

this is very bad!
User avatar
By alonewolfx2
#5616 its not working for me :( i can use my server with at_cloud example from Bananis and i can use cloud update. but your example not working. i can see esp webserver main page "ESP8266 OTA TEST UPTIME 102874139" but espip/ota not working. i tried espip/OTA but its not working too
Edit: i found something. here is webrequest in your otaupdate.c
Code: Select allos_sprintf(upServer->url,"GET /v1/device/rom/?action=download_rom&version=%s&filename=user%d.bin HTTP/1.1\r\nHost: "IPSTR":%d\r\n\r\n",upServer->upgrade_version,user_bin_n,IP2STR(upServer->ip),upServer->port);
   
and here is webrequest in Bananis's at_cloud example. is it same ? or you are using defferent default.aspx?
Code: Select all os_sprintf(temp,"GET /v1/device/rom/?is_format_simple=true HTTP/1.0\r\nHost: "IPSTR":%d\r\n"pheadbuffer"",