0

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.

Questions:

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 Jan 5 at 23:18
  • Look at what ArduinoOTA does. – Majenko Jan 5 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 Jan 5 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 Jan 5 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 Jan 5 at 23:45
0

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
0

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

https://www.esp8266.com/viewtopic.php?f=32&t=11324

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

#include "FS.h"



void setup() {
  Serial.begin(115200);
  Serial.println();
  SPIFFS.begin();
  Dir dir = SPIFFS.openDir("/");

  pinMode(BUILTIN_LED, OUTPUT);
  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
    Update.printError(Serial);
    Serial.println("ERROR");
  }

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

  }


  Serial.print(Update.end(true));
  digitalWrite(BUILTIN_LED, HIGH);
  file.close();
}

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 2 days ago

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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