I'm searching for a way to flash an esp8266 programmatically, i.e, without user interaction (and especially without Arduino IDE)?

Assuming I can put the program to be flashed on the SPIFFS filesystem, is there a way to flash the esp with that file?

  • 2
    yes, but why store it in SPIFFS? see the ESP8266HTTPUpdateServer and ESP8266httpUpdate libraries examples
    – Juraj
    Jul 28, 2020 at 18:55
  • I said I wanted no user interaction. Besides, I don't want a server in my ESP.
    – larsb
    Jul 29, 2020 at 16:21
  • how do you get the file to SPIFFS? the ESP8266httpUpdate library downloads an update bin from a server and updates using the Updater object without storing the bin to SPIFFS.
    – Juraj
    Jul 29, 2020 at 16:35

1 Answer 1


Yes, it is (or at least WAS possible a few years ago) to have an ESP8266 self-program if you can get the file onto the file system, by using the Update core that is used by OTA and httpUpdate. This was a example program to do it, but I don't know if it still works. I would also suggest that you look at using LittleFS instead of SPIFFS as the latter has been depreciated.

#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("/firmware-update.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() {     
  • Perfect! This is exactly what I was looking for. Also thanks for the suggestion of LittleFS, I will consider it.
    – larsb
    Jul 29, 2020 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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