sqfmi / badgy

Home of Badgy - IoT Badge

Home Page:http://badgy.sqfmi.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to wake from DeepSleep

liorbp opened this issue · comments

commented

Hi there,

I just realized I did something stupid by calling some function directly from setup() that ends with the sequence below and now I'm unable to flash a new sketch

delay(1000);
ESP.deepSleep(1 - 1000000UL);

I noticed this in the README:

Note that if the ESP chip is in a deep sleep then it will not automatically respond to the upload request and you may see something like "error: espcomm open failed" when trying to upload. A manual restart of the ESP chip, using the power slide button, just prior to upload gives you a small window of time to upload.

I was trying everything, switching the button, run the flash command using esptool in a loop and connecting the badgy while it runs. Nothing I did allowed me to re-flash it.
My attempts will always end with:

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

I suspect that at some point the esptool failed to flash the firmware to the ESP-12F chip and it causes the fail at boot.
Any chance this would help?

Have you kept the OTA Sketch upload part from the example sketches? This is where you hold down the centre button of the joystick to get it into upload mode from a web interface. If you do that, it will keep the ESP8266 alive while it waits you to upload a BIN file. Ignore that, but now the ESP8266 is no longer running the sketch so will be able to be flashed. Can you post your whole code to this to see at what point you have added the sleep part?

commented

Unfortunately, I didn't keep the OTA Sketch upload section (as I said, stupid).
The sketch was something like the below code... is it game over to my badgy? :(

GxIO_Class io(SPI, SS, 0, 2);
GxEPD_Class display(io);

void setup()
{
  Serial.begin(115200);
  display.init();
  myfunc();
}

void loop()
{
}

void myfunc()
{
  delay(1000);
  ESP.deepSleep(1 - 1000000UL);
}

No, it's not game over... you have a delay in there of a second, and the boot up from sleep also takes some time. The quick way will just be a case of trying to upload your sketch to the board, and timing the off/on right so it (the USB 2 Serial chip) catches the ESP8266 in it's boot up and sketch loading state. What revision board do you have? You're not going to damage the chip or board, just keep pressing upload, and trying different timings from when you can see the Arduino IDE compiling and turning the badge off and on. Unplugging the USB from your computer may be easier than fiddling with the slide switch too.

A longer and harder way would be to manually upload some code to the ESP8266 using some Dupoint cables and connecting up power, ground, RT, TX and setting the GPIO appropriatley. But you would need an external serial programmer, even a spare Wemos D1 mini or Node MCU would do. As you have spotted in your link, the pins would need to be:

UART Download Mode (Programming): GPIO 0 - LOW, GPIO 2 - HIGH, GPIO 15 LOW.

This will force the chip into programming mode when you power it up and you are not relying on the Badgy USB2Serial chip catching it in time. Then you can upload at your leisure.

Steve

sorted??