Flashing Bin files to your ESP8266


#1

I think there’s some browser / router cache issue when using the Web Updater sketch (to be pasted in this thread later) to flash a bin file. The screenshot below was taken when I had one of my normal ESP’s waiting to be provisioned and shows an AP of ESPproMon, as expected.

But having flashed the Web Updater sketch to another ESP an AP appeared called PeaceFairApp.
Weird cache issue resized
So where is this PeaceFairApp AP coming from as it’s not in the Web Updater sketch? We haven’t used the PeaceFairApp AP name in our sketches / bin files for many weeks.
If I had been able to go through the provisioning process, with the regular ESP powered off and just the new one powered up it would have shown the PeaceFairApp AP but unfortunately my phone went crazy at this stage and required a reboot.

This probably explains why one ESPproMon user saw the following AP during provisioning.


I know they use Web Updater to flash bin files and the Blynk myPlant AP will be a “cache” from an earlier period in time. This then means provisioning will fail. So somehow this cache needs to be removed or we use one of the other bin flashing tools, and not Web Updater.

If this is the first time you have used Web Updater it shouldn’t be a problem. More to follow in due course.


#2

OK after further investigation I suspect it’s an EEPROM issue for the user with the Blynk myPlant AP name and maybe my PeaceFairApp AP.

Flashing sketches, bin files and “hello world” examples does not clear your ESP8266.

It clears RAM but not EEPROM. So if you have previously used your ESP with any other sketches that use EEPROM, like the Blynk my Plant examples then it will still be holding this data in EEPROM.

Ideally select a pristine ESP directly from it’s anti-static bag but failing this clear EEPROM before you start the ESPproMon provisioning process.

Below is a sketch that we use to clear all 512 bytes of EEPROM. We only use a few bytes of EEPROM but it makes sense to clear the whole 512 bytes. Ignore this sketch and use the one with OTA facility at Provisioning your ESP8266 with our server

/********************************************************************************************
  Clean512bytes
                       EEPROM-Cleaner v1.2.0 from http://www.esp8266.com/viewtopic.php?f=24&t=14710

                       Copyright (c) 2017 Helmut Stult (schinfo)

 ********************************************************************************************/

#include <EEPROM.h> 
#include <ESP8266WiFi.h>

// sizeBytes being the number of bytes you want to use.
// It's defined with "#define sizeBytes"
// Size can be anywhere between 4 and 4096 bytes (Default for ESP8266_deauther = 4096)
//#define sizeBytes 4096
#define sizeBytes 512 

// change it for lower or higher endByte (Default for ESP8266_deauther = 4096)
// normaly it's the same as sizeBytes
//#define endByte 4096
#define endByte 512  // just clear first 512 bytes

// change it for lower or higher startByte (Default = 0)
#define startByte 0

unsigned long ok = 0;
unsigned long nok = 0;
unsigned long tok = 0;


void setup()
{
  Serial.begin(115200);
  EEPROM.begin(sizeBytes);

  delay(100);

  Serial.println("**********************************************************************************************************");
  Serial.println("");
  Serial.print("    Write a char(255) / hex(FF) from byte ");
  Serial.print(startByte);
  Serial.print(" to ");
  Serial.print(endByte - 1);
  Serial.print(" into the EEPROM with a defined size of ");
  Serial.print("");
  Serial.print(sizeBytes);
  Serial.println(" Bytes");
  Serial.println("");
  Serial.println("**********************************************************************************************************");
  Serial.println("");

  Serial.println("             testing EEPROM for written bytes");
  Serial.println("");

  for (int i = startByte; i < endByte; ++i)
  {
    if (EEPROM.read(i) == 255) {
      ++ok;
    } else {
      ++nok;
    }
  }

  Serial.printf("               empty bytes: %6d\r\n", ok);
  Serial.printf("           not empty bytes: %6d\r\n", nok);
  Serial.println("");
  Serial.println("**********************************************************************************************************");
  Serial.println("");

  Serial.println("**********************************************************************************************************");
  Serial.println("");
  Serial.println("             Start clearing EEPROM... - Please wait!!!");
  Serial.println("");
  Serial.println("**********************************************************************************************************");

  delay(1000);

  // write a char(255) / hex(FF) from startByte until endByte into the EEPROM
  for (int i = startByte; i < endByte; ++i) {
    EEPROM.write(i, -1);
  }

  EEPROM.commit();

  delay(1000);

  Serial.println("");
  Serial.println("             testing EEPROM for clearing");
  Serial.println("");

  String test;
  for (int i = startByte; i < endByte; ++i)
  {
    if (EEPROM.read(i) == 255) {
      ++tok;
    }
  }
  Serial.println("**********************************************************************************************************");
  Serial.println("");
  if (tok = endByte - startByte) {
    Serial.println("             EEPROM killed correctly");
  } else
    Serial.println("             EEPROM not killed - ERROR !!!");

  Serial.println("");
  Serial.println("**********************************************************************************************************");
  Serial.println("");
  Serial.println("             Ready - You can remove your ESP8266 / LoLin");
  Serial.println("");
  Serial.println("**********************************************************************************************************");
}

void loop()
{
}

The sketch above can be used to clear EEPROM at any stage if you get into difficulty with the EEPROM clearing features of the ESPproMon app.


#3

Hmmm… when I had used this a few days ago, I made the switch to 4096 for both… It worked, but in your opinion is this change good, bad or ugly?


#4

I noticed the references to 4096 for the first time today. Not sure if that’s trying to clear SPIFFS but my understanding is that EEPROM is just 512 bytes. Certainly only need to clear 512 bytes for ESPproMon.