| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@robert-hh would appreciate if you could take a look at this change, see if it makes sense to you. Thanks! |
Sorry, something went wrong.
|
Code size report: Reference: examples/rp2: Add PIO example for quadrature encoding. [9b2d80c]
Comparison: mimxrt/modmachine: Fix reset_cause and add HARD/DEEPSLEEP constants. [merge of a056c59]
mpy-cross: +0 +0.000%
bare-arm: +0 +0.000%
minimal x86: +0 +0.000%
unix x64: +0 +0.000% standard
stm32: +0 +0.000% PYBV10
esp32: +0 +0.000% ESP32_GENERIC
mimxrt: +104 +0.026% TEENSY40
rp2: +0 +0.000% RPI_PICO_W
samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
qemu rv32: +0 +0.000% VIRT_RV32
|
Sorry, something went wrong.
|
Thank you! |
Sorry, something went wrong.
|
Will do. |
Sorry, something went wrong.
|
Tested with MIMXRT1011 (Adafruit Metro M7), MIMXRT1020 (MIMXRT1020-EVK), MIMXRT1062 (Teensy 4.1 and OpenMV RT1060), MIMXRT1176 (MIMXRT1170-EVK). PWRON_RESET, WDT_RESET, DEEPSLEEP_RESET and SOFT_RESET are reliably detected. HARD_RESET is reported only immediately after firmware upload by the Adafruit and MIMXRT1020-EVK board. The MIMXRT MCUs do not have a dedicated hard reset Pin. Some board have a reset button, but that causes a power cycle. There is an irregularity with the MIMXRT1170-EVK board.
|
Sorry, something went wrong.
|
Thanks for testing!
I tested this by issuing machine.reset() at the REPL, then when it came back up as a USB device, checked the reset cause. It was HARD_RESET.
OK. That seems unrelated to this PR.
I pushed a commit which should resolve that issue: clearing the LPTA bit if it's set. Could you please retest on that board? |
Sorry, something went wrong.
Octoprobe PR report
Group: run-mpremote-tests.sh
|
Sorry, something went wrong.
It is a different issue- Deepsleep seem generally strange.
No change. Maybe one should fix the deepsleep() behavior first. |
Sorry, something went wrong.
|
At least, replacing machine.deepsleep() itself still behaves wrong. Either it resets immediately or not at all and the board freezes. But that's another story. |
Sorry, something went wrong.
| reset_cause = MP_DEEPSLEEP_RESET; | ||
| } else if (SNVS->LPSR & SNVS_LPSR_LPTA_MASK) { | ||
| // Device was reset due to low-power timer alarm. | ||
| SNVS->LPSR &= ~SNVS_LPSR_LPTA_MASK; |
There was a problem hiding this comment.
Better call instead machine_rtc_irq_deinit();. That fixes the sticky DEEPSLEEP_RESET state.
Sorry, something went wrong.
There was a problem hiding this comment.
You can call as well machine_rtc_alarm_off(true), which is called by machine_rtc_irq_deinit(), but it requires a declaration in modmachine.c, and an extra push of the argument.
Sorry, something went wrong.
There was a problem hiding this comment.
OK, thanks for that. I've now applied your suggestion to call machine_rtc_alarm_off(true) (that function is independent of the Python bindings/state, so a better fit).
Tested on TEENSY40 and it still works.
Sorry, something went wrong.
The `machine.reset_cause()` function was only partially working on mimxrt. This commit fixes it so that all five reset causes now work correctly: - SOFT_RESET is now set only after a soft reset at the REPL. - HARD_RESET is now set correctly (previously it used SOFT_RESET), and this constant is exposed to Python. - DEEPSLEEP_RESET is now set when the timer alarm wakes the device, and this constant is exposed to Python. Signed-off-by: Damien George <damien@micropython.org>
What argument are you using? I'm calling machine.deepsleep(1000). But regardless, that needs to be fixed in a separate PR. |
Sorry, something went wrong.
|
using machine.deepsleep(timeout) works with MIMXRT10xx, but not with MIMXRT117x. And machine.deepsleep() with a wakeup by low at the WAKEUP pin does not work at all.
For RT117x, using rtc.alarm() fails as well. The respective IRQ is simply not configured. I got to that because machine.deepsleep(timeout) uses the rtc alarm for the timeout. I'm working on it at the moment. rtc.alarm() and machine.deepsleep(timeout) for RT1176 are fine now, Pin wakeup from machine.deepsleep() is still due. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
The machine.reset_cause() function was only partially working on mimxrt. This commit fixes it so that all five reset causes now work correctly:
Testing
Tested on TEENSY40, using this helper script:
Run that via mpremote resume run cause.py to check the reset cause.
Tested all 5 cases, using machine.reset(), machine.deepsleep(1000) and machine.WDT(timeout=1000) to trigger the cases.
Generative AI
I did not use generative AI tools when creating this PR.