RP2350 / Pico 2 machine.deepsleep results in crash
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
- Install latest Firmware from https://micropython.org/download/RPI_PICO2/
- Implement
machine.deepsleep(5000)in your code - 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
RP2350 bricked with micropython
Port, board and/or hardware
RP2350
MicroPython version
Hello dear micropython developers,
today I got my hands on a brand new Pico 2 board. Since there is currently only one firmware release available, I flashed RPI_PICO2-20240809-v1.24.0-preview.201.g269a0e0e1.uf2.
Secondly since this would be a successor to my self made FanController project, I copied over the source files as well. After the Pico restarted it started flashing the onboard LED as intended. But it does not enumerate to USB any more.
When I hold down the BOOT button while plugging it in, I get the RP2350 memory exposed in file explorer and can copy over the same RPI_PICO2-20240809-v1.24.0-preview.201.g269a0e0e1.uf2 again. The controller disconnects form my computer, does not enumerate to USB and starts flashing again.
For RP2040 there is a "flash_nuke.uf2" file which the controller (RP2350) does not respond to.
I've reported the issue of easily brickable RP2040 some weeks ago and hope any fix is coming soon?
See: https://github.com/micropython/micropython/issues/15230#issuecomment-2277896658
content of my boot.py without imports:
if __name__ == "__main__":
logger = DebugLogger(0)
try:
loop = asyncio.get_event_loop()
program = FanController(logger)
program._setcpuspeed(Constants.CPU_SPEED_HZ)
program.startup(False)
programThread = _thread.start_new_thread(program.startProgram, ())
program.serialTransport.flushinput()
comms = loop.create_task(program.serialTransport.receive(
program.commandprocessor.handlecommand))
fanramp = loop.create_task(program.rampupfans())
temps = loop.create_task(program.readtemperaturestodatamodel())
autocontrol = loop.create_task(program.controller.runAutomaticControl())
program._cleangarbage()
loop.run_forever()
except KeyboardInterrupt:
program.onboardled.signalInterrupted()
program.stopProgram()
loop.stop()
logger.log(logger.DEBUG, "INTERRUPTED - STOPPING EVERYTHING")
program.serialTransport.stopreading()
One note: my serialTransport.receive() method is constantly reading asynchronously on sys.stdin. But this code still works in "older" micropython version flawlessly.
Edit: intermediate help: https://datasheets.raspberrypi.com/soft/flash_nuke.uf2 - clears the flash and brings the device back to life, except I can't run my micropython code on it.
Reproduction
Since I can't get any communication with the device and can not flash any other firmware for RP2350 I can't provide steps to reproduce, since I "know" that my python code works on Rp2040 and micropython 1.21.
Expected behaviour
When the device is connected to USB it enumerates an serial com device.
Observed behaviour
No device is enumerated. Device can only enumerate when in BOOTSEL mode.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree