Binary to update ESP8266 firmware to Espressif firmware. Requires user to press buttons.

Dependencies:   BufferedSerial mbed

Fork of ESPQuickFlash by Christopher Haster

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "BufferedSerial.h"
00003 
00004 
00005 // Include the actual image
00006 #include "flash_image.h"
00007 
00008 // Cross include definitions
00009 //#define DEBUG 1
00010 #define LED_STATUS 1
00011 DigitalOut led_blue(LED_BLUE);
00012 DigitalOut led_green(LED_GREEN);
00013 
00014 #include "slip.h"
00015 #include "esp_command.h"
00016 
00017 
00018 int main() {
00019     ESPCommand<BufferedSerial> esp(D1, D0, PTC6); // Change PTC6 to user button on your platform
00020     led_blue = 1;
00021     led_green = 1;
00022     
00023     for (int i = 0; i < FLASH_COUNT; i++) {
00024         if (!esp.flash_write(
00025                 FLASH_PAGES[i].address, 
00026                 FLASH_PAGES[i].data, 
00027                 FLASH_PAGES[i].size))
00028             error("Error writing flash at 0x%05x!\r\n", FLASH_PAGES[i].address);
00029     }
00030     
00031     // Signal we're done
00032     printf("Finished\r\n");
00033     
00034     while (true) {
00035         led_green = !led_green; // toggle led
00036         wait(0.2f);
00037     }
00038 }