Skip to content

Fix alarm.wake_alarm not set after deep sleep on pi pico#7137

Closed
georgboe wants to merge 1 commit into
adafruit:mainfrom
georgboe:rpi-wakealarm
Closed

Fix alarm.wake_alarm not set after deep sleep on pi pico#7137
georgboe wants to merge 1 commit into
adafruit:mainfrom
georgboe:rpi-wakealarm

Conversation

@georgboe
Copy link
Copy Markdown

@georgboe georgboe commented Oct 27, 2022

Hi,

EDIT: Fixes #6483.

I would like to see this issue fixed, so I had a look at it.

The problem here seems to be that watchdog's scratch register is read and alarm.wake_alarm is assigned in run_boot_py as a part of start_mp. Afterwards the scratch register is cleared by alarm_reset (https://github.com/adafruit/circuitpython/blob/main/ports/raspberrypi/common-hal/alarm/__init__.c#L105). By the time we get to run_code_py the scratch register has already been cleared and we have nothing that indicates that we have woken from deep sleep so alarm.wake_alarm is set to None.

I'm not sure how you'd like this to be fixed. But if you can please have a look at the changes and suggest improvements or a different approach, I'd willing to change it.

@dhalbert
Copy link
Copy Markdown
Collaborator

Thanks for the insight! This is not a problem on ESP32-nn alarms because the "alarm happened" state is not cleared by alarm_reset(), but it is on RP2040, as you diagnosed. I am taking a look to see what the best way to fix this would be. There might be some issues not doing alarm_reset() during run_boot_py() if some pins are going to be used.

@dhalbert
Copy link
Copy Markdown
Collaborator

dhalbert commented Oct 27, 2022

Note to myself: fix should also take #6476 into account. That is on Espressif, but there may be a more general solution here.

@dhalbert
Copy link
Copy Markdown
Collaborator

Subsumed by #7154.

@dhalbert dhalbert closed this Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pico: alarm.wake_alarm not set after deep-sleep

2 participants