-
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
Fix "espulp module broken in CircuitPython 9" #9277
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.
PR looks good, module looks amazing even by my cranky code standards.
Looks like a lovely excuse for me to give ULP a try.
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 would like to discuss further which type of ULP should be available. My gut was that riscv would be more useful, because it can be targeted with a gcc toolchain.
I would certainly love if the RISCV ULP were more accessible as it is definitely the more capable of the two ulps, and I do hope that espressif addresses the underlying issue preventing us from using both.
|
Risquev would be a lot more useful since it can be targetted by gcc, but it would be a lot less intuitive for a beginner to work with. The ULP assembly seems very friendly and simple from a quick read. Plus as Sola85 stated, og esp32 is a pretty big deal. |
C5, C6, C61 and P4 all have low power RISC-V cores. (Defined as My hope was to use |
Thanks for fixing this up @Sola85 ! |
Edit: This comment is no longer relevant. See the new comment below. The new PR only deviates from this one by one commit. |
I just learned that circuitpython maintains its own fork of esp-idf. I have submitted a PR adafruit/esp-idf#16 to that repo which would fix the underlying issue preventing us from using both ULPs. Should that PR get merged, we can enable both ULPs in this PR, by simply adding |
The PR to adafruit/esp-idf mentioned above got merged. I therefore pulled these changes and enabled the RISCV ulp again on supporting boards. See also the updated description of this PR above. |
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.
Thank you for getting this going! Just a couple comments about error checking. Generally we don't want to add new messages unless they are very specific.
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.
Looks good! Thank you!
This pull request fixes Issue #8770 as well as a few more minor issues with the existing
espulp
implementation. The changes/issues addressed are:RISCV
ULP is now disabled for all boards, as discussed in Issue espulp module broken in CircuitPython 9 #8770. This was necessary because with IDF Version 5.0, espressif only allows one type of ULP to be active at compile time, as documented here. This meant that some boards had access to only theFSM
, while others had access to only theRISCV
ULP.ULP
object.ulp.run()
method.ulp.run()
function, thenESP_PD_DOMAIN_RTC_PERIPH
is now configured to keep gpio powered during deep-sleep, such that the ulp can read/write gpio during deep sleep of the main cpu.ulp.run()
method checks that the ulp is not already running. But since theulp.halt()
method was not implemented for the FSM, this meant thatulp.run()
could only be called a second time after a power cycle or a hard-reset, because the ulp keeps running independent of the state of circuitpython. This is fixed by implementing theulp.halt()
method.Summary of the status of ULP support for all variants of the ESP32 that are currently supported by circuitpython:
RISCV working
RISCV working
Note: The RISCV-LP ulp of the esp32c6 was previously not implemented and is still not implemented since I do not own an esp32c6 and this is therefore outside the scope of this PR.
Here are two examples for using the ULPs to increment a variable (that now work after this PR).
ULP FSM (for esp32/esp32s2/esp32s3):
ULP RISCV (for esp32s2/esp32s3):