-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Raspberry Pi Pico hanging when writing microcontroller.nvm #4867
Comments
I tried this test on CircuitPython 7.0.0-alpha.2 and it worked correctly. |
I have done a few tests on this, I can definitely reproduce, but it's very inconsistent.
On a (not-freshly-erased) QT PY 2040 I get this without a code.py, simply connecting to the REPL and typing.
(hangs) |
This looks like this bug: raspberrypi/pico-sdk#457 that @dhalbert squashed. This pull fixes a clock startup glitch specific to a subset of QT Py RP2040s. Flash access takes a trip back through SDK initialization code to get XIP going again (it needs to leave XIP to do the flash write) which also restarts xosc, so that's where it's probably happening. |
The xosc fix I did is included in You could try changing the multiplier from 32 to 64 in |
Here are my results testing with
So, raspberrypi/pico-sdk#457 does not fix this bug. |
I can confirm that something similar happens on the macropad with alpha 5 |
I got a backtrace of this issue from a Raspberry Pi Pico using JLink and GDB. I'm not entirely sure what it means or what to do with the information I found but here is a paste of the backtrace in-case some else a little bit more knowledgeable knows what is going on "under the hood here". Upon crashing the first backtrace I saw was this:
From there I used GDB command to make it continue and received a second backtrace pointing to the next line down inside of
From there I again used GDB command to make it continue and ctrl-C again, and ended up a third different backtrace:
I repeated GDB continue and ctrl-c a few more times and got a few more stack traces until eventually finding one that doesn't point inside of crt0.S any more. (However I'm not entirely sure if these ones are as relevant to the problem. This is my first time using GDB debugging so I am wandering around a bit in the dark so to speak).
I found the file that it's pointing to inside the circuitpython repo at:
|
I think the issue may be that we shouldn't load any code when writing to flash. So, interrupts should be off during the write. These signal handlers show that this isn't the case. Since the stack is corrupt (5 and 6 being ??) I'd suggest adding printfs around the hang to determine where the flash write code gets stuck. |
I added some print statements inside It doesn't always crash on the same line. Here is the output from several test runs showing where the last print that occurred before the crash.
Each line represents a different test. I was using the sample code from the nvm docs for the tests: https://circuitpython.readthedocs.io/en/latest/shared-bindings/nvm/index.html?highlight=nvm#nvm.ByteArray It also does not fail every time. Sometimes the write succeeds and all of my print statements came out. @Neradoc observation about editing From these results and Scotts ideas I think maybe we need to wrap this section with disabling the interrupts and then re-enabling after: circuitpython/shared-bindings/nvm/ByteArray.c Lines 111 to 131 in f8493db
Is there an example somewhere else in the core where the interrupts are disabled and re-enabled? I can try it out if I have some code that does this to reference. |
Check this out: circuitpython/ports/raspberrypi/supervisor/internal_flash.c Lines 134 to 138 in f8493db
You'll want to modify the port specific code in the common-hal folder, not the code in shared-bindings. |
Fixed by #5663. Please try, and let us know. Note this fix is not in "Absolute Newest", because of git branches. Try the artifacts from https://github.com/adafruit/circuitpython/actions/runs/1540091742#artifacts. |
Firmware
REPL
Behavior
The system hangs, no error messages
Description
When it hangs, have to unplug the Pico and plug it back in.
The text was updated successfully, but these errors were encountered: