-
Notifications
You must be signed in to change notification settings - Fork 1.4k
build a CIRCUITPY_ERASER variant #4722
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
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.
Thanks for making this. One alternative that I've used for scenarios that needed this is to instruct Circuitpython to enter the repl first, before executing any user code. Simply erasing without having the user do anything is conveniently fire-and-forget, but it's another option to consider - sitting in the REPL would let you access the filesystem and extract things you want from it before erasing via storage. This would be done by changing bool skip_repl = true; to false in main().
1709147 to
bd2d7fd
Compare
We had a Slack discussion this morning where I proposed a safe-mode-only variant build, but it would be English-only, so we wouldn't double the number of builds. English-only was not favored, so I just made an eraser, which doesn't have any language to worry about. Obviously it's silly there's a lot of dead code in the firmware, but I started to make another executable that was much smaller and it was a lot more trouble than it was worth. |
hierophect
left a comment
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.
@dhalbert makes sense, sounds good to me
bd2d7fd to
e5b8745
Compare
e5b8745 to
6df4063
Compare
|
I'm making this draft while testing builds, so don't bother to review the actual code yet. The builds are not right: it did not do enough of a rebuild after the previous language (CIRCUITPY_ERASE is the same as zh_latn_pinyin). I know how to force a full rebuild but maybe there is something that will take less time. |
tannewt
left a comment
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.
I really don't like this. It has nothing to do with CircuitPython. I'd much rather factor out the useful bits from CircuitPython so that they can be used for other cross-board software. I understand this is the more expedient option but I think the extra work put into splitting useful things out will be more useful than we think.
It also erases all of the filesystem when we just want to disable boot.py and code.py to recover from USB mis-settings. This is what safe-mode is for and if it's broken on some boards, then we should fix it.
Is there a way to force entry to safe mode from the hardware? I've had to build versions of Circuitpython like this (or revert to old builds of Circuitpython that don't support what I'm working on) for peripheral-related bugs triggered by code.py that hang without crashing into safe mode, or occasionally for code that does something like restarting too fast, like a code.py that just calls |
|
Not sure if it has to be in or out of CircuitPython, but I believe Adafruit should be providing a safe UF2 file to restore the board to a working state, or one to test the board outside of user error... |
Boards without a status LED are an issue. Plus the Raspberry pico doesn't even have a reset button, so you couldn't do anything without adding wires. The only "safe" state the user can achieve with a naked pico is bootloader. Is it possible for those cases to have a UF2 that just writes some configuration bits that Circuitpython can then read ? Like "Drop this UF2 to start in safe mode". And do it again to restore normal behavior. |
On most boards you can click reset during a 700ms window at startup to restart into safe mode. On the ESP32-S2 the BOOT pin might work that way instead.
I think it's very rare to not have any status LED and even without it, the safe mode click should work (when a button exists.) We should fix the Pico to use the BOOTSEL state. |
|
I did start to implement this as a separate small executable based on the circuitpython code base ( This could easily be changed to just rename The 700ms safe mode window is hard to hit. My reaction time is not that good, and I have resorted to explaining this as a "slow" double-click, since I can't wait for yellow and then click again. Maybe just lengthening it slightly would be helpful. I would love an easier way to get into safe mode. In the long run a triple-click in the bootloader to enter safe mode or something similar would be nice, but it won't work on all boards. |
|
I'd say we could use one more of the following:
|
I'm totally open to increasing the time. It only occurs on power up so it's ok to make it longer. It's actually a hair under 700ms because it's 700 ticks which are just under a ms each.
I think we could patch builds instead of rebuilding to do this. (Have a variable to check for safe mode and use the map file to know where it is in the binary and then change it.) It'd still double the number of artifacts but not the build time. |
|
Closing for now. |
I like this idea - if it works, it achieves all the objectives in this thread, without the CI drawback. |
Is there a how-to for this yet? I think anything that can be installed should have an uninstaller In short, how to nuke/remove CircuitPython and leave it in a state for Arduino IDE? |
|
@rjsdotorg this bug was about erasing the contents of the filesystem on the flash, not CircuitPython itself. You can erase CircuitPython easily enough by simply flashing any Arduino program. If your Arduino IDE can't flash it, it's not CircuitPython's fault. |
|
@rjsdotorg Please bring this up in https://forums.adafruit.com or in discord (https://adafru.it/discord) and we can help diagnose. There are many possible causes for this. |
Will do. Thanks. |
For each board, this builds one special build that erases CIRCUITPY when loaded. The status LED starts at red and goes to blue when done. The build does nothing after erasing: no USB mounting, etc. So it's language-independent.
The GitHub Actions build will create a new
CIRCUITPY_ERASERdirectory in S3 for each board, alongside the language directories.Basically, this is a simple way of making per-board flash erasers without involving Arduino, etc.
Tested on a Trinket M0, but I need to see GitHub Actions working properly too.