-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Conversation
} | ||
|
||
//rename the file to prevent an infinite loop of updates | ||
fs.rename("/update.bin", "/update_old.bin"); |
There was a problem hiding this comment.
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?
Please remove the bin from the example ;) I have left a couple other comments too |
@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: |
every implementation that I have seen deletes the bin on success and some leave a text file with log. |
For the sake of simplicity I modified it to just delete the file. 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. |
@krzychb that is actually a good point, I will remove it and adjust the file accordingly |
@me-no-dev @krzychb I've removed it, does it look fine now? :) |
@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. |
@Curclamas what's going on? :) are you going to fix this issue here? 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;
} |
Hey @me-no-dev , thanks for the hint! Will implement it in the next days since I'm quite busy right now! |
@me-no-dev, just added your recommended snippet to the code with a slight modification and committed it. |
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.