Can you help me out to understand if this is possible with ESP8266 / 32 ?

I have a main binary that i upload to the chip, let's call it A - that's done from arduino.

A starts to work, but communicates every couple of minutes with central server polling for a task.

If there is a task - let's call it B

A downloads it and stores it on SPIFFS.

Now what should happen is that A uploads it, reboots and B starts to work.

When B finishes it loads up again A and the circle closes - this process goes on forever.


1) Is it possible that a stored on SPIFFS binary file can be uploaded to the chip? Like OTA does via www.

2) Can i somehow store A onto the SPIFFS, so that when B finishes i reupload A ?

Thanks for any input into this

  • why don't you have a single program that does both A and B?
    – jsotola
    Commented Jan 5, 2019 at 23:18
  • Look at what ArduinoOTA does.
    – Majenko
    Commented Jan 5, 2019 at 23:19
  • @Majenko - right, but i would then have to ask for firmware via WWW i don't speak to Web server, i download the binary from a dedicated grid computing system. So maybe you know if i can i download binary to SPIFFS and upload to chip other way than OTA?
    – PeeS
    Commented Jan 5, 2019 at 23:44
  • @jsotola because B changes and is sent from a distributed system, has nothing to do with A. Binaries sent from distributed system will be different all the time.
    – PeeS
    Commented Jan 5, 2019 at 23:44
  • 2
    Look at what ArduinoOTA does. I say again. Look at what it does. Don't use it. Just look at what it does.
    – Majenko
    Commented Jan 5, 2019 at 23:45

2 Answers 2


The esp8266 Arduino package has 3 libraries for firmware update.

  • ArduinoOTA for upload from Arduino IDE
  • ESP8266HTTPUpdateServer for upload with web browser
  • ESP8266httpUpdate library to check a web server for new version of the firmware

I think i've found an answer to my question here


#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

#include "FS.h"

void setup() {
  Dir dir = SPIFFS.openDir("/");

  digitalWrite(BUILTIN_LED, LOW);

  File file = SPIFFS.open("/blinkESP.bin", "r");

  uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
  if (!Update.begin(maxSketchSpace, U_FLASH)) { //start with max available size

  while (file.available()) {
    uint8_t ibuffer[128];
    file.read((uint8_t *)ibuffer, 128);
    Serial.println((char *)ibuffer);
    Update.write(ibuffer, sizeof(ibuffer));


  digitalWrite(BUILTIN_LED, HIGH);

void loop() {


Will give it a try and revert back to confirm if it answers my question.

  • Confirmed,works like a charm. Flashes firmware with a file from SPIFFS.
    – PeeS
    Commented Jan 19, 2019 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.