Closed DavePutz closed 2 years ago
Adafruit CircuitPython 7.0.0 on 2021-09-20; Raspberry Pi Pico with rp2040
This is the message that is printed by CircuitPython on a Raspberry Pi Pico but the code posted above appears to be for an Adafruit Feather RP2040. For example, board.D6
doesn't exist on a Raspberry Pi Pico but does exit on an Adafruit Feather RP2040.
On a Adafruit Feather RP2040 I'd expect the following message to be displayed:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Feather RP2040 with rp2040
What type of board is being used and was the correct version of CircuitPython flashed onto the board?
It fails on both, Easier to get traceback on pico board since it has easy to access debug pins. Feather 2040 need SMD headers soldered.
Yes the traceback was from a pico with pico circuitpython flashed to it.
On Sat, Oct 2, 2021 at 5:08 PM Brian Cooke @.***> wrote:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Raspberry Pi Pico with rp2040
This is the message that is printed by CircuitPython on a Raspberry Pi Pico but the code posted above appears to be for an Adafruit Feather RP2040. For example, board.D6 doesn't exist on a Raspberry Pi Pico but does exit on an Adafruit Feather RP2040.
On a Adafruit Feather RP2040 I'd expect the following message to be displayed:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Feather RP2040 with rp2040
What type of board is being used and was the correct version of CircuitPython flashed onto the board?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/adafruit/circuitpython/issues/5418#issuecomment-932826796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFM7PVIKJ7WIOZJZGW7SECLUE57G3ANCNFSM5FDFHKYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
It seems most likely that the problem arises when an RGBMatrix
has been created, but not its associated FramebufferDisplay
. We have to do "strange things" across a soft restart when these displayio-related objects exist. I recommend exploring this possibility, especially if that is the ONLY line where placing the exception-causing code leads to the problem.
The problem would not occur in quite the same way in the repl, because the soft reset would not occur until exiting the repl.
The issue looks to be that it is getting into the protomatter PWM interrupt handler when things are not set up yet. Note that a similar hang can be generated when running the script from https://learn.adafruit.com/rgb-led-matrices-matrix-panels-with-circuitpython/connecting-with-feather-rp2040-featherwing by hitting CTRL-C during startup. @jepler - I am not clear on why common_hal_rgbmatrix_rgbmatrix_construct is being called to create a PM object when things are in the process of shutting down. Can you clarify?
I have been able to correct the problem by turning off the PWM interrupt; putting a
irq_set_enabled(PWM_IRQ_WRAP, false);
near the beginning of _PM_begin in lib/protomatter/src/core.c; but I'm not sure that is a great solution.
When an RGBMatrix is initially constructed, its framebuffer (as well as other data used to do the low level "scan the matrix out" activity) is placed in the GC heap. Because displays are 'kept' over soft resets, there is a moment when it is necessary to destroy the RGBMatrix and construct a fresh one, placing the framebuffer in supervisor storage instead. This is what the common_hal_rgbmatrix_rgbmatrix_reconstruct function does when it's called during the interpreter teardown process. (there may be another way to do it, but this is the way I chose to do it. I welcome improvements to how this handover during reset is handled)
However, common_hal_rgbmatrix_rgbmatrix_construct should NOT be called during this time. (your traceback shows it being called during the run of your code.py)
To work as a displayio display, an RGBMatrix and a FramebufferDisplay object are both required to exist and work in concert. But in your example code, an RGBMatrix object is created but a FramebufferDisplay is not. This may have been an untested case and might not work properly.
CircuitPython version
Code/REPL
Behavior
Note that an intentional syntax error has been put in line 18. If the code is manually executed, the output is as expected:
However, if it is saved as code.py and automatically executed no messages are sent to the REPL device. The RP2040 is hung - CTRL-C, etc. have no effect. Compiling in DEBUG mode, the following stack was captured:
Description
The issue seems to be related to the use of rgbmatrix.RGBMatrix; as other code.py scripts with syntax errors behave as expected.
Additional information
No response