Skip to content

Add example to update ESP32 via SD card #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 29, 2017

Conversation

Curclamas
Copy link
Contributor

This example demonstrates how the Update library can also be used for offline uploads via SD card. This provides an update path where Internet is not available or OTA won't work and no serial programmer is at hand.

}

//rename the file to prevent an infinite loop of updates
fs.rename("/update.bin", "/update_old.bin");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just delete it?

@me-no-dev
Copy link
Member

Please remove the bin from the example ;) I have left a couple other comments too

@Curclamas
Copy link
Contributor Author

@me-no-dev thanks for the comments. I can surely remove the .bin from the repo and just delete the .bin from the SD card. Just two cents why I did it that way:
I've added the binary to the repo to provide an easy way to test the app (like in the AWS Update example). The renaming of the binary happens because it gives an Indication of success while not "harshly" deleting it. But you are right, just deleting it would make the code leaner and easier to read.

@me-no-dev
Copy link
Member

every implementation that I have seen deletes the bin on success and some leave a text file with log.

@Curclamas
Copy link
Contributor Author

For the sake of simplicity I modified it to just delete the file. What about the included binary in the repo?

@krzychb
Copy link

krzychb commented Sep 13, 2017

What about the included binary in the repo?

Bin is h/w specific and my not match e.g. the XTAL frequency of user's board.

@Curclamas
Copy link
Contributor Author

@krzychb that is actually a good point, I will remove it and adjust the file accordingly

@Curclamas
Copy link
Contributor Author

@me-no-dev @krzychb I've removed it, does it look fine now? :)

@me-no-dev
Copy link
Member

@Curclamas see I have another comment about checking if "/update.bin" is actually a file. New API will return "true" on fs.open if the path is a directory as well. So it needs to check that it is a file.

@me-no-dev
Copy link
Member

@Curclamas what's going on? :) are you going to fix this issue here?
Please note:

on ESP32 you need to make sure that it's a file

void updateFromFS(fs::FS &fs) {
   File updateBin = fs.open("/update.bin");
   if (updateBin) {
     if(updateBin.isDirectory()){
       Serial.println("Update is not a file");
       updateBin.close();
       return;
     }

@Curclamas
Copy link
Contributor Author

Hey @me-no-dev , thanks for the hint! Will implement it in the next days since I'm quite busy right now!

@Curclamas
Copy link
Contributor Author

Curclamas commented Sep 28, 2017

@me-no-dev, just added your recommended snippet to the code with a slight modification and committed it.

@me-no-dev me-no-dev merged commit 10ff1de into espressif:master Sep 29, 2017
@Curclamas Curclamas deleted the feature-sd_update branch November 1, 2017 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants