-
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
Refine coprocessor API #7218
Comments
I like the general idea that this portrays and agree with the suggested api changes. |
Ok, I've spent a good chunk of time on this in https://github.com/tannewt/circuitpython/tree/rework_coproc_api. I've tried getting the ULP working on ESP32-S3 and have only managed to get it working after reset. It stops working after reloads. Furthermore, I've traced some S3 sleep issues to having the coprocessor enabled (but not used by CP) due to the ulp falsely triggering on fault. So, I'd like to simply remove the |
Power usage should also be checked since the IDF fix for the S3 forces the ULP clock on. It may invalidate power savings without the ULP. |
Ok, with @microdev1's help (thanks!) I've made good progress. My program was failing because I set the stack pointer to the wrong address. 🤦 I was also setting the wrong bit in the gpio registers (there's an extra 10 bit shift.) I'll need to test deep sleep with it next week. (To make sure #7300 is fixed.) |
I think we should build on #6902 and refine the APIs to be more generic. I've been thinking about coprocessor and memory APIs within a few contexts that this API can apply to:
So I think there are two separate pieces:
We should also think about a world with more than one coprocessor (like Cortex-A chips or multiple Stemma QT coprocessors.) I doubt we want
run
andhalt
at the module level. Perhaps we want to makemicrocontroller.cpu[1+]
beCoprocessor
instances instead ofmicrocontroller.Processor
. We probably want to revamp Processor too.uid
,temperature
,reset_reason
are actually system level. Processor would be the core that runs CircuitPython and the Coprocessors would be CircuitPython controlled and tracked like other peripherals for "in use."I don't think we want to manage multiple programs (or tasks) on a single cpu. Instead, we keep along the lines of doing one thing on a core at a time and track "in use". Later, if we want to do multiple tasks across a set of cores, then the Coprocessors could be added to a task manager-ish thing. (The USB host code on the RP2040 will need to claim the coprocessor for example.)
Here are the things I'd definitely do before 8.0.0:
coproc.CoprocMemory
tomemoryio.Memory
. The shared-bindings constructor should delegate to a port-specific construct method so that a port can raise exceptions for protected memory regions and track "in use". The goal is to make it harder to have two things using memory at once including native classes and memoryio concurrently. (A kwarg could be given to override this check.) Making this generic would allow us to write peripheral drivers in pure python, not just C.coproc
tocoprocessor
for clarity. Can alwaysimport coprocessor as coproc
to shorten it.coproc.Coproc
toProgram
(it should look similar to PIO's programs) or skip this and use aReadableBuffer
for the program like the low level PIO API. If we addProgram
, then it could be generically used for both on-chip coprocessors and those off-chip (like Stemma Qt.) We may want to include architecture and entry address info on it.coprocessor.Coprocessor
class for run and halt. TheCoprocessorAlarm
would also take aCoprocessor
along with theProgram
.The text was updated successfully, but these errors were encountered: