2015-07-29 00:40:53 +00:00
|
|
|
/* A very simple OTA example
|
|
|
|
*
|
2016-02-08 05:58:31 +00:00
|
|
|
* Binds a TCP socket, reads an image from it over TFTP and then flashes live.
|
2015-07-29 00:40:53 +00:00
|
|
|
*
|
2016-02-08 05:58:31 +00:00
|
|
|
* For more information about esp-open-rtos OTA see https://github.com/SuperHouse/esp-open-rtos/wiki/OTA-Update-Configuration
|
2015-07-29 00:40:53 +00:00
|
|
|
*
|
|
|
|
* NOT SUITABLE TO PUT ON THE INTERNET OR INTO A PRODUCTION ENVIRONMENT!!!!
|
|
|
|
*/
|
|
|
|
#include "espressif/esp_common.h"
|
2015-10-06 12:04:19 +00:00
|
|
|
#include "esp/uart.h"
|
2015-07-29 00:40:53 +00:00
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "esp8266.h"
|
2015-08-10 04:50:32 +00:00
|
|
|
#include "ssid_config.h"
|
2015-07-29 00:40:53 +00:00
|
|
|
|
2015-08-04 04:50:50 +00:00
|
|
|
#include "ota-tftp.h"
|
2016-04-07 18:29:28 +00:00
|
|
|
#include "rboot-integration.h"
|
|
|
|
#include "rboot.h"
|
|
|
|
#include "rboot-api.h"
|
2015-07-29 00:40:53 +00:00
|
|
|
|
|
|
|
void user_init(void)
|
|
|
|
{
|
2015-10-06 12:04:19 +00:00
|
|
|
uart_set_baud(0, 115200);
|
|
|
|
|
2016-04-07 18:29:28 +00:00
|
|
|
rboot_config conf = rboot_get_config();
|
2015-08-04 04:50:50 +00:00
|
|
|
printf("\r\n\r\nOTA Basic demo.\r\nCurrently running on flash slot %d / %d.\r\n\r\n",
|
|
|
|
conf.current_rom, conf.count);
|
|
|
|
|
|
|
|
printf("Image addresses in flash:\r\n");
|
|
|
|
for(int i = 0; i <conf.count; i++) {
|
2015-09-05 02:54:09 +00:00
|
|
|
printf("%c%d: offset 0x%08x\r\n", i == conf.current_rom ? '*':' ', i, conf.roms[i]);
|
2015-08-04 04:50:50 +00:00
|
|
|
}
|
2015-07-29 00:40:53 +00:00
|
|
|
|
|
|
|
struct sdk_station_config config = {
|
|
|
|
.ssid = WIFI_SSID,
|
|
|
|
.password = WIFI_PASS,
|
|
|
|
};
|
|
|
|
sdk_wifi_set_opmode(STATION_MODE);
|
|
|
|
sdk_wifi_station_set_config(&config);
|
|
|
|
|
2015-08-04 04:50:50 +00:00
|
|
|
ota_tftp_init_server(TFTP_PORT);
|
2015-07-29 00:40:53 +00:00
|
|
|
}
|