-
Notifications
You must be signed in to change notification settings - Fork 0
Add hardware tests for machine.lightsleep and machine.deepsleep #26
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
|
@copilot , would it be possibility to use Esp32 wiring with a lower GPIO pin number that is also supported on the esp32-C3 so that this PR can also be tested ? |
tests/target_wiring/esp32.py
Outdated
| # Sleep wake test configuration (optional) | ||
| # Connect sleep_trigger_pin to sleep_wake_pin for GPIO wake tests | ||
| sleep_wake_pin = 2 # Pin configured to wake from sleep | ||
| sleep_trigger_pin = 15 # Pin used to generate wake signal |
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.
Would prefer a lower GPIO if possible
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.
Would prefer a lower GPIO if possible
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.
Changed to GPIO2/GPIO3 which work on all ESP32 variants including C3. Updated across all files. (df60e32)
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.
@copilot, the sleep trigger pin is still a high GPIO, please correct if possible
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.
Already corrected in df60e32 - sleep_trigger_pin changed from GPIO15 to GPIO3. Current configuration uses GPIO2↔GPIO3 for all sleep tests.
…PIO pins for ESP32-C3 compatibility Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Changed ESP32 wiring to use GPIO2↔GPIO3 instead of GPIO2↔GPIO15. These lower GPIO pins are supported on ESP32-C3 and all other ESP32 variants. No separate wiring script needed. (df60e32) |
Summary
Implements unittest-based hardware tests for
machine.lightsleep()andmachine.deepsleep()that can be executed against connected MicroPython boards using the existing test framework. Addresses the need to validate sleep functionality across platforms with minimal hardware setup.Test files added:
tests/extmod_hardware/machine_lightsleep.py- Timer-based wake, state preservation, timing validation (no hardware required)tests/extmod_hardware/machine_deepsleep.py- Reset cause detection, state file utilities, manual test patternstests/extmod_hardware/machine_lightsleep_gpio.py- GPIO wake tests for ESP32 (EXT0) and RP2 (IRQ) with loopbackConfiguration:
tests/target_wiring/esp32.pyandtests/target_wiring/rp2.pywith sleep test pin mappingsDocumentation:
docs/sleep_test_research.md- Platform capabilities, wake sources, implementation strategiestests/README.mdwith concise sleep testing sectiontests/run_sleep_tests_example.py- Interactive test runnerTesting
Tests validated for syntax and structure. Ready for hardware validation on:
Timer-based tests require no external connections. GPIO wake tests require 2-wire loopback as documented in target_wiring configs.
Trade-offs and Alternatives
Deepsleep testing is challenging due to device reset clearing test state. Implementation provides:
Full automated deepsleep validation would require external test harness to monitor device resets. Current approach balances automation with practical constraints while providing clear manual testing guidance.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.