-->
Page 2 of 4

Re: Update ESP8266 from SPIFFS file

PostPosted: Sat Nov 05, 2016 11:58 am
by RichardS
In theory the Updater should work but from what I see you need to send it parameters like "client" which is network based....

I looked at updater.h and will try and use these functions....

Do I need to worry about MD5... how to know the file I updated with is valid?

RichardS

Re: Update ESP8266 from SPIFFS file

PostPosted: Sat Nov 05, 2016 12:59 pm
by RichardS
ESP.getSketchMD5() gets the current running sketch MD5?

So once I load new sketch how to make sure MD5 of the file is equal to the MD5 of the new yet to be executed sketch in flash?

Also when I execute MD5Final (hash, &md5); it seems to crash the ESP

RichardS

Re: Update ESP8266 from SPIFFS file

PostPosted: Sat Nov 05, 2016 4:38 pm
by martinayotte
I don't see any "client" refered in Updater.cpp ...

About MD5, it seems that if you never call Updater.setMD5, it won't check any, but if you provide one, calculated yourself from the file in SPIFFS, then it will verify it and will avoid replacing firmware if not matching.

Re: Update ESP8266 from SPIFFS file

PostPosted: Sat Nov 05, 2016 5:50 pm
by RichardS
That's what I thought and it seems I can not make it fail, I want to use MD5, I calculate one...

Code: Select all md5_context_t md5;
int fileLen;
char buf[64];
char hash[64];

fileLen = f.size();
MD5Init (&md5);
while (fileLen > 0) {
  readLen = f.read(buf, 64);
  MD5Update (&md5, buf, readLen);
  fileLen -= readLen;
  yield();
}
MD5Final (hash, &md5);


What size MD5 so I expect?? is it in character format?

BUT

When I do call setMD5(hash) it never complains if its valid or not.... I never get MD5 error.... even if I pass it hash[0] = 0;

I expect to be able to force an error code 7, which is bad MD5.

RichardS