Open sjefferson99 opened 1 month ago
https://www.kevsrobots.com/blog/micropython-ota.html
This guy wrote an OTA module for micropython. https://github.com/kevinmcaleer/ota/blob/main/ota.py
Basically urequest the raw github content and write to file, rename to main file and reboot. Actually as simple as we hoped, shouldn't be hard to write a module that works in smibhid (uses our wifi module and async requests etc). Also have something iterate through all the files in the smibhid lib folder + main.py. Should be very achievable.
Would we also want a way to manually push a file(s) to the picos remotley?
or use the web UI allow you to specify a branch and/or tag/revision to pull files from
Yes I have a number of ideas in my head still crystalising around identifying files changed, updating to a branch, pushing an individual file or files, checking config, recovering from a failed update etc. I will list them out here as I start writing components. Probably have some smaller enhancement records for each piece.
Looks like the answer right now is no we can't. I have confirmed the code works to download a small text file from a URL and the commit already made confirms the process works from there. But trying to execute a download request in our running system even with gc right before the request leads to out of memory and that's with a small 20 line file. There is simply not enough memory on the pico to do this while running the SMIBHID loop. Also I would need to use async requests and I don't know how to do that in the tinyweb API builder.
A few ideas that come to mind:
I will explore whether a cut down mode can pull the sort of file sizes we have for individual smibhid py files and then develop this if it works.
Latest commit on this branch is a working PoC of an update mode successfully downloading the 17kb space_state.py lib file. Iterates through URLs (one per line) in an /updates/.updating file if present. This file could be populated by the web UI with files to download and apply before reset, removing the .updating file. If file not present, main.py loads HID as normal.
Web UI to populate this file needs building and some further error handling and testing needed in the update code.
I will implement a backup directory of files changed (cleared before new download processing to ensure disk space is managed) and a main.py hid wrapper for catching errors and attempting restore from backup in #252
Is it possible to load new files into littlefs over an API/web page and save them and reset or are they locked?