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

Dependencies:   BufferedSerial mbed

Fork of ESPQuickFlash by Christopher Haster

How to Use

This program will update the firmware on a connected ESP8266 to the Espressif Firmware. The user will need to put the ESP8266 board into FW Update mode and follow instructions as given on the serial console.

Between each block transfer power cycle the ESP8266 and put back into FW Update mode. On the Seeed Grove Serial WiFi module this requires a short press followed by a long press on the esp8266 reset button untill the light on the module goes red.

Terminal Settings

9600 baud 8-N-1

Video of how its done

Committer:
mbedAustin
Date:
Mon Apr 18 21:23:56 2016 +0000
Revision:
1:7cb29c3c51ac
Parent:
0:d84cdaf22096
Updated example to use 2wire board (Seeed Grove serial WiFi module) and ask for user input between files.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
geky 0:d84cdaf22096 1 #ifndef SLIP_H
geky 0:d84cdaf22096 2 #define SLIP_H
geky 0:d84cdaf22096 3
geky 0:d84cdaf22096 4 // Packet wrapping using the SLIP protocol
geky 0:d84cdaf22096 5 template <typename SERIAL>
geky 0:d84cdaf22096 6 class SLIPPacket {
geky 0:d84cdaf22096 7 private:
geky 0:d84cdaf22096 8 SERIAL _serial;
geky 0:d84cdaf22096 9
geky 0:d84cdaf22096 10 public:
geky 0:d84cdaf22096 11 SLIPPacket(PinName tx, PinName rx) : _serial(tx, rx) {}
geky 0:d84cdaf22096 12
geky 0:d84cdaf22096 13 int checkgetc() {
geky 0:d84cdaf22096 14 Timer timer;
geky 0:d84cdaf22096 15 timer.start();
geky 0:d84cdaf22096 16
geky 0:d84cdaf22096 17 while (!_serial.readable()) {
geky 0:d84cdaf22096 18 if (timer.read_ms() > 1500)
geky 0:d84cdaf22096 19 return -1;
geky 0:d84cdaf22096 20 }
geky 0:d84cdaf22096 21
geky 0:d84cdaf22096 22 int c = _serial.getc();
geky 0:d84cdaf22096 23 #ifdef DEBUG
geky 0:d84cdaf22096 24 printf("<- 0x%02x\r\n", c);
geky 0:d84cdaf22096 25 #endif
geky 0:d84cdaf22096 26 return c;
geky 0:d84cdaf22096 27 }
geky 0:d84cdaf22096 28
geky 0:d84cdaf22096 29 int checkputc(char c) {
geky 0:d84cdaf22096 30 wait_us(100);
geky 0:d84cdaf22096 31
geky 0:d84cdaf22096 32 while (!_serial.writeable())
geky 0:d84cdaf22096 33 ;
geky 0:d84cdaf22096 34
geky 0:d84cdaf22096 35 #ifdef DEBUG
geky 0:d84cdaf22096 36 printf("-> 0x%02x\r\n", c);
geky 0:d84cdaf22096 37 #endif
geky 0:d84cdaf22096 38 return _serial.putc(c);
geky 0:d84cdaf22096 39 }
geky 0:d84cdaf22096 40
geky 0:d84cdaf22096 41 void flush() {
geky 0:d84cdaf22096 42 while (_serial.readable())
geky 0:d84cdaf22096 43 _serial.getc();
geky 0:d84cdaf22096 44 }
geky 0:d84cdaf22096 45
geky 0:d84cdaf22096 46 public:
geky 0:d84cdaf22096 47 bool req_start() {
geky 0:d84cdaf22096 48 #ifdef LED_STATUS
geky 0:d84cdaf22096 49 led_blue = 0; // Show progress
geky 0:d84cdaf22096 50 #endif
geky 0:d84cdaf22096 51 return !(checkputc(0xc0) < 0);
geky 0:d84cdaf22096 52 }
geky 0:d84cdaf22096 53
geky 0:d84cdaf22096 54 bool req_finish() {
geky 0:d84cdaf22096 55 #ifdef LED_STATUS
geky 0:d84cdaf22096 56 led_blue = 1; // Show progress
geky 0:d84cdaf22096 57 #endif
geky 0:d84cdaf22096 58 return !(checkputc(0xc0) < 0);
geky 0:d84cdaf22096 59 }
geky 0:d84cdaf22096 60
geky 0:d84cdaf22096 61 bool putc(char c) {
geky 0:d84cdaf22096 62 switch (c) {
geky 0:d84cdaf22096 63 case 0xdb: return checkputc(0xdb) >= 0 && checkputc(0xdd) >= 0;
geky 0:d84cdaf22096 64 case 0xc0: return checkputc(0xdb) >= 0 && checkputc(0xdc) >= 0;
geky 0:d84cdaf22096 65 default: return checkputc(c) >= 0;
geky 0:d84cdaf22096 66 }
geky 0:d84cdaf22096 67 }
geky 0:d84cdaf22096 68
geky 0:d84cdaf22096 69 bool send(const void *data, int len) {
geky 0:d84cdaf22096 70 for (int i = 0; i < len; i++) {
geky 0:d84cdaf22096 71 if (!putc(((char *)data)[i]))
geky 0:d84cdaf22096 72 return false;
geky 0:d84cdaf22096 73 }
geky 0:d84cdaf22096 74
geky 0:d84cdaf22096 75 return true;
geky 0:d84cdaf22096 76 }
geky 0:d84cdaf22096 77
geky 0:d84cdaf22096 78 public:
geky 0:d84cdaf22096 79 bool resp_start() {
geky 0:d84cdaf22096 80 return checkgetc() == 0xc0;
geky 0:d84cdaf22096 81 }
geky 0:d84cdaf22096 82
geky 0:d84cdaf22096 83 bool resp_finish() {
geky 0:d84cdaf22096 84 return checkgetc() == 0xc0;
geky 0:d84cdaf22096 85 }
geky 0:d84cdaf22096 86
geky 0:d84cdaf22096 87 int getc() {
geky 0:d84cdaf22096 88 int c = checkgetc();
geky 0:d84cdaf22096 89
geky 0:d84cdaf22096 90 if (c < 0) {
geky 0:d84cdaf22096 91 return -1;
geky 0:d84cdaf22096 92 } else if (c == 0xdb) {
geky 0:d84cdaf22096 93 c = checkgetc();
geky 0:d84cdaf22096 94 switch (c) {
geky 0:d84cdaf22096 95 case 0xdd: return 0xdb;
geky 0:d84cdaf22096 96 case 0xdc: return 0xc0;
geky 0:d84cdaf22096 97 default: return -1;
geky 0:d84cdaf22096 98 }
geky 0:d84cdaf22096 99 } else {
geky 0:d84cdaf22096 100 return c;
geky 0:d84cdaf22096 101 }
geky 0:d84cdaf22096 102 }
geky 0:d84cdaf22096 103
geky 0:d84cdaf22096 104 bool recv(void *resp, int len) {
geky 0:d84cdaf22096 105 for (int i = 0; i < len; i++) {
geky 0:d84cdaf22096 106 int c = getc();
geky 0:d84cdaf22096 107
geky 0:d84cdaf22096 108 if (c < 0)
geky 0:d84cdaf22096 109 return false;
geky 0:d84cdaf22096 110
geky 0:d84cdaf22096 111 if (resp)
geky 0:d84cdaf22096 112 ((char *)resp)[i] = c;
geky 0:d84cdaf22096 113 }
geky 0:d84cdaf22096 114
geky 0:d84cdaf22096 115 return true;
geky 0:d84cdaf22096 116 }
geky 0:d84cdaf22096 117 };
geky 0:d84cdaf22096 118
geky 0:d84cdaf22096 119 #endif