← index #15622Issue #15623
Related · high · value 5.561
QUERY · ISSUE

RP2350 / Pico 2 machine.lightsleep not working correctly

openby geerlingguyopened 2024-08-08updated 2025-03-03
bugport-rp2

Port, board and/or hardware

Pico 2 / RP2350

MicroPython version

MicroPython v1.24.0-preview.201.g269a0e0e1 on 2024-08-09; Raspberry Pi Pico2 with RP2350

Reproduction

  1. Install latest Firmware from https://micropython.org/download/RPI_PICO2/
  2. Implement machine.lightsleep(5000) in your code
  3. Run code.

Expected behaviour

Expected Pico 2 to enter lightsleep mode for 5 seconds, then continue to next bit of code.

Observed behaviour

lightsleep is maybe entered for a cycle or so, but code carries on and never stops executing for any time value I enter for lightsleep.

Additional Information

Complete code example:

# Lightsleep MicroPython example.
from machine import Pin
import time
led = Pin(25, Pin.OUT)

while True:
    led.toggle()
    time.sleep_ms(5000)
    led.toggle()
    machine.lightsleep(5000)

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

RP2350 / Pico 2 machine.deepsleep results in crash

openby geerlingguyopened 2024-08-08updated 2025-03-03
bugport-rp2

Port, board and/or hardware

Pico 2 / RP2350

MicroPython version

MicroPython v1.24.0-preview.201.g269a0e0e1 on 2024-08-09; Raspberry Pi Pico2 with RP2350

Reproduction

  1. Install latest Firmware from https://micropython.org/download/RPI_PICO2/
  2. Implement machine.deepsleep(5000) in your code
  3. Run code.

Expected behaviour

Expected Pico 2 to enter deepsleep mode for 5 seconds, then continue to next bit of code.

Observed behaviour

Upon reaching deepsleep, the LED on my Pico blinks when it reaches that part of the code, but Thonny's console outputs:

PROBLEM IN THONNY'S BACK-END: Exception while handling 'Run' (ConnectionError: read failed: [Errno 6] Device not configured).
See Thonny's backend.log for more info.
You may need to press "Stop/Restart" or hard-reset your MicroPython device and try again.


Process ended with exit code 1.
Unable to connect to /dev/cu.usbmodem83101: [Errno 2] could not open port /dev/cu.usbmodem83101: [Errno 2] No such file or directory: '/dev/cu.usbmodem83101'

Contents of backend.log after the Shell displays that error:

12:00:29.977 [MainThread] INFO    thonny: Thonny version: 4.1.4
12:00:29.977 [MainThread] INFO    thonny: cwd: /Users/jgeerling
12:00:29.977 [MainThread] INFO    thonny: original argv: ['/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python', '-s', '-u', '-B', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/thonny/plugins/rp2040/rp2040_back.py', "{'clean': True, 'port': '/dev/cu.usbmodem83101', 'dtr': None, 'rts': None, 'submit_mode': 'raw_paste', 'interrupt_on_connect': True, 'write_block_size': 64, 'write_block_delay': None, 'proxy_class': 'RaspberryPiPicoBackendProxy', 'sync_time': True, 'validate_time': False, 'local_rtc': True}"]
12:00:29.977 [MainThread] INFO    thonny: sys.executable: /Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/bin/python3.10
12:00:29.977 [MainThread] INFO    thonny: sys.argv: ['/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/thonny/plugins/rp2040/rp2040_back.py', "{'clean': True, 'port': '/dev/cu.usbmodem83101', 'dtr': None, 'rts': None, 'submit_mode': 'raw_paste', 'interrupt_on_connect': True, 'write_block_size': 64, 'write_block_delay': None, 'proxy_class': 'RaspberryPiPicoBackendProxy', 'sync_time': True, 'validate_time': False, 'local_rtc': True}"]
12:00:29.977 [MainThread] INFO    thonny: sys.path: ['/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/thonny/plugins/rp2040', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python310.zip', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload', '/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages']
12:00:29.977 [MainThread] INFO    thonny: sys.flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=1, no_user_site=1, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0, dev_mode=False, utf8_mode=0, warn_default_encoding=0, int_max_str_digits=-1)
12:00:29.978 [MainThread] INFO    thonny.plugins.micropython.bare_metal_backend: Starting backend, args: {'clean': True, 'port': '/dev/cu.usbmodem83101', 'dtr': None, 'rts': None, 'submit_mode': 'raw_paste', 'interrupt_on_connect': True, 'write_block_size': 64, 'write_block_delay': None, 'proxy_class': 'RaspberryPiPicoBackendProxy', 'sync_time': True, 'validate_time': False, 'local_rtc': True}

Additional Information

Full code example:

# Lightsleep MicroPython example.
from machine import Pin
import time
led = Pin(25, Pin.OUT)

while True:
    led.toggle()
    time.sleep_ms(5000)
    led.toggle()
    machine.deepsleep(5000)

On the original Pico, deepsleep was, I believe, an alias to lightsleep. On Pico 2, it looks like there are deeper sleep states that may be implemented and an internal RTC that can be used to wake the chip... is it possible that either the deepsleep option could differ on the Pico 2, or should it just remain an alias to lightsleep?

Either way, the behavior here is different than lightsleep—which also breaks right now, see #15622.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied