//writethenewfirmwareintoflashbyspi_flash_write
}
• Set a software timer to check the upgrade status of the firmware periodically. If the
timer indicates a time-out, and the firmware has not been updated from the cloud
server, it means the upgrade failed. The status of the firmware upgrade will become
idle and the upgrade will stop.
• If the firmware has been successfully downloaded from the server, the upgrade status
will be shown as UPGRADE_FLAG_FINISH. Call function system_upgrade_reboot,
reboot ESP8266, and start running the newly updated firmware.
4. Compile the application program, generate firmware and download it into the ESP8266
module.
5. Power off the module, and change it to operation mode; then power on the module and
run the program.
Result:
• Establish a server at the PC terminal via the webserver, then upload user1.bin and
user2.bin to the same server. After the firmware has been programmed into
ESP8266, user1.bin will is run first by default, then user2.bin will be downloaded
from the server.
• The module will reboot automatically when user2.bin has been downloaded, and will
start running user2.bin. Until the next FOTA upgrade, ESP8266 will not run
user1.bin. When there is a new firmware on the server and a new FOTA upgrade is
requested by the users, user1.bin will be downloaded from the server. When the
module reboots automatically, user1.bin is run in this case. This process repeats.