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

asked Jan 5, 2019 at 23:12
6
  • why don't you have a single program that does both A and B? Commented Jan 5, 2019 at 23:18
  • Look at what ArduinoOTA does. 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? 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. 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. Commented Jan 5, 2019 at 23:45

2 Answers 2

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
answered Jan 6, 2019 at 6:43
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.

answered Jan 7, 2019 at 11:18
1
  • Confirmed,works like a charm. Flashes firmware with a file from SPIFFS. Commented Jan 19, 2019 at 20:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.