Skip to content
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

Can we find a way to apply new firmware over the air #241

Open
sjefferson99 opened this issue Oct 9, 2024 · 7 comments
Open

Can we find a way to apply new firmware over the air #241

sjefferson99 opened this issue Oct 9, 2024 · 7 comments
Assignees
Labels
🔮 enhancement New feature or request 👁 smib-hid SMIBHID related code

Comments

@sjefferson99
Copy link
Member

Is it possible to load new files into littlefs over an API/web page and save them and reset or are they locked?

@sjefferson99 sjefferson99 added the 🔮 enhancement New feature or request label Oct 9, 2024
@sjefferson99 sjefferson99 self-assigned this Oct 9, 2024
@sam57719
Copy link
Collaborator

sam57719 commented Oct 9, 2024

@sam57719
Copy link
Collaborator

sam57719 commented Oct 9, 2024

@sjefferson99
Copy link
Member Author

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.

@sam57719
Copy link
Collaborator

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

@sjefferson99
Copy link
Member Author

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.

@sjefferson99
Copy link
Member Author

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:

  • Use a pico2W when they come out as they have more RAM - It would be nice not to rely on better hardware, especially as it doesn't yet exist, although I hope it soon will.
  • Have SMIBHID reboot into an update firmware loop that isn't smibhidding and taking lots of RAM - This also means I can implement the safe mode firmware update idea in that safe mode rather than wrapping main in the exception loop and then calling safe mode/backup

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.

@sjefferson99
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔮 enhancement New feature or request 👁 smib-hid SMIBHID related code
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants